GIDForums  

Go Back   GIDForums > Computer Programming Forums > C Programming Language
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 14-Oct-2005, 12:00
svenveer svenveer is offline
New Member
 
Join Date: Oct 2005
Posts: 15
svenveer is on a distinguished road

linker problem


Hi, I'm using g++ from eclipse. I'm trying to compile the following:

CPP / C++ / C Code:
#include <glib.h>
#include <libgnomevfs/gnome-vfs-init.h>
#include <libgnome/gnome-url.h>

int main(void){
  const char* filePathStr = "file://home/sven/fotos/DSC00013.JPG";
  GError *error = NULL;
  gnome_url_show(filePathStr, &error);
}

The problem is that the linker cannot find the libraries:

Code:
Building file: ../testgnome.c Invoking: GCC C Compiler gcc -I/opt/gnome/include/glib-2.0 -I/opt/gnome/include/gnome-vfs-2.0 -I/opt/gnome/include/libgnome-2.0 -I/opt/gnome/lib/glib-2.0/include -O0 -g3 -Wall -c -fmessage-length=0 -otestgnome.o ../testgnome.c Finished building: ../testgnome.c Building target: c_gnome Invoking: GCC C Linker gcc -L/opt/gnome/lib -oc_gnome ./testgnome.o -llibgnome-2 /usr/lib/gcc-lib/i586-suse-linux/3.3.4/../../../../i586-suse-linux/bin/ld: cannot find -llibgnome-2 collect2: ld returned 1 exit status make: *** [c_gnome] Error 1 make: Target `all' not remade because of errors. Build complete for project c_gnome Building file: ../testgnome.c Invoking: GCC C Compiler gcc -I/opt/gnome/include/glib-2.0 -I/opt/gnome/include/gnome-vfs-2.0 -I/opt/gnome/include/libgnome-2.0 -I/opt/gnome/lib/glib-2.0/include -O0 -g3 -Wall -c -fmessage-length=0 -otestgnome.o ../testgnome.c Finished building: ../testgnome.c

the libgnome-2 library really exists in /opt/gnome/lib with .a .la .so .so.0 and .so.0.601.0. They are owned by root and have rx permissions for others. What am I missing here.

O, by the way, I'm using suse9.2
Last edited by LuciWiz : 15-Oct-2005 at 03:24. Reason: Please insert your C++ code between [c++] & [/c++] tags
  #2  
Old 14-Oct-2005, 13:53
monalin monalin is offline
Junior Member
 
Join Date: Sep 2005
Posts: 35
monalin is on a distinguished road

Re: linker problem


i'm no expert coder or heck i dont even pretend to know anything lol. But since nobody's posted anything i'll give my 2 cents.

I cant help you very much cause i'm not really sure what your trying to do but i know that most additional library's have to be added in the Linker Properties box.

I'm not useing the same compiler as you but for me its under Project -> 'PROJECT NAME' Properties -> Linker -> General -> Additional Library Directories

maybe that will help you find the problem. again i could be way off sorry if i am.
__________________
There are 10 kinds of people in this world. Those who speak binary and those who dont.
  #3  
Old 14-Oct-2005, 14:42
davekw7x davekw7x is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Left Coast, USA
Posts: 4,693
davekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to behold

Re: linker problem


Quote:
Originally Posted by svenveer
Hi, I'm using g++ from eclipse.

The problem is that the linker cannot find the libraries:

Building target: c_gnome
Invoking: GCC C Linker
gcc -L/opt/gnome/lib -oc_gnome ./testgnome.o -llibgnome-2
/usr/lib/gcc-lib/i586-suse-linux/3.3.4/../../../../i586-suse-linux/bin/ld: cannot find -llibgnome-2

I don't have suse or eclipse to test the results, but I'll take a wild stab at it.

I will point out that the legacy of C compiler/linkers command line usage is kind of strange.

For example, if the library name is libm.a, the command line to include this would be something like

Quote:
gcc -lm x.c

If you have a library named libiberty.a, you would use

Quote:
gcc -liberty x.c

See the pattern? So, if your library is named libgnome-2.a, your command line wouldn't have "llibgnome-2", it would have this:

Quote:
gcc ...... -lgnome-2 .....

Let us know if it makes a difference.

Note that if you are sure that the library name is OK, you can make sure that the tools get to the right directories by using "-v" in the command line for gcc. The "verbose" output of the compiler tells us where it is looking.

Regards,

Dave
Last edited by davekw7x : 14-Oct-2005 at 16:01.
  #4  
Old 17-Oct-2005, 10:14
svenveer svenveer is offline
New Member
 
Join Date: Oct 2005
Posts: 15
svenveer is on a distinguished road

Re: linker problem


Thanks Dave that did the trick. Returning to c/c++ after 8 years of java ;-)

So, as a rule, libs named libxyz are 'known' to the linker as xyz.


Sven
  #5  
Old 17-Oct-2005, 11:06
davekw7x davekw7x is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Left Coast, USA
Posts: 4,693
davekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to behold

Re: linker problem


Quote:
Originally Posted by svenveer
Thanks Dave that did the trick. Returning to c/c++ after 8 years of java ;-)

So, as a rule, libs named libxyz are 'known' to the linker as xyz.


Sven

This is in keeping with the traditional UNIX philosophy of minimizing keystrokes, especially on command lines.

You know, "cp" for copy, "rm" for remove, "mv" for move, etc., so "gcc -lm z.c" to link in libm.a

Note that while developing and testing, I usually name my programs z.c (even in Windows) instead something like "theBigTestProgramForSocketsProgramming.c", so you can see that I have bought into it.

Regards,

Dave
  #6  
Old 17-Oct-2005, 11:27
svenveer svenveer is offline
New Member
 
Join Date: Oct 2005
Posts: 15
svenveer is on a distinguished road

Re: linker problem


Quote:
Originally Posted by davekw7x
This is in keeping with the traditional UNIX philosophy of minimizing keystrokes, especially on command lines.

You know, "cp" for copy, "rm" for remove, "mv" for move, etc., so "gcc -lm z.c" to link in libm.a

I guess I've used Eclipse too much to really remember that Before that it was Borland C++ Builder. I guess I need to be reeducated

I guess however that my boss prefers "TheReallyReallyLongNameForTheApplicationHeSoldThe Client" instead of just "z"

I must say I Like the "z" though
  #7  
Old 17-Oct-2005, 13:38
davekw7x davekw7x is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Left Coast, USA
Posts: 4,693
davekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to behold

Re: linker problem


Quote:
Originally Posted by svenveer
I guess I've used Eclipse too much to really remember that Before that it was Borland C++ Builder. I guess I need to be reeducated

I guess however that my boss prefers "TheReallyReallyLongNameForTheApplicationHeSoldThe Client" instead of just "z"

I must say I Like the "z" though


That's what Makefiles are for. Enter the stuff once, then just enter make.

(Or if you are really lazy, put alias 'm=make' in your ~/.bashrc, then you only enter m.)

Regards,

Dave
 
 

Recent GIDBlogMeeting the local Iraqis by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Graphic problem in Unreal Tournament 2004 zerox Computer Software Forum - Games 10 09-Oct-2005 12:31
Runtime Problem involving "printf" in C Program supamakia C Programming Language 2 09-Oct-2005 10:09
a significant problem after installing Xp mohammad Computer Software Forum - Windows 10 09-Aug-2005 07:03
Another FX 5600 problem (but with details that might shed light on this) BobDaDuck Computer Hardware Forum 2 16-Apr-2004 07:53

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 20:43.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.