Hello,

I am running a project that uses several libs which seemingly rely on
pthread. In my CMake files, I don't explicitely refer to pthread
(especially as it is a different story under different OS's like
Windows). Instead I use the find_package logic, e.g.:

find_package(Boost ${VOLE_MINIMUM_BOOST_VERSION} COMPONENTS thread)

then use "${Boost_INCLUDE_DIR}/include/;${Boost_INCLUDE_DIR}",
${Boost_THREAD_LIBRARY} appropriately.

On the GNU/Linux systems I tested, I get a linker output like this:

/usr/bin/g++    -Wall -Wno-long-long -Wno-reorder -pedantic  -O3
-DNDEBUG    CMakeFiles/qgerbil.dir/main.cpp.o
CMakeFiles/qgerbil.dir/qrc_gerbil.cxx.o  -o ../../bin/qgerbil -rdynamic
../core/libcore-lib.a libgerbil_gui-lib.a -lQtOpenGL -lGLU -lGL -lSM
-lICE -lX11 -lXext ../rgb/librgb-lib.a ../../librgb-optional-lib.a
../seg_graphs/libseg_graphs-lib.a ../csparse/libcsparse-lib.a
../../libseg_graphs-optional-lib.a ../../libgerbil_gui-optional-lib.a
../seg_meanshift/libseg_meanshift-lib.a ../lsh/liblsh-lib.a
../../libseg_meanshift-optional-lib.a
../seg_felzenszwalb/libseg_felzenszwalb-lib.a
../edge_detect/libedge_detect-lib.a ../som/libsom-lib.a
../imginput/libimginput-lib.a -lgdal
../similarity_measures/libsimilarity_measures-lib.a
../core/libcore-lib.a -ltbb -lboost_system -lboost_filesystem -lQtCore
-lQtGui -lboost_thread -lboost_date_time -lboost_chrono
/usr/lib/libopencv_videostab.so.2.4.9 /usr/lib/libopencv_ts.a -ldl -lm
-lpthread -lrt -lGLU -lGL -lSM -lICE -lX11 -lXext -ltbb
/usr/lib/libopencv_superres.so.2.4.9
/usr/lib/libopencv_stitching.so.2.4.9
/usr/lib/libopencv_contrib.so.2.4.9 /usr/lib/libopencv_nonfree.so.2.4.9
/usr/lib/libopencv_ocl.so.2.4.9 /usr/lib/libopencv_gpu.so.2.4.9
/usr/lib/libopencv_photo.so.2.4.9 /usr/lib/libopencv_objdetect.so.2.4.9
/usr/lib/libopencv_legacy.so.2.4.9 /usr/lib/libopencv_video.so.2.4.9
/usr/lib/libopencv_ml.so.2.4.9 /usr/lib/libopencv_calib3d.so.2.4.9
/usr/lib/libopencv_features2d.so.2.4.9
/usr/lib/libopencv_highgui.so.2.4.9 /usr/lib/libopencv_imgproc.so.2.4.9
/usr/lib/libopencv_flann.so.2.4.9 /usr/lib/libopencv_core.so.2.4.9
-lboost_program_options

Now a user wrote me that he gets this output:

/usr/bin/c++    -Wall -Wno-long-long -Wno-reorder -pedantic  -O3
-DNDEBUG    CMakeFiles/qgerbil.dir/main.cpp.o
CMakeFiles/qgerbil.dir/qrc_gerbil.cxx.o  -o ../../bin/qgerbil -rdynamic
../core/libcore-lib.a libgerbil_gui-lib.a /usr/lib64/qt4/libQtOpenGL.so
-lGLU -lGL -lSM -lICE -lX11 -lXext ../rgb/librgb-lib.a
../../librgb-optional-lib.a ../seg_graphs/libseg_graphs-lib.a
../csparse/libcsparse-lib.a ../../libseg_graphs-optional-lib.a
../../libgerbil_gui-optional-lib.a
../seg_meanshift/libseg_meanshift-lib.a ../lsh/liblsh-lib.a
../../libseg_meanshift-optional-lib.a
../seg_felzenszwalb/libseg_felzenszwalb-lib.a
../edge_detect/libedge_detect-lib.a ../som/libsom-lib.a
../imginput/libimginput-lib.a -lgdal
../similarity_measures/libsimilarity_measures-lib.a
../core/libcore-lib.a -ltbb -lboost_system-mt -lboost_filesystem-mt
/usr/lib64/qt4/libQtCore.so /usr/lib64/qt4/libQtGui.so -lboost_thread-mt
-lboost_date_time-mt -lboost_chrono-mt -lopencv_calib3d -lopencv_contrib
-lopencv_core -lopencv_features2d -lopencv_flann -lopencv_gpu
-lopencv_highgui -lopencv_imgproc -lopencv_legacy -lopencv_ml
-lopencv_nonfree -lopencv_objdetect -lopencv_photo -lopencv_stitching
-lopencv_superres -lopencv_ts -lopencv_video -lopencv_videostab
-lboost_program_options-mt -Wl,-rpath,/usr/lib64/qt4


I see two differences:
1. -ldl -lm -lpthread -lrt are missing
2. both Qt and OpenCV libs are referenced differently (in an opposing way)


Can anybody shed light on the issue how my user might have obtained this
different behaviour? What can or should I do in my CMake files to
prevent this problem from happening. The successful workaround my user
applied is to set CFLAGS='-lpthread'. Obviously that is not a good
solution, but it shows that there are no other issues in the build (and
it seems that missing -ldl -lm -lrt doesn't matter).


Thank you for your time and your help!


Best Regards,
Johannes

p.s.: the project can be found at http://gerbilvis.org
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake

Reply via email to