0

I'm trying to link my built assimp library to an empty test project but I'm unable to for whatever reason. I have very little knowledge of CMake so I'm just completely confused.

I build the Assimp library following the tutorial for "build from source "(https://github.com/assimp/assimp/blob/master/Build.md) using the visual studio 2019 compiler. I then found the .dll and added it to my system path and restarted my computer. Then I used added the .lib to my cmake file

project(godijustwantittowork)

set(CMAKE_CXX_STANDARD 14)

include_directories("../libraries/assimp-5.2.3/include/")

add_executable(${PROJECT_NAME} main.cpp)
target_link_libraries(${PROJECT_NAME} "C:/libraries/assimp-5.2.3/lib/Debug/assimp-vc142-mtd.lib")

I also tried localising include_directories("../libraries/assimp-5.2.3/include/") by moving the include folder so include_directories became include_directories("include/assimp-5.2.3/include/") That also didn't work.

So I tried building assimp in the project's include folder and moved the PATH .dll to the new location and restart my computer. I fixed up the CMakeLists.txt to:

project(godijustwantittowork)

set(CMAKE_CXX_STANDARD 14)

include_directories("include/assimp-5.2.3/include/")

add_executable(${PROJECT_NAME} main.cpp)

find_library(ASSIMP_LOCATION NAMES "assimp-vc142-mtd" HINTS "include/assimp-5.2.3/lib/Debug/" REQUIRED)
message(${ASSIMP_LOCATION})
target_link_libraries(${PROJECT_NAME} "${ASSIMP_LOCATION}")

But all of these attemps give the same undefined reference to 'x' error. Full Error:

"C:\Program Files\JetBrains\CLion 2020.3\bin\cmake\win\bin\cmake.exe" --build C:\godijustwantittowork\cmake-build-debug --target all -- -j 9
Scanning dependencies of target godijustwantittowork
[ 50%] Building CXX object CMakeFiles/godijustwantittowork.dir/main.cpp.obj
[100%] Linking CXX executable godijustwantittowork.exe
CMakeFiles\godijustwantittowork.dir\build.make:95: recipe for target 'godijustwantittowork.exe' failed
CMakeFiles\Makefile2:81: recipe for target 'CMakeFiles/godijustwantittowork.dir/all' failed
Makefile:89: recipe for target 'all' failed
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: CMakeFiles\godijustwantittowork.dir/objects.a(main.cpp.obj): in function `main':
C:/godijustwantittowork/main.cpp:10: undefined reference to `Assimp::Importer::Importer()'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:/godijustwantittowork/main.cpp:11: undefined reference to `Assimp::Importer::ReadFile(char const*, unsigned int)'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:/godijustwantittowork/main.cpp:10: undefined reference to `Assimp::Importer::~Importer()'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:/godijustwantittowork/main.cpp:10: undefined reference to `Assimp::Importer::~Importer()'
collect2.exe: error: ld returned 1 exit status
mingw32-make.exe[2]: *** [godijustwantittowork.exe] Error 1
mingw32-make.exe[1]: *** [CMakeFiles/godijustwantittowork.dir/all] Error 2
mingw32-make.exe: *** [all] Error 2

I'm sure this has been posted before but I was unable to fix my issues so I've decided to just ask here. CLion uses gcc I believe, is the different compilers causing issues? if so how do I fix that?

  • You can't use a visual studio library in gcc, you'll need to get/compile a gcc version of the library – Alan Birtles May 04 '22 at 06:36
  • @AlanBirtles sorry to bother you. I'm unable to build with gcc. I do the commands "cmake CMakeLists.txt -G "MinGW Makefiles" -Wno-error=implicit-function-declaration cmake --build ." but I still get this output "error: implicit declaration of function 'ftello'; did you mean 'ftell'? [-Werror=implicit-function-declaration]". Doesn't matter if I use -Wno-error flag either still get the error. I've tried from a fresh install as well and I still get the error using the flags. – confused cmake user May 04 '22 at 07:48
  • Sounds like a new question, I assume you've read the documentation of the library? It's entirely possible they've just never built with mingw, its not a particularly widely used platform – Alan Birtles May 04 '22 at 08:36

0 Answers0