Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » added new library but still eclipse cannot find it(problem in adding a library)
added new library but still eclipse cannot find it [message #1730964] Sun, 01 May 2016 06:25 Go to next message
Oran Oran is currently offline Oran OranFriend
Messages: 3
Registered: May 2016
Junior Member
I've been trying to use libtins library in my c++ project,but I'm unable to run it.
I compiled libtins from source in /usr/local/lib. In eclipse, I added in `project >> properties >> cross G++ Compiler >> Includes` the path of the headers file of the lib.
Then in `... >> Cross G++ Linker >> Libraries` I added in the -l field
/usr/local/lib/libtins.so

and in the -L field
/usr/local/lib

Then I modified the /etc/ld.so.conf file adding /usr/local/lib and running then ldconfig as sudo to refresh the cache
but when I run it still say
     Building target: PacketSniffer
    Invoking: Cross G++ Linker
    g++ -L/usr/local/lib -o "PacketSniffer"  ./src/PacketSniffer.o   -l/usr/local/lib/libtins.so
    /usr/bin/ld: cannot find -l/usr/local/lib/libtins.so
    collect2: error: ld returned 1 exit status
    make: *** [PacketSniffer] Error 1
    makefile:45: recipe for target 'PacketSniffer' failed



Did i miss something?
Re: added new library but still eclipse cannot find it [message #1730978 is a reply to message #1730964] Sun, 01 May 2016 12:59 Go to previous messageGo to next message
David Wegener is currently offline David WegenerFriend
Messages: 1445
Registered: July 2009
Senior Member
When specifying libraries to the gcc linker, you strip off the lib
prefix and any suffix. You also have to have a file named libtin.a in
you library paths somewhere not libtin.so since gcc needs to link
against the library archive not the shared runtime. In your case you
should specify tin as the library name so the parameter to the linker
becomes -ltin. Gcc then performs the magic of manipulating the name to
look for a matching library in all of the defined library paths (default
locations plus -L arguments).
Re: added new library but still eclipse cannot find it [message #1730979 is a reply to message #1730978] Sun, 01 May 2016 13:10 Go to previous messageGo to next message
David Wegener is currently offline David WegenerFriend
Messages: 1445
Registered: July 2009
Senior Member
After checking, it appears that the .so file can be used by the linker,
so you may be able to disregard my statements about .a vs .so. Here is
a link that talks about creating/using shared libraries and specifying
how to find them at build/run time.

http://www.cprogramming.com/tutorial/shared-libraries-linux-gcc.html
Re: added new library but still eclipse cannot find it [message #1730981 is a reply to message #1730979] Sun, 01 May 2016 14:38 Go to previous messageGo to next message
Oran Oran is currently offline Oran OranFriend
Messages: 3
Registered: May 2016
Junior Member
Reading the cprogramming tutorial I've exported LD_LIBRARY_PATH var
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH

but still the same error
Re: added new library but still eclipse cannot find it [message #1730987 is a reply to message #1730981] Sun, 01 May 2016 17:56 Go to previous messageGo to next message
David Wegener is currently offline David WegenerFriend
Messages: 1445
Registered: July 2009
Senior Member
What did you change the library name to? It needs to be called tin not
/usr/local/lib/libtin.so.

LD_LIBRARY_PATH only comes into play when you try to run your
executable. It isn't used during the build.
Re: added new library but still eclipse cannot find it [message #1730988 is a reply to message #1730987] Sun, 01 May 2016 18:29 Go to previous messageGo to next message
Oran Oran is currently offline Oran OranFriend
Messages: 3
Registered: May 2016
Junior Member
Yes,thanks I solved. In the -l field had to write
tins
no
/usr/local/lib/libtin.so
Re: added new library but still eclipse cannot find it [message #1731670 is a reply to message #1730964] Mon, 09 May 2016 07:06 Go to previous message
Tommy Hulbert is currently offline Tommy HulbertFriend
Messages: 1
Registered: May 2016
Junior Member
Thanks David Wegener, I also have this problem and bump to this post Smile


Previous Topic:No project are found to import
Next Topic:C compiler does not recognize // in line comments
Goto Forum:
  


Current Time: Tue Mar 19 06:27:17 GMT 2024

Powered by FUDForum. Page generated in 0.01976 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top