Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Compiling issue undefined reference to symbol 'clock_gettime@@GLIBC_2.2'

  1. #1
    Join Date
    Jun 2011
    Beans
    36

    Compiling issue undefined reference to symbol 'clock_gettime@@GLIBC_2.2'

    Hi,

    When compiling my c/c++ program in Netbeans I get this error:
    Code:
    gcc -I/usr/local/include/opencv -I/usr/local/include -pthread -I/usr/include/libxml2 -I/usr/include/glibmm-2.4 -I/usr/lib/i386-linux-gnu/glibmm-2.4/include -I/usr/include/sigc++-2.0 -I/usr/lib/i386-linux-gnu/sigc++-2.0/include -I/usr/include/glib-2.0 -I/usr/lib/i386-linux-gnu/glib-2.0/include -I/usr/include/libxml++-2.6 -I/usr/lib/libxml++-2.6/include -lxml++-2.6 -lxml2 -lglibmm-2.4 -lgobject-2.0 -lsigc-2.0 -lglib-2.0 -fpermissive    -L/usr/local/lib -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_ml -lopencv_video -lopencv_features2d -lopencv_calib3d -lopencv_objdetect -lopencv_contrib -lopencv_legacy -lopencv_flann -ldecodeqr -L/usr/local/lib/ -lcurl -pthread -lxml++-2.6 -lxml2 -lglibmm-2.4 -lgobject-2.0 -lsigc-2.0 -lgthread-2.0 -lrt -lglib-2.0 -o dist/Debug/GNU-Linux-x86/trunk build/Debug/GNU-Linux-x86/cardObject.o build/Debug/GNU-Linux-x86/visualisation.o build/Debug/GNU-Linux-x86/monitoring.o build/Debug/GNU-Linux-x86/main.o build/Debug/GNU-Linux-x86/player.o build/Debug/GNU-Linux-x86/detectBiddings.o build/Debug/GNU-Linux-x86/gameStatsObject.o build/Debug/GNU-Linux-x86/cardOCR.o build/Debug/GNU-Linux-x86/cardModifications.o build/Debug/GNU-Linux-x86/geometry.o build/Debug/GNU-Linux-x86/boardNumber.o build/Debug/GNU-Linux-x86/cardSuit.o build/Debug/GNU-Linux-x86/bidObject.o build/Debug/GNU-Linux-x86/dummyCorner.o build/Debug/GNU-Linux-x86/trayCorner.o build/Debug/GNU-Linux-x86/logicConnection.o build/Debug/GNU-Linux-x86/bidSuit.o build/Debug/GNU-Linux-x86/bmCommunication.o build/Debug/GNU-Linux-x86/imageProcessing.o build/Debug/GNU-Linux-x86/bidOCR.o -lopencv_core -lopencv_highgui -lopencv_imgproc -lopencv_video -lclsocket -ldecodeqr 
    /usr/bin/ld: build/Debug/GNU-Linux-x86/imageProcessing.o: undefined reference to symbol 'clock_gettime@@GLIBC_2.2'
    /usr/bin/ld: note: 'clock_gettime@@GLIBC_2.2' is defined in DSO /usr/lib/gcc/i686-linux-gnu/4.6/../../../i386-linux-gnu/librt.so so try adding it to the linker command line
    /usr/lib/gcc/i686-linux-gnu/4.6/../../../i386-linux-gnu/librt.so: could not read symbols: Invalid operation
    collect2: ld returned 1 exit status
    make[2]: *** [dist/Debug/GNU-Linux-x86/trunk] Error 1
    make[2]: Leaving directory `/home/user/NetBeansProjects/bcr/trunk'
    make[1]: *** [.build-conf] Error 2
    make[1]: Leaving directory `/home/user/NetBeansProjects/bcr/trunk'
    make: *** [.build-impl] Error 2
    I'm on Ubuntu 12.04. I have the same code running on Ubuntu 10.10 without any compiling problems. I assume there is a library linking problem, but I do not have a clue how to solve this.

    Thank you
    Last edited by nevixa; May 24th, 2012 at 03:27 PM.

  2. #2
    Join Date
    Dec 2011
    Location
    The Netherlands
    Beans
    1,087
    Distro
    Ubuntu 11.10 Oneiric Ocelot

    Re: Compiling issue undefined reference to symbol 'clock_gettime@@GLIBC_2.2'

    Move your sourcefiles to the begin of the command and put -lrt after the source files.

    G++ can be a little picky about the order (i know why, but i don't feel like explaining it)
    "Everything that has a beginning, has an end." --an unexpectedly wise wallpaper

  3. #3
    Join Date
    Jun 2011
    Beans
    36

    Re: Compiling issue undefined reference to symbol 'clock_gettime@@GLIBC_2.2'

    Thank you roelforg. I made a mess of the included libraries, so I start with cleaning that up.

  4. #4
    Join Date
    Dec 2011
    Location
    The Netherlands
    Beans
    1,087
    Distro
    Ubuntu 11.10 Oneiric Ocelot

    Re: Compiling issue undefined reference to symbol 'clock_gettime@@GLIBC_2.2'

    Quote Originally Posted by nevixa View Post
    Thank you roelforg. I made a mess of the included libraries, so I start with cleaning that up.
    If you don't mind the longer compile times, order like this:
    Code:
    -Wl,--start-group <source files and libraries go here, order not important> -Wl,--end-group
    This'll cause the linker to keep researching the list until all references are resolved.
    "Everything that has a beginning, has an end." --an unexpectedly wise wallpaper

  5. #5
    Join Date
    Jun 2011
    Beans
    36

    Re: Compiling issue undefined reference to symbol 'clock_gettime@@GLIBC_2.2'

    Good tip, thanx.

  6. #6
    Join Date
    Jun 2011
    Beans
    36

    Re: Compiling issue undefined reference to symbol 'clock_gettime@@GLIBC_2.2'

    I cleaned out my code and tried to clean out my includes. I'm trying to add libxml++-2.6 (version 2.35.2?) to my Netbeans program.

    My includes before adding libxml++-2.6:
    Code:
    -Wl,--start-group -I/usr/local/include/opencv -I/usr/local/include -pthread -Wl,--end-group -fpermissive
    Compiles perfectly.
    I added the output of pkg-config libxml++-2.6 --cflags --libsto my addition compiler options. Giving me:

    Code:
    gcc -Wl,--start-group -L/usr/local/lib -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_ml -lopencv_video -lopencv_features2d -lopencv_calib3d -lopencv_objdetect -lopencv_contrib -lopencv_legacy -lopencv_flann -pthread -I/usr/local/include/libxml++-2.6 -I/usr/local/lib/libxml++-2.6/include -I/usr/include/libxml2 -I/usr/include/glibmm-2.4 -I/usr/lib/i386-linux-gnu/glibmm-2.4/include -I/usr/include/sigc++-2.0 -I/usr/lib/i386-linux-gnu/sigc++-2.0/include -I/usr/include/glib-2.0 -I/usr/lib/i386-linux-gnu/glib-2.0/include -L/usr/local/lib -lxml++-2.6 -lxml2 -lglibmm-2.4 -lgobject-2.0 -lsigc-2.0 -lglib-2.0 -Wl,--end-group -o dist/Debug/GNU-Linux-x86/trunk build/Debug/GNU-Linux-x86/cardObject.o build/Debug/GNU-Linux-x86/visualisation.o build/Debug/GNU-Linux-x86/monitoring.o build/Debug/GNU-Linux-x86/main.o build/Debug/GNU-Linux-x86/player.o build/Debug/GNU-Linux-x86/detectBiddings.o build/Debug/GNU-Linux-x86/gameStatsObject.o build/Debug/GNU-Linux-x86/cardOCR.o build/Debug/GNU-Linux-x86/cardModifications.o build/Debug/GNU-Linux-x86/geometry.o build/Debug/GNU-Linux-x86/boardNumber.o build/Debug/GNU-Linux-x86/cardSuit.o build/Debug/GNU-Linux-x86/bidObject.o build/Debug/GNU-Linux-x86/dummyCorner.o build/Debug/GNU-Linux-x86/trayCorner.o build/Debug/GNU-Linux-x86/logicConnection.o build/Debug/GNU-Linux-x86/bidSuit.o build/Debug/GNU-Linux-x86/bmCommunication.o build/Debug/GNU-Linux-x86/imageProcessing.o build/Debug/GNU-Linux-x86/bidOCR.o -lclsocket -lopencv_core -lopencv_highgui -lopencv_imgproc -lopencv_legacy -lopencv_ml -lopencv_video -lcurl -lxml++-2.6 
    /usr/bin/ld: build/Debug/GNU-Linux-x86/logicConnection.o: undefined reference to symbol 'Glib::ustring::compare(char const*) const'
    /usr/bin/ld: note: 'Glib::ustring::compare(char const*) const' is defined in DSO /usr/lib/gcc/i686-linux-gnu/4.6/../../../i386-linux-gnu/libglibmm-2.4.so so try adding it to the linker command line
    /usr/lib/gcc/i686-linux-gnu/4.6/../../../i386-linux-gnu/libglibmm-2.4.so: could not read symbols: Invalid operation
    collect2: ld returned 1 exit status
    make[2]: *** [dist/Debug/GNU-Linux-x86/trunk] Error 1
    make[2]: Leaving directory `/home/user/NetBeansProjects/bcr/trunk'
    make[1]: *** [.build-conf] Error 2
    make[1]: Leaving directory `/home/user/NetBeansProjects/bcr/trunk'
    make: *** [.build-impl] Error 2
    Any ideas what I'm doing wrong?

  7. #7
    Join Date
    Dec 2011
    Location
    The Netherlands
    Beans
    1,087
    Distro
    Ubuntu 11.10 Oneiric Ocelot

    Re: Compiling issue undefined reference to symbol 'clock_gettime@@GLIBC_2.2'

    Quote Originally Posted by nevixa View Post
    I cleaned out my code and tried to clean out my includes. I'm trying to add libxml++-2.6 (version 2.35.2?) to my Netbeans program.

    My includes before adding libxml++-2.6:
    Code:
    -Wl,--start-group -I/usr/local/include/opencv -I/usr/local/include -pthread -Wl,--end-group -fpermissive
    Compiles perfectly.
    I added the output of pkg-config libxml++-2.6 --cflags --libsto my addition compiler options. Giving me:

    Code:
    gcc -Wl,--start-group -L/usr/local/lib -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_ml -lopencv_video -lopencv_features2d -lopencv_calib3d -lopencv_objdetect -lopencv_contrib -lopencv_legacy -lopencv_flann -pthread -I/usr/local/include/libxml++-2.6 -I/usr/local/lib/libxml++-2.6/include -I/usr/include/libxml2 -I/usr/include/glibmm-2.4 -I/usr/lib/i386-linux-gnu/glibmm-2.4/include -I/usr/include/sigc++-2.0 -I/usr/lib/i386-linux-gnu/sigc++-2.0/include -I/usr/include/glib-2.0 -I/usr/lib/i386-linux-gnu/glib-2.0/include -L/usr/local/lib -lxml++-2.6 -lxml2 -lglibmm-2.4 -lgobject-2.0 -lsigc-2.0 -lglib-2.0 -Wl,--end-group -o dist/Debug/GNU-Linux-x86/trunk build/Debug/GNU-Linux-x86/cardObject.o build/Debug/GNU-Linux-x86/visualisation.o build/Debug/GNU-Linux-x86/monitoring.o build/Debug/GNU-Linux-x86/main.o build/Debug/GNU-Linux-x86/player.o build/Debug/GNU-Linux-x86/detectBiddings.o build/Debug/GNU-Linux-x86/gameStatsObject.o build/Debug/GNU-Linux-x86/cardOCR.o build/Debug/GNU-Linux-x86/cardModifications.o build/Debug/GNU-Linux-x86/geometry.o build/Debug/GNU-Linux-x86/boardNumber.o build/Debug/GNU-Linux-x86/cardSuit.o build/Debug/GNU-Linux-x86/bidObject.o build/Debug/GNU-Linux-x86/dummyCorner.o build/Debug/GNU-Linux-x86/trayCorner.o build/Debug/GNU-Linux-x86/logicConnection.o build/Debug/GNU-Linux-x86/bidSuit.o build/Debug/GNU-Linux-x86/bmCommunication.o build/Debug/GNU-Linux-x86/imageProcessing.o build/Debug/GNU-Linux-x86/bidOCR.o -lclsocket -lopencv_core -lopencv_highgui -lopencv_imgproc -lopencv_legacy -lopencv_ml -lopencv_video -lcurl -lxml++-2.6 
    /usr/bin/ld: build/Debug/GNU-Linux-x86/logicConnection.o: undefined reference to symbol 'Glib::ustring::compare(char const*) const'
    /usr/bin/ld: note: 'Glib::ustring::compare(char const*) const' is defined in DSO /usr/lib/gcc/i686-linux-gnu/4.6/../../../i386-linux-gnu/libglibmm-2.4.so so try adding it to the linker command line
    /usr/lib/gcc/i686-linux-gnu/4.6/../../../i386-linux-gnu/libglibmm-2.4.so: could not read symbols: Invalid operation
    collect2: ld returned 1 exit status
    make[2]: *** [dist/Debug/GNU-Linux-x86/trunk] Error 1
    make[2]: Leaving directory `/home/user/NetBeansProjects/bcr/trunk'
    make[1]: *** [.build-conf] Error 2
    make[1]: Leaving directory `/home/user/NetBeansProjects/bcr/trunk'
    make: *** [.build-impl] Error 2
    Any ideas what I'm doing wrong?
    It's not the includes that you need to put in the -Wl,--start-group -Wl,--end-group
    This command line is how you should've done it:
    Code:
    gcc -L/usr/local/lib -I/usr/local/include/libxml++-2.6 -I/usr/local/lib/libxml++-2.6/include  -I/usr/include/libxml2 -I/usr/include/glibmm-2.4  -I/usr/lib/i386-linux-gnu/glibmm-2.4/include -I/usr/include/sigc++-2.0  -I/usr/lib/i386-linux-gnu/sigc++-2.0/include -I/usr/include/glib-2.0  -I/usr/lib/i386-linux-gnu/glib-2.0/include -L/usr/local/lib  -Wl,--start-group -lopencv_core  -lopencv_imgproc -lopencv_highgui -lopencv_ml -lopencv_video  -lopencv_features2d -lopencv_calib3d -lopencv_objdetect -lopencv_contrib  -lopencv_legacy -lopencv_flann -pthread -lxml++-2.6  -lxml2 -lglibmm-2.4 -lgobject-2.0 -lsigc-2.0 -lglib-2.0 build/Debug/GNU-Linux-x86/cardObject.o  build/Debug/GNU-Linux-x86/visualisation.o  build/Debug/GNU-Linux-x86/monitoring.o build/Debug/GNU-Linux-x86/main.o  build/Debug/GNU-Linux-x86/player.o  build/Debug/GNU-Linux-x86/detectBiddings.o  build/Debug/GNU-Linux-x86/gameStatsObject.o  build/Debug/GNU-Linux-x86/cardOCR.o  build/Debug/GNU-Linux-x86/cardModifications.o  build/Debug/GNU-Linux-x86/geometry.o  build/Debug/GNU-Linux-x86/boardNumber.o  build/Debug/GNU-Linux-x86/cardSuit.o  build/Debug/GNU-Linux-x86/bidObject.o  build/Debug/GNU-Linux-x86/dummyCorner.o  build/Debug/GNU-Linux-x86/trayCorner.o  build/Debug/GNU-Linux-x86/logicConnection.o  build/Debug/GNU-Linux-x86/bidSuit.o  build/Debug/GNU-Linux-x86/bmCommunication.o  build/Debug/GNU-Linux-x86/imageProcessing.o  build/Debug/GNU-Linux-x86/bidOCR.o -lclsocket -lopencv_core  -lopencv_highgui -lopencv_imgproc -lopencv_legacy -lopencv_ml  -lopencv_video -lcurl -lxml++-2.6 -Wl,--end-group   -o dist/Debug/GNU-Linux-x86/trunk
    "Everything that has a beginning, has an end." --an unexpectedly wise wallpaper

  8. #8
    Join Date
    Apr 2009
    Location
    Germany
    Beans
    2,134
    Distro
    Ubuntu Development Release

    Re: Compiling issue undefined reference to symbol 'clock_gettime@@GLIBC_2.2'

    instead of messing around with groups, why not just do it right to begin with?
    just move all -l... to the end of the line.

  9. #9
    Join Date
    Dec 2011
    Location
    The Netherlands
    Beans
    1,087
    Distro
    Ubuntu 11.10 Oneiric Ocelot

    Re: Compiling issue undefined reference to symbol 'clock_gettime@@GLIBC_2.2'

    Quote Originally Posted by MadCow108 View Post
    instead of messing around with groups, why not just do it right to begin with?
    just move all -l... to the end of the line.
    It's useful when you have circular dependencies (try using sdl with several of it's helper libs and you'll see how picky it is about where the source goes (hint: it's not at the end, or beginning but somewhere in the middle of the libs), then it's very useful to have groups).
    "Everything that has a beginning, has an end." --an unexpectedly wise wallpaper

  10. #10
    Join Date
    Jun 2011
    Beans
    36

    Re: Compiling issue undefined reference to symbol 'clock_gettime@@GLIBC_2.2'

    Quote Originally Posted by roelforg View Post
    It's not the includes that you need to put in the -Wl,--start-group -Wl,--end-group
    This command line is how you should've done it:
    Code:
    gcc -L/usr/local/lib -I/usr/local/include/libxml++-2.6 -I/usr/local/lib/libxml++-2.6/include  -I/usr/include/libxml2 -I/usr/include/glibmm-2.4  -I/usr/lib/i386-linux-gnu/glibmm-2.4/include -I/usr/include/sigc++-2.0  -I/usr/lib/i386-linux-gnu/sigc++-2.0/include -I/usr/include/glib-2.0  -I/usr/lib/i386-linux-gnu/glib-2.0/include -L/usr/local/lib  -Wl,--start-group -lopencv_core  -lopencv_imgproc -lopencv_highgui -lopencv_ml -lopencv_video  -lopencv_features2d -lopencv_calib3d -lopencv_objdetect -lopencv_contrib  -lopencv_legacy -lopencv_flann -pthread -lxml++-2.6  -lxml2 -lglibmm-2.4 -lgobject-2.0 -lsigc-2.0 -lglib-2.0 build/Debug/GNU-Linux-x86/cardObject.o  build/Debug/GNU-Linux-x86/visualisation.o  build/Debug/GNU-Linux-x86/monitoring.o build/Debug/GNU-Linux-x86/main.o  build/Debug/GNU-Linux-x86/player.o  build/Debug/GNU-Linux-x86/detectBiddings.o  build/Debug/GNU-Linux-x86/gameStatsObject.o  build/Debug/GNU-Linux-x86/cardOCR.o  build/Debug/GNU-Linux-x86/cardModifications.o  build/Debug/GNU-Linux-x86/geometry.o  build/Debug/GNU-Linux-x86/boardNumber.o  build/Debug/GNU-Linux-x86/cardSuit.o  build/Debug/GNU-Linux-x86/bidObject.o  build/Debug/GNU-Linux-x86/dummyCorner.o  build/Debug/GNU-Linux-x86/trayCorner.o  build/Debug/GNU-Linux-x86/logicConnection.o  build/Debug/GNU-Linux-x86/bidSuit.o  build/Debug/GNU-Linux-x86/bmCommunication.o  build/Debug/GNU-Linux-x86/imageProcessing.o  build/Debug/GNU-Linux-x86/bidOCR.o -lclsocket -lopencv_core  -lopencv_highgui -lopencv_imgproc -lopencv_legacy -lopencv_ml  -lopencv_video -lcurl -lxml++-2.6 -Wl,--end-group   -o dist/Debug/GNU-Linux-x86/trunk
    When I compile in terminal with the command line above I still get the Glib::ustring compile error:
    Code:
    /usr/bin/ld: build/Debug/GNU-Linux-x86/logicConnection.o: undefined reference to symbol 'Glib::ustring::compare(char const*) const'
    /usr/bin/ld: note: 'Glib::ustring::compare(char const*) const' is defined in DSO /usr/lib/gcc/i686-linux-gnu/4.6/../../../i386-linux-gnu/libglibmm-2.4.so so try adding it to the linker command line
    /usr/lib/gcc/i686-linux-gnu/4.6/../../../i386-linux-gnu/libglibmm-2.4.so: could not read symbols: Invalid operation
    collect2: ld returned 1 exit status
    @MadCow108 thank you for your reaction. Do you mean like this:
    Code:
    gcc -L/usr/local/lib -I/usr/local/include/libxml++-2.6 -I/usr/local/lib/libxml++-2.6/include  -I/usr/include/libxml2 -I/usr/include/glibmm-2.4  -I/usr/lib/i386-linux-gnu/glibmm-2.4/include -I/usr/include/sigc++-2.0  -I/usr/lib/i386-linux-gnu/sigc++-2.0/include -I/usr/include/glib-2.0  -I/usr/lib/i386-linux-gnu/glib-2.0/include -L/usr/local/lib   build/Debug/GNU-Linux-x86/cardObject.o  build/Debug/GNU-Linux-x86/visualisation.o  build/Debug/GNU-Linux-x86/monitoring.o build/Debug/GNU-Linux-x86/main.o  build/Debug/GNU-Linux-x86/player.o  build/Debug/GNU-Linux-x86/detectBiddings.o  build/Debug/GNU-Linux-x86/gameStatsObject.o  build/Debug/GNU-Linux-x86/cardOCR.o  build/Debug/GNU-Linux-x86/cardModifications.o  build/Debug/GNU-Linux-x86/geometry.o  build/Debug/GNU-Linux-x86/boardNumber.o  build/Debug/GNU-Linux-x86/cardSuit.o  build/Debug/GNU-Linux-x86/bidObject.o  build/Debug/GNU-Linux-x86/dummyCorner.o  build/Debug/GNU-Linux-x86/trayCorner.o  build/Debug/GNU-Linux-x86/logicConnection.o  build/Debug/GNU-Linux-x86/bidSuit.o  build/Debug/GNU-Linux-x86/bmCommunication.o  build/Debug/GNU-Linux-x86/imageProcessing.o  build/Debug/GNU-Linux-x86/bidOCR.o -lclsocket -lopencv_core  -lopencv_highgui -lopencv_imgproc -lopencv_legacy -lopencv_ml  -lopencv_video -lcurl -lxml++-2.6 -pthread -lxml++-2.6  -lxml2 -lglibmm-2.4 -lgobject-2.0 -lsigc-2.0 -lglib-2.0  -o dist/Debug/GNU-Linux-x86/trunk
    That seems actually to compile without errors! Now I am going to figure out how to get this compiled within netbeans. Thanks again!

Page 1 of 2 12 LastLast

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •