Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » eclipse can't find installed library
eclipse can't find installed library [message #1727415] Tue, 22 March 2016 21:09 Go to next message
Kevin Lutzer is currently offline Kevin LutzerFriend
Messages: 1
Registered: March 2016
Junior Member
Hello all,

I have eclipse mars installed on my ubuntu 14.04 lts machine. I am using cdt with c++ to cross compile an application for the raspberry pi. I have a library I want to use called pigpio.

I have successfully installed the library files in /usr/local/include. The only problem is that I can't get eclipse to link files in that path.

I am not entirely sure what I am doing wrong. The library I want to use is pigpio.h. In the project properties I have tried to add the directory path too Properties -> Settings -> G++ Cross Compiler -> Includes. This doesn't seem to work. What am I doing wrong? Thanks!!
Re: eclipse can't find installed library [message #1727478 is a reply to message #1727415] Wed, 23 March 2016 10:25 Go to previous messageGo to next message
David VavraFriend
Messages: 1426
Registered: October 2012
Senior Member
Telling the compiler where the header file can be found doesn't tell the linker what libraries you are using. They are really two different things.

You need to also set Properties -> Settings -> linker -> Libraries

Put the library name in the upper pane and the path to it in the lower pane. The path is really only needed if non-standard but it doesn't hurt if it is standard.

Libraries may need other libraries and they need to be added , as well.
If a library was installed as a package, you can use pkg-config to get the flags needed to compile and link.

pkg-config --cflags will get you the compiler flags which are usually just the includes
pkg-config --libs will tell you what libraries are needed and their order

As an example, here are the cflags needed for gtk+-3.0 (obviously you would use the library name you are interested in):

pkg-config --cflags gtk+-3.0
-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/lib64/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/libpng16 -I/usr/include/freetype2 -I/usr/include/libdrm -I/usr/include/libpng16 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng16 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include

Note that -pthread must be given to the compiler for this library as well as the include paths. This has to be set somehow in tool settings. You would add it to Misc. if you couldn't find a specific setting for it.

And here are the libraries
pkg-config --libs gtk+-3.0
-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

Don't give Eclipse the -I,-L and -l flags. Eclipse will add them for you.




Re: eclipse can't find installed library [message #1728372 is a reply to message #1727478] Sun, 03 April 2016 23:34 Go to previous messageGo to next message
David Liu is currently offline David LiuFriend
Messages: 4
Registered: April 2016
Junior Member
Thanks for the explanation. I have an issue much like the one from OP, so I thought it would be relevant to put it here. The details of my issue are as follows:

I'm trying to cross compile code to the Beaglebone Black that references libraries from the Starterware package offered by TI for the AM335X processor on the BBB (software-dl.ti.com/dsps/dsps_public_sw/am_bu/starterware/latest/index_FDS.html)

Now, in the includes folder of these files, I can reference files that allow me to access the gpio or use interrupts and various other functions. I've included the header files, but am not able to properly reference the library files.

In eclipse, in the top pane of the Libraries tab, I've put: " drivers", " platform", " system", " utils" (with the spaces in front, but I've also tried omitting the spaces and it still doesn't work).

In the bottom pane, I've put the paths to the .lib files. So for example, for drivers, this would be ".../AM335X_StarterWare_02_00_01_01/binary/armv7a/cht_ccs/am335x/drivers". The "drivers.lib" file is inside the "Release" folder inside the said path.
FYI, I've also tried making the path be ".../AM335X_StarterWare_02_00_01_01/binary/armv7a/cht_ccs/am335x/drivers/Release" as well, and still have issues.

The error I get is:
"/usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/../../../../arm-linux-gnueabihf/bin/ld: cannot find -l drivers"
and the same thing for all of the other libraries (platform, system, utils).

So my question is, clearly I'm doing something incorrect, so where is my error? Is the .lib file that I described what I'm actually supposed to have eclipse reference when compiling? If not, given that I have all these library functions provided by TI, how should I go about using them? I've read on other posts that the library file often has a prefix lib, which none of these files do. Can someone please give me some pointers?

