User forums > Using Code::Blocks

error adding symbols: DSO missing from command line

(1/3) > >>

niconol:
Hi,

obviously, a classical error.
I'm working on code::blocks, raspbian

I use -lpthread (last option) to compile my project, but i've got this error:


--- Code: ---/usr/bin/ld: obj/Debug/pict.o: référence au symbole non défini «pthread_create@@GLIBC_2.4»
//lib/arm-linux-gnueabihf/libpthread.so.0: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 16 second(s))
0 error(s), 20 warning(s) (0 minute(s), 16 second(s))
--- End code ---

this is my .cbp

--- Code: ---<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_project_file>
<FileVersion major="1" minor="6" />
<Project>
<Option title="dic_gtk_opencv_01" />
<Option pch_mode="2" />
<Option compiler="gcc" />
<Build>
<Target title="Debug">
<Option output="bin/Debug/dic_gtk_opencv_01" prefix_auto="1" extension_auto="1" />
<Option object_output="obj/Debug/" />
<Option type="1" />
<Option compiler="gcc" />
<Compiler>
<Add option="-g" />
<Add option="-rdynamic" />
</Compiler>
</Target>
<Target title="Release">
<Option output="bin/Release/dic_gtk_opencv_01" prefix_auto="1" extension_auto="1" />
<Option object_output="obj/Release/" />
<Option type="1" />
<Option compiler="gcc" />
<Compiler>
<Add option="-O2" />
</Compiler>
<Linker>
<Add option="-s" />
</Linker>
</Target>
</Build>
<Compiler>
<Add option="-std=c++11" />
<Add option="-Wall" />
<Add option="`pkg-config gtk+-3.0 --cflags`" />
<Add option="`pkg-config opencv --cflags`" />
</Compiler>
<Linker>
<Add option="`pkg-config gtk+-3.0 --libs`" />
<Add option="&apos;pkg-config opencv --libs&apos;" />
<Add option="`pkg-config --libs opencv`" />
<Add library="wiringPi" />
<Add library="udev" />
<Add library="pthread" />
</Linker>
<Unit filename="hard.cpp" />
<Unit filename="hard.h" />
<Unit filename="ihm.cpp" />
<Unit filename="ihm.h" />
<Unit filename="ihm_sig.cpp" />
<Unit filename="ihm_sig.h" />
<Unit filename="interrupt.cpp" />
<Unit filename="interrupt.h" />
<Unit filename="main.cpp" />
<Unit filename="pict.cpp" />
<Unit filename="pict.h" />
<Extensions>
<editor_config active="1" use_tabs="0" tab_indents="1" tab_width="2" indent="2" eol_mode="0" />
<code_completion />
<envvars />
<lib_finder disable_auto="1" />
<debugger />
</Extensions>
</Project>
</CodeBlocks_project_file>

--- End code ---

An idea to help me please?

Bye

BlueHazzard:
http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_(general)#Q:_How_do_I_report_a_compilation_problem_on_the_forums.3F

a build log would be more helpfull

BlueHazzard:
first match on duckduckgo:
https://stackoverflow.com/questions/1662909/undefined-reference-to-pthread-create-in-linux#1665110

this will fix your problem
You have to use the other linker settings, not the library...

niconol:
Thank you BlueHazzard,

Sorry, it was only the end of the build log, the complete is :


--- Code: ---
-------------- Clean: Debug in dic_gtk_opencv_01 (compiler: GNU GCC Compiler)---------------

Cleaned "dic_gtk_opencv_01 - Debug"

-------------- Build: Debug in dic_gtk_opencv_01 (compiler: GNU GCC Compiler)---------------

g++ -std=c++11 -Wall -pthread -I/usr/include/gtk-3.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0 -I/usr/include/dbus-1.0 -I/usr/lib/arm-linux-gnueabihf/dbus-1.0/include -I/usr/include/gtk-3.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng12 -I/usr/include/glib-2.0 -I/usr/lib/arm-linux-gnueabihf/glib-2.0/include -I/usr/include/opencv -g -rdynamic  -c /home/pi/dic2/dic_gtk_opencv_01/hard.cpp -o obj/Debug/hard.o
g++ -std=c++11 -Wall -pthread -I/usr/include/gtk-3.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0 -I/usr/include/dbus-1.0 -I/usr/lib/arm-linux-gnueabihf/dbus-1.0/include -I/usr/include/gtk-3.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng12 -I/usr/include/glib-2.0 -I/usr/lib/arm-linux-gnueabihf/glib-2.0/include -I/usr/include/opencv -g -rdynamic  -c /home/pi/dic2/dic_gtk_opencv_01/ihm.cpp -o obj/Debug/ihm.o
g++ -std=c++11 -Wall -pthread -I/usr/include/gtk-3.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0 -I/usr/include/dbus-1.0 -I/usr/lib/arm-linux-gnueabihf/dbus-1.0/include -I/usr/include/gtk-3.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng12 -I/usr/include/glib-2.0 -I/usr/lib/arm-linux-gnueabihf/glib-2.0/include -I/usr/include/opencv -g -rdynamic  -c /home/pi/dic2/dic_gtk_opencv_01/ihm_sig.cpp -o obj/Debug/ihm_sig.o
/home/pi/dic2/dic_gtk_opencv_01/ihm_sig.cpp: In function ‘void BoutonTest_Click()’:
/home/pi/dic2/dic_gtk_opencv_01/ihm_sig.cpp:12:14: warning: variable ‘view’ set but not used [-Wunused-but-set-variable]
   GtkWidget *view;
              ^
