Results 1 to 5 of 5

Thread: undefined reference to "gnome_rr_screen_refresh(GnomeRRScreen*, _GError**)'

  1. #1
    Join Date
    Dec 2013
    Beans
    2

    undefined reference to "gnome_rr_screen_refresh(GnomeRRScreen*, _GError**)'

    Hi,

    I am trying to write a small application in C++ using C::B, the code seems to compile successfully but something goes wrong in the linking stage and i can't figure out what.

    Code:
    #include <iostream>
    #define GNOME_DESKTOP_USE_UNSTABLE_API
    #include <gnome-desktop-3.0/libgnome-desktop/gnome-rr-config.h>
    using namespace std;
    
    
    int main()
    {
        GnomeRRConfig *myconfig;
        GnomeRRScreen* myscreen;
        GError*        myerror;
    
    
       gboolean result = gnome_rr_screen_refresh(myscreen,NULL);
    
    
    
    
    
    
        return 0;
    }
    Code:
    Build started on: 16-12-2013 at 05:17.16
    Build ended on: 16-12-2013 at 05:17.16-------------- Build: Debug in Test (compiler: GNU GCC Compiler)---------------
    g++ -Wall -fexceptions -g -Iinclude -I/usr/include/glib-2.0/ -I/usr/include/gnome-desktop-3.0/ -I/usr/include/gtk-2.0 -I/usr/include/cairo/ -I/usr/include/pango-1.0/ -I/usr/lib/x86_64-linux-gnu/gtk-2.0/include/ -I/usr/include/gdk-pixbuf-2.0/ -c /home/damir/Documents/Programming/Test/main.cpp -o obj/Debug/main.o
    /home/damir/Documents/Programming/Test/main.cpp: In function ‘int main()’:
    /home/damir/Documents/Programming/Test/main.cpp:8:20: warning: unused variable ‘myconfig’ [-Wunused-variable]
    GnomeRRConfig *myconfig;
    ^
    /home/damir/Documents/Programming/Test/main.cpp:10:20: warning: unused variable ‘myerror’ [-Wunused-variable]
    GError* myerror;
    ^
    /home/damir/Documents/Programming/Test/main.cpp:12:13: warning: unused variable ‘result’ [-Wunused-variable]
    gboolean result = gnome_rr_screen_refresh(myscreen,NULL);
    ^
    /home/damir/Documents/Programming/Test/main.cpp:12:59: warning: ‘myscreen’ is used uninitialized in this function [-Wuninitialized]
    gboolean result = gnome_rr_screen_refresh(myscreen,NULL);
    ^
    g++ -L/usr/lib/x86_64-linux-gnu/glib-2.0/include/ -L/usr/lib -L/usr/lib -o bin/Debug/Test obj/Debug/main.o /usr/lib/x86_64-linux-gnu/libglib-2.0.so /usr/lib/x86_64-linux-gnu/control-center-1/panels/libdisplay.so /usr/lib/libgnome-desktop-3.so /usr/lib/x86_64-linux-gnu/libglib-2.0.so /usr/lib/libgnome-desktop-3.so
    obj/Debug/main.o: In function "main':
    /home/damir/Documents/Programming/Test/main.cpp:12: undefined reference to "gnome_rr_screen_refresh(GnomeRRScreen*, _GError**)'
    collect2: error: ld returned 1 exit status
    Process terminated with status 1 (0 minute(s), 0 second(s))
    1 error(s), 4 warning(s) (0 minute(s), 0 second(s))
    By the looks of it, libgnome-desktop-3.so which contains "000000000001aa30 T gnome_rr_screen_refresh" is being linked with main.o.

    Any suggestions on how to resolve this problem are greatly appreciated.

  2. #2
    Join Date
    Nov 2005
    Location
    Bordeaux, France
    Beans
    11,297
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: undefined reference to "gnome_rr_screen_refresh(GnomeRRScreen*, _GError**)'

    Libraries are normally linked with the -l flag, not by typing their full filename.
    「明後日の夕方には帰ってるからね。」


  3. #3
    Join Date
    Dec 2013
    Beans
    2

    Re: undefined reference to "gnome_rr_screen_refresh(GnomeRRScreen*, _GError**)'

    I tried linking with
    g++ -L/usr/lib/x86_64-linux-gnu/glib-2.0/include/ -L/usr/lib -L/usr/lib -o bin/Debug/Test obj/Debug/main.o -lgnome-desktop-3
    and I still get the same error. It seems like the linker finds the library but can't find the method inside it?

  4. #4
    Join Date
    Aug 2010
    Location
    Lancs, United Kingdom
    Beans
    1,084
    Distro
    Xubuntu 14.04 Trusty Tahr

    Re: undefined reference to "gnome_rr_screen_refresh(GnomeRRScreen*, _GError**)'

    I apologise in advance if these observations are incorrect or unhelpful, but I don't have time to check at the moment, and there is a chance that they might help.
    By the looks of it, libgnome-desktop-3.so which contains "000000000001aa30 T gnome_rr_screen_refresh" is being linked with main.o.
    That looks like a C function to me.
    /home/damir/Documents/Programming/Test/main.cpp:12: undefined reference to "gnome_rr_screen_refresh(GnomeRRScreen*, _GError**)'
    That looks like a C++ function, i.e. the argument types are part of the linkage. If you run nm on main.o you might be able to confirm this. If that's the case then it suggests that you are missing an "extern C" when the function is declared... but if you are including the proper headers, I don't know why that would happen.

    Another thing that surprises me, but probably has nothing to do with your problem is this.
    -I/usr/include/gtk-2.0
    Now I thought Gnome3 used gtk3, so why gtk-2.0?

  5. #5
    Join Date
    Dec 2013
    Beans
    1

    Re: undefined reference to "gnome_rr_screen_refresh(GnomeRRScreen*, _GError**)'

    Quote Originally Posted by holovati View Post
    Any suggestions on how to resolve this problem are greatly appreciated.
    Include the header file gnome-rr.h

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
  •