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?