Trouble building the Open Asset Import Library (As

2019-02-09 15:06发布

问题:

I have just downloaded the Open Asset Import Library (Assimp) which is an API used to import 3D file formats such as .3DS and .Obj into source code. Doing so allows for much easier rendering of meshes using openGL.

The problem is, I can't get the Library to build. It comes with very vague and cryptic directions on how to build it and connect to a compiler such as XCode (which I am using). It says I should use a program called CMake to build the library. I have downloaded CMake and tried to use it but it has not yet worked for me.

Has anyone here successfully built and installed Assimp using CMake or some other tool?

回答1:

I totally agree that the documentation for Mac is a bit lacking, but I have managed (after several attempts) to build and install the library.

A few things before starting: make sure you have installed XCode Command Line Tools (that installs the GNU compiler). These are the steps I followed:

  1. Download the latest release of Assimp and extract it (I got the file from here, the one with source only: http://sourceforge.net/projects/assimp/files/assimp-3.0/)
  2. If you don't have it, install CMake (http://www.cmake.org/cmake/resources/software.html; I'm currently using an older version, but the latest one should work fine as well)
  3. Create a build directory (should be outside the source directory)
  4. Open CMake and point it to the folder you created at step 1 (where it says "Where is the source code"); the other folder ("Where to build the binaries") should point to the folder created at step 3
  5. Click "Configure" on the bottom; it will ask you which environment you'd like to use. I picked "Eclipse CDT 4 - Unix Makefiles"
  6. You should get a list of options; the two I selected were "BUILD_STATIC_LIB" and "ENABLE_BOOST_WORKAROUND"
  7. Click "Generate"
  8. Now you should move to the terminal and go to the folder created at step 3
  9. Type "make" and launch it; you should see the build progressing without issues
  10. When the build is finished, type "sudo make install"; it will ask for your password and install the library

After the last step you should be able to include the library in your code:

#include <assimp/cimport.h>
#include <assimp/scene.h>
#include <assimp/postprocess.h>

Make sure you also include the library for linking; when linking you should add -lassimp to the list

Let me know if you have any issues with the steps above!