[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.tools.cdt] Re: Very simple question: How to get CDT to link in a library?

On 17/08/2009 03:05, Eric Rizzo wrote:
Copying this to the eclipse.tools.cdt group.

Paul Pedriana wrote:
I have a static library project called "A" and an executable project
called "ATest". I want ATest to link in the A library. I have A
selected in the "Project References" page for ATest. But A is not
being linked in. Do I need to manually add the A library via the GCC
linker settings page? That doesn't seem right.

I tried adding the path to the A library to the GCC linker libraries
list. GCC just gives the error "/usr/bin/ld: cannot find
-l/home/me/workspace/A/Debug/A.a", which seems crazy because in fact
the file is present and was just built by GCC a minute earlier.

A project dependency does not add the library. All it does, is ensure that the project is built before your project.

Your static library project should have created a library called "libA.a". This will be in a directory called Debug or Release, relative to your project.

In you executable project you need to add a library path:
${workspace_loc:A}/Debug, or
${workspace_loc:A}/Release
depending on whether you want the debug or release build of the library

You also need to add it to the list of libraries to link wth. Add
A
to the list of libraries.
VERY IMPORTANT NOTE: DO NOT add "libA.a" or any combination. The GNU linker automatically adds a "lib" prefix and a ".a" suffix to whatever you specify. If you need more information on the GNU linker, RTM.



-- Derek