2

So I've set up a CMakeLists.txt script (runs fine), which sets up my project : Problem is when I run the makefile, everything runs fine, until it prints me :

PS : I installed assimp like this (I'm on linux/ubuntu) : sudo apt-get install libassimp-dev; The library is for sure well installed; because I laready used it, in the same project using code::blocks !

Linking CXX executable Test
CMakeFiles/Test.dir/src/Mesh.cpp.o: In function `Mesh::Mesh(char const*)':
Mesh.cpp:(.text+0x1db): undefined reference to `Assimp::Importer::Importer()'
Mesh.cpp:(.text+0x1f9): undefined reference to `Assimp::Importer::ReadFile(char const*, unsigned int)'
Mesh.cpp:(.text+0x625): undefined reference to `Assimp::Importer::~Importer()'
Mesh.cpp:(.text+0x672): undefined reference to `Assimp::Importer::~Importer()'
collect2: error: ld returned 1 exit status
make[2]: *** [Test] Error 1
make[1]: *** [CMakeFiles/Test.dir/all] Error 2
make: *** [all] Error 2

Here is my CMakeLists.txt :

CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
project(Test)

set(CMAKE_CXX_FLAGS "-std=c++11")

################INCLUDE LIBRARIES###################
#specify module path
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)

#OPENGL
find_package(OpenGL REQUIRED)
if(OPENGL_FOUND)
    include_directories(${OpenGL_INCLUDE_DIRS})
endif()

#SDL2
find_package(SDL2 REQUIRED)
if(SDL2_FOUND)
    include_directories(${SDL2_INCLUDE_DIR})
endif()

#GLEW
find_package(GLEW REQUIRED)
if(GLEW_FOUND)
    include_directories(${GLEW_INCLUDE_DIR})
endif() 

#BOOST
find_package(BOOST REQUIRED)
if(BOOST_FOUND)
    include_directories(${BOOST_INCLUDE_DIR})
endif() 

#LUA
find_package(LUA REQUIRED)
if(LUA_FOUND)
    include_directories(${LUA_INCLUDE_DIR})
endif() 


#LUABIND
find_package(LUABIND REQUIRED)
if(LUABIND_FOUND)
    include_directories(${LUABIND_INCLUDE_DIR})
endif() 

#ASSIMP
find_package(ASSIMP REQUIRED)
if(ASSIMP_FOUND)
    include_directories(${ASSIMP_INCLUDE_DIR})
endif() 


include_directories(
        #include directories are here...
    )



add_executable(
    ${PROJECT_NAME}

    #I won't list cpp files, bcause there are a lot !
 )


################LINK LIBRARIES#####################

target_link_libraries(Test ${OPENGL_LIBRARY})
target_link_libraries(Test ${SDL2_LIBRARY})
target_link_libraries(Test ${GLEW_LIBRARY})
target_link_libraries(Test ${BOOST_LIBRARY})
target_link_libraries(Test ${LUA_LIBRARY})
target_link_libraries(Test ${LUABIND_LIBRARY})
target_link_libraries(Test ${CMAKE_DL_LIBS})
target_link_libraries(Test ${ASSIMP_LIBRARY})

2 Answers 2

4

I guess the right answer is more:

target_link_libraries(${PROJECT_NAME} ${ASSIMP_LIBRARIES})

LIBRARIES not LIBRARY

1
  • You are right, fixed the issue! Thanks for the hint!
    – KimKulling
    Commented Sep 5, 2018 at 6:12
0

Please try to use

target_link_libraries(${PROJECT_NAME} ${ASSIMP_LIBRARIES})

I am not sure, if the library will be linked to the right executable.

5
  • nope, still got the error ... I've got my assimp folder... how can Ispecify the include path for it ?
    – user4807452
    Commented Jul 13, 2015 at 8:57
  • Nope, still not working.... But I've got my assimp folder next to my cmake folder, how can I specify the include path to it ?
    – user4807452
    Commented Jul 13, 2015 at 8:59
  • Use INCLUDE_DIRECTORIES( <include_dir> ) to specify it.
    – KimKulling
    Commented Jul 16, 2015 at 8:34
  • ok, but I should list all the assimp headers, or is there a way to include everything in assimp ?
    – user4807452
    Commented Jul 16, 2015 at 9:39
  • Try to use the public heaers, which are in include. All pricate headers you will find in the code area. And of course only include public header which you need to use.
    – KimKulling
    Commented Jul 16, 2015 at 13:23