Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Library question
Library question [message #725285] Wed, 14 September 2011 12:34 Go to next message
schliz11 is currently offline schliz11Friend
Messages: 6
Registered: September 2011
Junior Member
I am working with Eclipse Indigo.
I have two C++ projects.
The first project creates a library .a.
The second project uses this library and creates a binary at the end.

Is it possible (and which steps do I have to do) to get the following:

When debugging the second project.

1) I would like to debug into the libraries code.
2) If I change something in the libraries code, I would like to have it build and linked automatically when I restart debugging of the second project.

Thank you very much for your help.
Georg
Re: Library question [message #725935 is a reply to message #725285] Fri, 16 September 2011 08:25 Go to previous messageGo to next message
David Bo Jensen is currently offline David Bo JensenFriend
Messages: 12
Registered: November 2010
Junior Member
The first should be possible just out of the box, as long the second project links to the library with debugger information.
The second can be complicated. I use cygwin, g++ and have discovered strange behavior. I have 4 open projects where one is the executable depending on the other 3 which are static libraries. The exe project referes to lib1 which again referes to the 2 other libs.
When I build the executable I get this
one library is not rebuild (That's okay because I have made no changes)
second library is build all the times (No matter if I make changes to it or not)
the last library is created all the time no matter if I make changes to it or not, however if I make changes, the source files are compiled too.
My conclusion is that Eclipse can't be used with cygwin unless for a simple "Hello world" project
Re: Library question [message #727113 is a reply to message #725935] Tue, 20 September 2011 12:41 Go to previous message
schliz11 is currently offline schliz11Friend
Messages: 6
Registered: September 2011
Junior Member
What I found out:
To create a static library select:

File → new Project → C++ Project

Select further:

Static library / Empty project

Enter a library's name.
Add some header and source files.

If you compile the project you get:

/Debug/libNAME.a
/Release/libNAME.a

Importing the library

(Now we want to use the library created earlier)
Create a new C / C++ Project.

Add the used headerfiles of the library in the code e.g.: (#include <myTestLib.h>)

You need to enter the following settings for Release and Debug.

Libraries -l

Enter the library without lib____.a only the name! For example the library in the Debug folder is libmyTestLib.a, you need to enter myTestLib only.

Library search path -L

Enter the path where the library is located.


C/C++General / Path and Symbols/ Includes
Needs to point to the headerfiles of the lib. Do this for GNU C and GNU C++


During debugging a project which includes a library you need sometimes to edit the code of the library. If you set a reference to the library, it is built automatically before you start a new debugging session. Do this for Release and Debug. Set a reference as the following:
Path and Symbols -> References -> select Lib project Release or Debug

That's it
Georg
Previous Topic:Fortran code profiling with TAU
Next Topic:[Code Style] Indention in Initializer lists?
Goto Forum:
  


Current Time: Wed May 08 10:15:37 GMT 2024

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

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

Back to the top