[CMake] adding a link directory

Alexander Neundorf a.neundorf-work at gmx.net
Sun May 8 11:39:40 EDT 2011


On Sunday 08 May 2011, Liam Kurmos wrote:
> thanks Rolf, but no joy.
> 
> i must have done something else wrong. Is there a way to make cmake
> output the link command?

make VERBOSE=1

 
> i get undefined link errors (as below). when i made a simple test of
> linking these with a gcc command everything worked using the
> -L/absPath/
> 
> libtourtre definitely provides the undefined functions.
> 
> errors:
> 
> CMakeFiles/testOVAS.dir/Volume4D.cpp.o: In function
> `Volume4D::testContourTree()':
> Volume4D.cpp:(.text+0xad5): undefined reference to `ct_init(unsigned
> long, unsigned long*, double (*)(unsigned long, void*), unsigned long
> (*)(unsigned long, unsigned long*, void*), void*)'
> Volume4D.cpp:(.text+0xaeb): undefined reference to
> `ct_sweepAndMerge(ctContext*)'
> Volume4D.cpp:(.text+0xafa): undefined reference to
> `ct_decompose(ctContext*)' Volume4D.cpp:(.text+0xb10): undefined reference
> to `ct_branchMap(ctContext*)' Volume4D.cpp:(.text+0xb26): undefined
> reference to `ct_cleanup(ctContext*)' collect2: ld returned 1 exit status
> make[2]: *** [testOVAS] Error 1
> make[1]: *** [CMakeFiles/testOVAS.dir/all] Error 2
> make: *** [all] Error 2
> 
> 
> my cmake file looks like this:
> 
> PROJECT (OVAS)
> cmake_minimum_required(VERSION 2.6)
> 
> FIND_PACKAGE(VXL)
> 
> 
> FIND_PACKAGE(VTK REQUIRED)
> IF(NOT VTK_USE_RENDERING)
>   MESSAGE(FATAL_ERROR "Example ${PROJECT_NAME} requires
> VTK_USE_RENDERING.") ENDIF(NOT VTK_USE_RENDERING)
> INCLUDE(${VTK_USE_FILE})
> 
> 
> include_directories (${VAS_SOURCE_DIR} "/usr/local/include/vxl/core/"
> "/usr/local/include/vxl/vcl/"
> "/home/zoizoi/psyforge/woven/libtourtre_v15/libtourtre/include")
> 
> 
> ADD_EXECUTABLE(testOVAS testOVAS.cpp Analyser4D.cpp
> abstractFeature.cpp  Feature.cpp ImplicitVolume4D.cpp
> Analyser3D.cpp GeoPoint.cpp StepToParamConverter.cpp
>        GeoSequence.cpp GeoSphere.cpp    Volume4D.cpp MetaballsVol4D
> FeatureWeights.cpp ViewEvaluator.cpp testVol4D.cpp OVASControl.cpp
> FrameBuffer.cpp TemporalChangeFeature.cpp arraytools.h AreaFeature.cpp
> InfoSheet.cpp InfoData.cpp FlyingSaucersVol4D.cpp PathVisualiser.cpp
> TemporalChangeFeature2.cpp MovingAAElipsoid.cpp Data.cpp Mesh.cpp
> )
> 
> 
> FIND_LIBRARY(TOURTRE_LIBRARY tourtre
> /home/zoizoi/psyforge/woven/libtourtre_v15/libtourtre)
> TARGET_LINK_LIBRARIES(testOVAS vtkWidgets vtkRendering vtkHybrid vnl
> libtourtre.so ${TOURTRE_LIBRARY})

Ok, this is not the good way to do it.

I would suggest you add some debug output:
message(STATUS TOURTRE_LIBRARY ${TOURTRE_LIBRARY} )

so you see what has been found.

Also, the find_library()-call should look something like this:
FIND_LIBRARY(TOURTRE_LIBRARY tourtre)

and then you can set the environment variable CMAKE_PREFIX_PATH to the install 
location of the tourtre library.
Did you actually install the tourtre library ? It doesn't look like it.
Simply do a "make install" and it will install it.
If you don't have root permissions, set CMAKE_INSTALL_PREFIX e.g. to 
<your_home>/install/, then it will be installed there, and CMAKE_PREFIX_PATH 
would have to be <your_home>/install/.

Also for the vxl/ stuff you should not use hardcoded paths, but you should 
also use find_path() etc. to detect these files and directories.

Alex


More information about the CMake mailing list