g++ -std=c++11 -Wall -pthread -I/usr/include/gtk-3.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0 -I/usr/include/dbus-1.0 -I/usr/lib/arm-linux-gnueabihf/dbus-1.0/include -I/usr/include/gtk-3.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng12 -I/usr/include/glib-2.0 -I/usr/lib/arm-linux-gnueabihf/glib-2.0/include -I/usr/include/opencv -g -rdynamic  -c /home/pi/dic2/dic_gtk_opencv_01/interrupt.cpp -o obj/Debug/interrupt.o
g++ -std=c++11 -Wall -pthread -I/usr/include/gtk-3.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0 -I/usr/include/dbus-1.0 -I/usr/lib/arm-linux-gnueabihf/dbus-1.0/include -I/usr/include/gtk-3.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng12 -I/usr/include/glib-2.0 -I/usr/lib/arm-linux-gnueabihf/glib-2.0/include -I/usr/include/opencv -g -rdynamic  -c /home/pi/dic2/dic_gtk_opencv_01/main.cpp -o obj/Debug/main.o
/home/pi/dic2/dic_gtk_opencv_01/main.cpp: In function ‘int main(int, char**)’:
/home/pi/dic2/dic_gtk_opencv_01/main.cpp:7:21: warning: passing NULL to non-pointer argument 1 of ‘int main_gtk(int, char**)’ [-Wconversion-null]
   main_gtk(NULL,NULL);
                     ^