Thanks!
Re: eclipse can't find installed library [message #1728588 is a reply to message #1728372] Tue, 05 April 2016 16:29 Go to previous messageGo to next message
David Liu is currently offline David LiuFriend
Messages: 4
Registered: April 2016
Junior Member
Bump, really need to get this working ASAP! Thanks!
Re: eclipse can't find installed library [message #1728590 is a reply to message #1728372] Tue, 05 April 2016 16:39 Go to previous messageGo to next message
David VavraFriend
Messages: 1426
Registered: October 2012
Senior Member
The problem may be that you are trying to use a relative path. It would have to be relative to the directory where make is running the GCC linker. Try using the full path to the libraries. If you think you must use relative paths, temporarily change the linker command to display the current working directory then calculate the necessary relative path to it from the working directory of the link.
Re: eclipse can't find installed library [message #1728620 is a reply to message #1728590] Tue, 05 April 2016 22:44 Go to previous messageGo to next message
David Liu is currently offline David LiuFriend
Messages: 4
Registered: April 2016
Junior Member
Hi David,

Thanks for the reply! Assuming that the full path to the library starts at /home, I'm actually already using the full path to my file. Is this the correct assumption?

Also, do you know whether the .lib files that I listed earlier are the correct library files that I should be trying to link?

Thanks!
Re: eclipse can't find installed library [message #1728623 is a reply to message #1728620] Wed, 06 April 2016 01:42 Go to previous messageGo to next message
David VavraFriend
Messages: 1426
Registered: October 2012
Senior Member
Quote:
The "drivers.lib" file is inside the "Release" folder


This is not a standard name. The library paths will appear as -L<path> in the link command. The library names will appear as -l<name>. The -l<name> causes the linker to search for a file named lib<name>.so if it's a dynamic library or lib<name>.a if static (https://gcc.gnu.org/onlinedocs/gcc/Link-Options.html#Link-Options). Both of these have a specific file format. If the file is one of these but just has the wrong name, you could try having it placed in the linker command as an input file by using the Other Objects pane under Miscellaneous linker settings menu. You could try it even if it's not in standard file format. Some modified versions of GCC understand things like a DLL.

I have no idea what library files you should be using. Are you really sure the libraries are contained in the directory you've given? Yes, if it starts with '/' it is a Linux absolute path. However, ".../AM335X_StarterWare_02_00_01_01/binary/armv7a/cht_ccs/am335x/drivers" which you gave earlier is not. If you are taking shortcuts to save typing here, please don't.

You could post the actual link command from the build log along with following output . There may be something obviously wrong with the command. You could also try running the linker command in a command terminal until you figure out what is really needed. Then you'll have a better handle on what needs to be given to Eclipse.


[Updated on: Wed, 06 April 2016 01:43]

Report message to a moderator

Re: eclipse can't find installed library [message #1728634 is a reply to message #1728623] Wed, 06 April 2016 06:59 Go to previous messageGo to next message
David Liu is currently offline David LiuFriend
Messages: 4
Registered: April 2016
Junior Member
Solved it. So you're right, it's not a standard name and not a library. Essentially, TI provided a bunch of files but no library. In a separate folder of these provided files, there are the equivalent folders which all have makefiles inside of them. I first had to navigate to each of these directories and use make. Afterwards, the library files (libdrivers.a, libsystem_config.a, etc...) were created one by one and I simply had to change the library directory in Eclipse to point to them. So really not difficult if I knew what I was doing, but clearly I had problems finding this solution.

Anyways, thanks for the pointers!
Re: eclipse can't find installed library [message #1781880 is a reply to message #1728634] Wed, 14 February 2018 09:27 Go to previous message
sharon  maxwell is currently offline sharon maxwellFriend
Messages: 2
Registered: January 2018
Junior Member
it shows Eclipse in C language Program can't find the opencv include files to build the new project
No, it doesn't.

> In fact Eclipse is using a MingW path I don't recall setting.
The "path" you are showing is the path to the linker. You can tell this by noting the "ld.exe" at the end of it. The message is that the linker cannot find the libraries you are specifying. Ensure that they exist in the directory you've told it to look in.

The linker is called after all of the code in your project has been compiled (therefore, it found all of the include/header files necessary for compilation.)

http://www.cetpainfotech.com/technology/c-language-training
Previous Topic:trouble with cross g++ linker and opencv libraries
Next Topic:toolchain path (GNU MCU)
Goto Forum:
  


Current Time: Thu Mar 28 23:31:06 GMT 2024

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

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

Back to the top