How to use library from project?

General questions regarding the usage of CodeLite
Iwan Zotow
CodeLite Curious
Posts: 2
Joined: Thu Dec 23, 2010 8:55 am
Genuine User: Yes
IDE Question: C++
Contact:

How to use library from project?

Post by Iwan Zotow »

Hi,

Ubuntu 10.10, 64bit. GCC/G++ 4.4.5. Installed Codelite 2.8 .0.4537. Made simple "hello world" console program, it works.

So now how I got the problem:

1. New workspace
2. Made library project, dynamic (shared) library. Two c++ files, one header file. First problem I hit here is that c++ files are NOT compiled with -fPIC compiler switch as required. Fixed it by adding -fPIC to library project settings.
3. Executable console project which ought to call library - cannot include from lib project, cannot link etc.

How it is supposed to work? How in general I set dependencies - libA is to be build first, because libB and libC depends on it, but then executable shall depends on all libraries, build last and link with lib[A,B,C] properly

Help is greatly appreciated

regards
User avatar
eranif
CodeLite Plugin
Posts: 6367
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: How to use library from project?

Post by eranif »

Iwan Zotow wrote: Two c++ files, one header file. First problem I hit here is that c++ files are NOT compiled with -fPIC compiler switch as required. Fixed it by adding -fPIC to library project settings.
Actually, since you will need it for all of your projects, I suggest to add it in the Compiler level and not per-project.

From the main menu:

Settings | Build Settings | Compilers | gnu g++ | Tools

Update the "C++ compiler name" from

Code: Select all

g++

to

Code: Select all

g++ -fPIC
Do the same for the "C compiler name" and "Linker name"

Repeat the above for the "gnu gcc" compiler
Iwan Zotow wrote:3. Executable console project which ought to call library - cannot include from lib project, cannot link etc.
You will have to be more specific here...

Read this:
http://codelite.org/forum/viewtopic.php?f=3&t=804

Eran
Make sure you have read the HOW TO POST thread
Iwan Zotow
CodeLite Curious
Posts: 2
Joined: Thu Dec 23, 2010 8:55 am
Genuine User: Yes
IDE Question: C++
Contact:

Re: How to use library from project?

Post by Iwan Zotow »

I suggest to add it in the Compiler level and not per-project
Well, some libraries might still be build as static. But thank you for help, it worked
You will have to be more specific here...
Ok

Case 1. Workspace, one executable (main) project and one shared library project. Shared library builds ok, no error. But how to add above-mentioned library to the main executable project?
So that if I change something in library, main executable would be properly recompiled or/and relinked

Case 2. Workspace, one executable (main) project and three shared library projects. Out of three libraries, one is base (libBase) and two other libraries (libA and libB) depend on it. Main executable depends on libA and libB.
How to describe such configuration in Codelite ?

libBase
/ \
/ \
libA libB
\ /
\ /
Main exe

In general, in projects with many libs and exes, we have some kind of graph of dependencies. How this graph is mapped into Codelite?

Thank you
User avatar
eranif
CodeLite Plugin
Posts: 6367
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: How to use library from project?

Post by eranif »

Right click on your executable project, and select 'Build order'

You will then be given the list of all the other projects, simply check their names and arrange their order.

Eran
Make sure you have read the HOW TO POST thread
Post Reply