Page 1 of 1

How to use library from project?

Posted: Thu Dec 23, 2010 9:09 am
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

Re: How to use library from project?

Posted: Thu Dec 23, 2010 11:18 pm
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

Re: How to use library from project?

Posted: Fri Dec 24, 2010 7:09 am
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

Re: How to use library from project?

Posted: Fri Dec 24, 2010 11:50 am
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