Static Linking with Codelite on Linux

General questions regarding the usage of CodeLite
toddcarnes
CodeLite Curious
Posts: 1
Joined: Thu Aug 18, 2011 6:07 pm
Genuine User: Yes
IDE Question: c++
Contact:

Static Linking with Codelite on Linux

Post by toddcarnes »

Hello everyone. My name is Todd and I have just started using CodeLite. So far, I really like it... but I'm having a problem.

I am using CodeLite version 2.8.0.4537 on Lubuntu. I am trying to compile the boost.regex example located at http://www.boost.org/doc/libs/1_47_0/mo ... st-library.

I set my compiler options to -g;-static. I set the search paths to .;/usr/local/boost_1_47_0.

On the linker page, I set my library path to /usr/local/boost_1_47_0/stage/lib and I set libraries to boost_regex.

Everything compiles fine with no errors, but when I try to run the resulting program I get the following error...

./regex_test: error while loading shared libraries: libboost_regex.so.1.47.0: cannot open shared object file: No such file or directory

First, this sounds like it's trying to link to the dynamic version of the library, even though I specifically told the compiler to use the static version.

Second, I verified that BOTH the static & the dynamic versions are in the directory /usr/local/boost_1_47_0/stage/lib. So, even if it was linking against the dynamic version of the library, it should be finding the file.

I have tried to run the file both from withing the IDE and locally in a terminal window with the same result.

Can anyone tell me what I'm doing wrong?

TIA,

Todd
DavidGH
CodeLite Plugin
Posts: 819
Joined: Wed Sep 03, 2008 7:26 pm
Contact:

Re: Static Linking with Codelite on Linux

Post by DavidGH »

Hi Todd,
I set my compiler options to -g;-static
Shouldn't -static be in the linker options instead or as well?
First, this sounds like it's trying to link to the dynamic version of the library, even though I specifically told the compiler to use the static version.
which is what will happen if both are available. Try moving/renaming the .so and see what happens then.

Alternatively, use dynamic linking instead and live happily ever after ;) .

Regards,

David
Post Reply