3

I have been trying to install Assimp 3.0 recently to load models from Blender to use in OpenGL.

My project is setup in Sublime Text 3, so I have created CMake files to generate the required make files for me to build my project.

All of the other libraries I am using, for example SFML, are being included and linked fine, but for some reason Assimp isn't working.

On build I get the following linker errors:

undefined reference to `Assimp::Importer::Importer()
undefined reference to `Assimp::Importer::~Importer()
undefined reference to `Assimp::Importer::~Importer()

Since this is a linker error I am under the assumption that my problem lies in my CMake files.

I created a FindASSIMP.cmake file to set some variables for me with the correct include directory and the path of the .lib files that need to be linked, and I can see that it is working fine because I can print the resulting variables and get the expected output.

I have two variables ${ASSIMP_INCLUDE_DIR} and ${ASSIMP_LIBRARY}.

In a release build:

${ASSIMP_INCLUDE_DIR} = C:/lib/assimp/3.0/include
${ASSIMP_LIBRARY} = C:/lib/assimp/3.0/lib/assimp_release-dll_win32/assimp.lib

My main CMake file which brings everything together goes something like this (with a lot of unrelated stuff stripped out):

set(EXE "main")

# Add sub-directories to create libraries from my files
add_subdirectory(various_sub_dirs)

add_executable(${EXE} my_sources.cpp)

# Link up my sub-directory libraries
target_link_libraries(${EXE} various_libraries_from_my_code)

# Link up external libraries
target_link_libraries(${EXE} ${ASSIMP_LIBRARY})
target_link_libraries(${EXE} ${GLEW_LIBRARIES})
target_link_libraries(${EXE} ${GLUT_LIBRARY})
target_link_libraries(${EXE} ${OPENGL_LIBRARIES})
# etc...

I don't get any include errors, so I know the inlcude directory is being used correctly, but for some reason, even though I can print out the exact path to the .lib file I am linking, it either isn't actually linking, or I'm linking the wrong thing.

Does anybody know why I am seeing these linker errors?

Do I need to link a different file? Or perhaps I need to link it in a certain order?

Any help would be appreciated because I can't see what I'm doing wrong.

If any more information is needed, please leave a comment and I will edit the question as soon as I can.

4
  • How are you building this? Have you checked that C:/lib/assimp/3.0/lib/assimp_release-dll_win32/assimp.lib is listed in the link command?
    – Fraser
    Commented Apr 12, 2013 at 1:29
  • @Fraser I am building with MinGW on Windows 7 via make files which are generated with CMake. I just turned on VERBOSE=1 for the make command and I can see that the path to the .lib file is being included at the linking stage with g++. The output I can see is basically this (... is where I have omitted things): "C:\mingw_path\g++.exe -std=c++11 -Wall ... -o C:\bin_path\main.exe ... C:\lib\assimp\3.0\lib\assimp_release-dll_win32\assimp.lib ...". I have tried using the assimp.lib, Assimp32.dll and Assimp64.dll files, but all of them give the same result (actually the x64 dll is not recognised).
    – Lucas
    Commented Apr 12, 2013 at 4:38
  • I'm not too familiar with MinGW I'm afraid. My only suggestion would be to try linking assimp last in case one of the other libs has it as a dependency. Just try moving the target_link_libraries(${EXE} ${ASSIMP_LIBRARY}) to the end of all the target_link_libraries calls.
    – Fraser
    Commented Apr 12, 2013 at 4:50
  • @Fraser Thank you for you're time, but it seems the problem was with the pre-compiled files that came with the download. I just compiled the library files myself with CMake and Make, and used those files instead and now it is working without any problems at all.
    – Lucas
    Commented Apr 12, 2013 at 5:06

1 Answer 1

2

The problem was in the pre-compiled libraries that came with the full download of Assimp 3.0.

I used CMake and Make to compile the Assimp libraries myself and now it is working without any problems.

1
  • 2
    Can you elaborate how you got this to work? When I try to compile using CMake and VS2013, I get an .exe that has unresolved methods (checked using Dependency Walker). Commented Jun 8, 2015 at 17:19

Not the answer you're looking for? Browse other questions tagged or ask your own question.