g++ -std=c++11 -Wall -pthread -I/usr/include/gtk-3.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0 -I/usr/include/dbus-1.0 -I/usr/lib/arm-linux-gnueabihf/dbus-1.0/include -I/usr/include/gtk-3.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng12 -I/usr/include/glib-2.0 -I/usr/lib/arm-linux-gnueabihf/glib-2.0/include -I/usr/include/opencv -g -rdynamic  -c /home/pi/dic2/dic_gtk_opencv_01/pict.cpp -o obj/Debug/pict.o
/home/pi/dic2/dic_gtk_opencv_01/pict.cpp: In function ‘void myInterruptBpShot()’:
/home/pi/dic2/dic_gtk_opencv_01/pict.cpp:448:10: warning: enumeration value ‘DEMARRAGE’ not handled in switch [-Wswitch]
   switch (etatSystem){
          ^
/home/pi/dic2/dic_gtk_opencv_01/pict.cpp:448:10: warning: enumeration value ‘DEMANDE_PHOTO0’ not handled in switch [-Wswitch]
/home/pi/dic2/dic_gtk_opencv_01/pict.cpp:448:10: warning: enumeration value ‘DEMANDE_SEQ’ not handled in switch [-Wswitch]
/home/pi/dic2/dic_gtk_opencv_01/pict.cpp:448:10: warning: enumeration value ‘DEMANDE_SALVE’ not handled in switch [-Wswitch]
/home/pi/dic2/dic_gtk_opencv_01/pict.cpp:448:10: warning: enumeration value ‘FIN_SALVE’ not handled in switch [-Wswitch]
/home/pi/dic2/dic_gtk_opencv_01/pict.cpp:448:10: warning: enumeration value ‘ERROR’ not handled in switch [-Wswitch]
/home/pi/dic2/dic_gtk_opencv_01/pict.cpp:448:10: warning: enumeration value ‘ABORT_DEMANDE_SALVE’ not handled in switch [-Wswitch]
/home/pi/dic2/dic_gtk_opencv_01/pict.cpp:448:10: warning: enumeration value ‘ABORT_SALVE_EN_COURS’ not handled in switch [-Wswitch]
/home/pi/dic2/dic_gtk_opencv_01/pict.cpp: In function ‘void myInterruptOpto()’:
/home/pi/dic2/dic_gtk_opencv_01/pict.cpp:496:10: warning: enumeration value ‘DEMARRAGE’ not handled in switch [-Wswitch]
   switch (etatSystem){
          ^
/home/pi/dic2/dic_gtk_opencv_01/pict.cpp:496:10: warning: enumeration value ‘DEMANDE_PHOTO0’ not handled in switch [-Wswitch]
/home/pi/dic2/dic_gtk_opencv_01/pict.cpp:496:10: warning: enumeration value ‘DEMANDE_SEQ’ not handled in switch [-Wswitch]
/home/pi/dic2/dic_gtk_opencv_01/pict.cpp:496:10: warning: enumeration value ‘DEMANDE_SALVE’ not handled in switch [-Wswitch]
/home/pi/dic2/dic_gtk_opencv_01/pict.cpp:496:10: warning: enumeration value ‘SALVE_EN_COURS’ not handled in switch [-Wswitch]
/home/pi/dic2/dic_gtk_opencv_01/pict.cpp:496:10: warning: enumeration value ‘FIN_SALVE’ not handled in switch [-Wswitch]
/home/pi/dic2/dic_gtk_opencv_01/pict.cpp:496:10: warning: enumeration value ‘ERROR’ not handled in switch [-Wswitch]
/home/pi/dic2/dic_gtk_opencv_01/pict.cpp:496:10: warning: enumeration value ‘SLEEP’ not handled in switch [-Wswitch]
/home/pi/dic2/dic_gtk_opencv_01/pict.cpp:496:10: warning: enumeration value ‘ABORT_DEMANDE_SALVE’ not handled in switch [-Wswitch]
/home/pi/dic2/dic_gtk_opencv_01/pict.cpp:496:10: warning: enumeration value ‘ABORT_SALVE_EN_COURS’ not handled in switch [-Wswitch]
g++  -o bin/Debug/dic_gtk_opencv_01 obj/Debug/hard.o obj/Debug/ihm.o obj/Debug/ihm_sig.o obj/Debug/interrupt.o obj/Debug/main.o obj/Debug/pict.o  -lgtk-3 -lgdk-3 -lpangocairo-1.0 -lpango-1.0 -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0  'pkg-config opencv --libs' /usr/lib/arm-linux-gnueabihf/libopencv_calib3d.so -lopencv_calib3d /usr/lib/arm-linux-gnueabihf/libopencv_contrib.so -lopencv_contrib /usr/lib/arm-linux-gnueabihf/libopencv_core.so -lopencv_core /usr/lib/arm-linux-gnueabihf/libopencv_features2d.so -lopencv_features2d /usr/lib/arm-linux-gnueabihf/libopencv_flann.so -lopencv_flann /usr/lib/arm-linux-gnueabihf/libopencv_gpu.so -lopencv_gpu /usr/lib/arm-linux-gnueabihf/libopencv_highgui.so -lopencv_highgui /usr/lib/arm-linux-gnueabihf/libopencv_imgproc.so -lopencv_imgproc /usr/lib/arm-linux-gnueabihf/libopencv_legacy.so -lopencv_legacy /usr/lib/arm-linux-gnueabihf/libopencv_ml.so -lopencv_ml /usr/lib/arm-linux-gnueabihf/libopencv_objdetect.so -lopencv_objdetect /usr/lib/arm-linux-gnueabihf/libopencv_ocl.so -lopencv_ocl /usr/lib/arm-linux-gnueabihf/libopencv_photo.so -lopencv_photo /usr/lib/arm-linux-gnueabihf/libopencv_stitching.so -lopencv_stitching /usr/lib/arm-linux-gnueabihf/libopencv_superres.so -lopencv_superres /usr/lib/arm-linux-gnueabihf/libopencv_ts.so -lopencv_ts /usr/lib/arm-linux-gnueabihf/libopencv_video.so -lopencv_video /usr/lib/arm-linux-gnueabihf/libopencv_videostab.so -lopencv_videostab  -pthread  -lwiringPi -ludev -lmount
/usr/bin/ld: obj/Debug/pict.o: référence au symbole non défini «pthread_create@@GLIBC_2.4»
//lib/arm-linux-gnueabihf/libpthread.so.0: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 15 second(s))
0 error(s), 20 warning(s) (0 minute(s), 15 second(s))
 
--- End code ---

I read on this
https://stackoverflow.com/questions/1662909/undefined-reference-to-pthread-create-in-linux#1665110

For Linux the correct command is:


--- Code: ---gcc -pthread -o term term.c
--- End code ---

I put
--- Code: ----pthread
--- End code ---
in other linker option, not in library, but It doesn't work better

And because I don't understand nuance, I tried

--- Code: ---pthread
lpthread
-pthread
-lpthread
'pthread'
...

--- End code ---

Neither solves the problem, can you explain me again?

Thanks

BlueHazzard:
well sry, i probably messed this up. i have no linux machine at the moment so i can not test it.

You have to set the -pthread option in "other compiler settings", not "other linker settings"...
https://stackoverflow.com/questions/30101874/linux-setting-codeblocks-to-compile-multithreading-c-code

Navigation

[0] Message Index

[#] Next page

Go to full version