First the basics: OS, CB version please ... the forum rules said you should provide them....
Ubuntu 10.04 LTS
CodeBlocks 8.02 (Build Sept 13 2009)
Do you have the paths to this library added to the project configuration in Project-> Build options -> Search directories -> Linker ? If you have them there the console_runner or C::B will export the LD_LIBRARY_PATH variable for you.
Yes - the path the the library is defined in "Project-> Build options -> Search directories -> Linker"
Here is an example...
project "test", file "test.cpp"
#include <iostream>
#include "testlib.h"
using namespace std;
int main()
{
cout << foobar() << endl;
cout << FooBar() << endl;
return 0;
}
project definition file "test.cbp"
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_project_file>
<FileVersion major="1" minor="6" />
<Project>
<Option title="test" />
<Option pch_mode="2" />
<Option compiler="gcc" />
<Build>
<Target title="Debug">
<Option output="bin/Debug/test" prefix_auto="1" extension_auto="1" />
<Option object_output="obj/Debug/" />
<Option type="1" />
<Option compiler="gcc" />
<Compiler>
<Add option="-g" />
</Compiler>
</Target>
<Target title="Release">
<Option output="bin/Release/test" prefix_auto="1" extension_auto="1" />
<Option object_output="obj/Release/" />
<Option type="1" />
<Option compiler="gcc" />
<Compiler>
<Add option="-O2" />
</Compiler>
<Linker>
<Add option="-s" />
</Linker>
</Target>
</Build>
<Compiler>
<Add option="-Wall" />
<Add option="-fexceptions" />
</Compiler>
<Linker>
<Add library="testlib" />
<Add directory="/work/lib" />
</Linker>
<Unit filename="test.cpp" />
<Extensions>
<code_completion />
<debugger />
</Extensions>
</Project>
</CodeBlocks_project_file>
project testlib, file "testlib.h"
#ifndef TESTLIB_H_INCLUDED
#define TESTLIB_H_INCLUDED
#include <string>
using namespace std;
double foobar();
string FooBar();
#endif // TESTLIB_H_INCLUDED
project testlib, file "testlib.cpp"
#include "testlib.h"
using namespace std;
double foobar()
{
return 1; // "Hello world";
}
string FooBar()
{
return "Hello world";
}
project definition file "testlib.cbp"
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_project_file>
<FileVersion major="1" minor="6" />
<Project>
<Option title="testlib" />
<Option pch_mode="2" />
<Option compiler="gcc" />
<Build>
<Target title="Debug">
<Option output="/work/lib/libtestlib" prefix_auto="1" extension_auto="1" />
<Option object_output="obj/Debug/" />
<Option type="3" />
<Option compiler="gcc" />
<Option createDefFile="1" />
<Option createStaticLib="1" />
<Compiler>
<Add option="-g" />
</Compiler>
</Target>
<Target title="Release">
<Option output="/work/lib/libtestlib" prefix_auto="1" extension_auto="1" />
<Option object_output="obj/Release/" />
<Option type="3" />
<Option compiler="gcc" />
<Option createDefFile="1" />
<Option createStaticLib="1" />
<Compiler>
<Add option="-O2" />
</Compiler>
<Linker>
<Add option="-s" />
</Linker>
</Target>
</Build>
<Compiler>
<Add option="-Wall" />
<Add option="-fPIC" />
</Compiler>
<Unit filename="testlib.cpp">
<Option compilerVar="CC" />
</Unit>
<Unit filename="testlib.h" />
<Extensions>
<code_completion />
<debugger />
</Extensions>
</Project>
</CodeBlocks_project_file>
And what terminal do you use to run console-projects in ?
Some terminals seem not expand shell-variables (correctly) given on commandline.
gnome-terminal -t $TITLE -x
Hope this helps