0

I'm trying to use assimp in my project. I get assimp with conan and cmake:

macro(run_conan)
# Download automatically, you can also just copy the conan.cmake file
if(NOT EXISTS "${CMAKE_BINARY_DIR}/conan.cmake")
  message(
    STATUS
      "Downloading conan.cmake from https://github.com/conan-io/cmake-conan")
  file(DOWNLOAD "https://github.com/conan-io/cmake-conan/raw/v0.15/conan.cmake"
       "${CMAKE_BINARY_DIR}/conan.cmake")
endif()

include(${CMAKE_BINARY_DIR}/conan.cmake)

conan_add_remote(NAME bincrafters URL
                 https://api.bintray.com/conan/bincrafters/public-conan)

conan_cmake_run(
  REQUIRES
  ${CONAN_EXTRA_REQUIRES}
  glfw/3.3.2
  glad/0.1.33
  glm/0.9.9.8
  stb/20200203
  assimp/5.0.0
  OPTIONS
  ${CONAN_EXTRA_OPTIONS}
  BASIC_SETUP
  CMAKE_TARGETS # individual targets to link to
  BUILD
  missing)
endmacro()

and link it to my target like this:

target_link_libraries(my_lib PUBLIC CONAN_PKG::glm CONAN_PKG::glfw CONAN_PKG::glad CONAN_PKG::stb CONAN_PKG::assimp)
add_executable(lib_test test.cpp)
target_link_libraries(lib_test PUBLIC  project_options project_warnings my_lib)

when i try to build project i get linker errors in assimp files. I suspect there is something wrong with zlib:

/usr/bin/ld: /home/wojto/.conan/data/assimp/5.0.0/_/_/package/9a4d2bae52ac84e2ccb41d80f63793a0dfd0e50b/lib/libassimpd.a(IFCLoader.cpp.o): in function `Assimp::IFCImporter::InternReadFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, aiScene*, Assimp::IOSystem*)':
/home/wojto/.conan/data/assimp/5.0.0/_/_/build/9a4d2bae52ac84e2ccb41d80f63793a0dfd0e50b/source_subfolder/code/Importer/IFC/IFCLoader.cpp:186: undefined reference to `unzOpen'
/usr/bin/ld: /home/wojto/.conan/data/assimp/5.0.0/_/_/build/9a4d2bae52ac84e2ccb41d80f63793a0dfd0e50b/source_subfolder/code/Importer/IFC/IFCLoader.cpp:203: undefined reference to `unzGoToFirstFile'
/usr/bin/ld: /home/wojto/.conan/data/assimp/5.0.0/_/_/build/9a4d2bae52ac84e2ccb41d80f63793a0dfd0e50b/source_subfolder/code/Importer/IFC/IFCLoader.cpp:208: undefined reference to `unzGetCurrentFileInfo'
/usr/bin/ld: /home/wojto/.conan/data/assimp/5.0.0/_/_/build/9a4d2bae52ac84e2ccb41d80f63793a0dfd0e50b/source_subfolder/code/Importer/IFC/IFCLoader.cpp:214: undefined reference to `unzOpenCurrentFile'
/usr/bin/ld: /home/wojto/.conan/data/assimp/5.0.0/_/_/build/9a4d2bae52ac84e2ccb41d80f63793a0dfd0e50b/source_subfolder/code/Importer/IFC/IFCLoader.cpp:220: undefined reference to `unzReadCurrentFile'
/usr/bin/ld: /home/wojto/.conan/data/assimp/5.0.0/_/_/build/9a4d2bae52ac84e2ccb41d80f63793a0dfd0e50b/source_subfolder/code/Importer/IFC/IFCLoader.cpp:233: undefined reference to `unzCloseCurrentFile'
/usr/bin/ld: /home/wojto/.conan/data/assimp/5.0.0/_/_/build/9a4d2bae52ac84e2ccb41d80f63793a0dfd0e50b/source_subfolder/code/Importer/IFC/IFCLoader.cpp:247: undefined reference to `unzClose'
/usr/bin/ld: /home/wojto/.conan/data/assimp/5.0.0/_/_/package/9a4d2bae52ac84e2ccb41d80f63793a0dfd0e50b/lib/libassimpd.a(ZipArchiveIOSystem.cpp.o): in function `Assimp::ZipFileInfo::ZipFileInfo(void*, unsigned long)':
/home/wojto/.conan/data/assimp/5.0.0/_/_/build/9a4d2bae52ac84e2ccb41d80f63793a0dfd0e50b/source_subfolder/code/Common/ZipArchiveIOSystem.cpp:218: undefined reference to `unzGetFilePos'
/usr/bin/ld: /home/wojto/.conan/data/assimp/5.0.0/_/_/package/9a4d2bae52ac84e2ccb41d80f63793a0dfd0e50b/lib/libassimpd.a(ZipArchiveIOSystem.cpp.o): in function `Assimp::ZipFileInfo::Extract(void*) const':
/home/wojto/.conan/data/assimp/5.0.0/_/_/build/9a4d2bae52ac84e2ccb41d80f63793a0dfd0e50b/source_subfolder/code/Common/ZipArchiveIOSystem.cpp:224: undefined reference to `unzGoToFilePos'
/usr/bin/ld: /home/wojto/.conan/data/assimp/5.0.0/_/_/build/9a4d2bae52ac84e2ccb41d80f63793a0dfd0e50b/source_subfolder/code/Common/ZipArchiveIOSystem.cpp:227: undefined reference to `unzOpenCurrentFile'
/usr/bin/ld: /home/wojto/.conan/data/assimp/5.0.0/_/_/build/9a4d2bae52ac84e2ccb41d80f63793a0dfd0e50b/source_subfolder/code/Common/ZipArchiveIOSystem.cpp:232: undefined reference to `unzReadCurrentFile'
/usr/bin/ld: /home/wojto/.conan/data/assimp/5.0.0/_/_/build/9a4d2bae52ac84e2ccb41d80f63793a0dfd0e50b/source_subfolder/code/Common/ZipArchiveIOSystem.cpp:239: undefined reference to `unzCloseCurrentFile'
/usr/bin/ld: /home/wojto/.conan/data/assimp/5.0.0/_/_/package/9a4d2bae52ac84e2ccb41d80f63793a0dfd0e50b/lib/libassimpd.a(ZipArchiveIOSystem.cpp.o): in function `Assimp::ZipArchiveIOSystem::Implement::Implement(Assimp::IOSystem*, char const*, char const*)':
/home/wojto/.conan/data/assimp/5.0.0/_/_/build/9a4d2bae52ac84e2ccb41d80f63793a0dfd0e50b/source_subfolder/code/Common/ZipArchiveIOSystem.cpp:342: undefined reference to `unzOpen2'
/usr/bin/ld: /home/wojto/.conan/data/assimp/5.0.0/_/_/package/9a4d2bae52ac84e2ccb41d80f63793a0dfd0e50b/lib/libassimpd.a(ZipArchiveIOSystem.cpp.o): in function `Assimp::ZipArchiveIOSystem::Implement::~Implement()':
/home/wojto/.conan/data/assimp/5.0.0/_/_/build/9a4d2bae52ac84e2ccb41d80f63793a0dfd0e50b/source_subfolder/code/Common/ZipArchiveIOSystem.cpp:349: undefined reference to `unzClose'
/usr/bin/ld: /home/wojto/.conan/data/assimp/5.0.0/_/_/package/9a4d2bae52ac84e2ccb41d80f63793a0dfd0e50b/lib/libassimpd.a(ZipArchiveIOSystem.cpp.o): in function `Assimp::ZipArchiveIOSystem::Implement::MapArchive()':
/home/wojto/.conan/data/assimp/5.0.0/_/_/build/9a4d2bae52ac84e2ccb41d80f63793a0dfd0e50b/source_subfolder/code/Common/ZipArchiveIOSystem.cpp:362: undefined reference to `unzGoToFirstFile'
/usr/bin/ld: /home/wojto/.conan/data/assimp/5.0.0/_/_/build/9a4d2bae52ac84e2ccb41d80f63793a0dfd0e50b/source_subfolder/code/Common/ZipArchiveIOSystem.cpp:370: undefined reference to `unzGetCurrentFileInfo'
/usr/bin/ld: /home/wojto/.conan/data/assimp/5.0.0/_/_/build/9a4d2bae52ac84e2ccb41d80f63793a0dfd0e50b/source_subfolder/code/Common/ZipArchiveIOSystem.cpp:377: undefined reference to `unzGoToNextFile'

What might be reason for that behawior and how can i fix this or work around? I can provide more info if needed.

WBurzynski
  • 21
  • 3
  • I think you are having same issue as here: https://stackoverflow.com/questions/62004186/undefined-reference-using-external-library-with-cmake-and-conan – ymochurad Nov 29 '20 at 12:26
  • @ymochurad I think there is a different issue here, but it gave an idea. I noticed that by default assimp is built as Static library. I builded it as shared and now it links fine. Not sure if that was the reason or if i fixed it for good. – WBurzynski Nov 29 '20 at 13:12

0 Answers0