User forums > Using Code::Blocks
C::B/Linux - run console and LD_LIBRARY_PATH
jsarao:
TOOL CHAIN:
Code::Blocks 8.02 Build: Feb 27 2008, 21:58:34 - wx2.8.7 (Linux, unicode)
gcc version 4.2.4 (Ubuntu 4.2.4-1ubuntu3)
[Did I miss anything?]
PROBLEM:
I have a similar setup, but a slightly different problem. I have a workspace with 2 projects. Project A: creates a shared (dynamic?) library (MyLib.so). Project B: creates a console application.
I build Project A, with no problem. I see MyLib.so in the output directory.
I try to have Project B link MyLib.so, but I always get the following output in the "Build log":
-------------- Build: Debug in VideoSvrLinux ---------------
Linking console executable: bin/Debug/MyConsoleApp
/usr/bin/ld: cannot find -lMyLib.so
collect2: ld returned 1 exit status
So my console application (Project B) does not even link.
QUESTION: does someone have a very simple example of a Workspace, Project File, Source file that I can use a starting point?
QUESTION: is Code::Blocks "Dynamic library" the same thing as a "Shared Library"?
Project A creates a shared library.
Project B links in that shared library.
Thank in advance.
NOTES:
* tried copying MyLib.so to /usr/local/lib and edited the /etc/ld.so.conf to include that path; no success
* previously Project A was just generating a Static library (libMyLib.a) and I could link against that no problem.
Jenna:
Add the path where the dynamic (shared) library gets created as linker searchpath for your console app.
jsarao:
Tried that. Both a relative path and fixed path with no success.
rcoll:
I'm not a Unix or Linux expert, but isn't LD_LIBRARY_PATH only used for compiling and linking? Don't you need to use LD_RUN_PATH when executing the program?
Ringo
siege:
I run in the same problem and since i couldn't find solution on this forum i decided to post one.
The problem is that xterm do not propagate environment variables.
So i use the following script
--- Quote ---#!/bin/bash
# usage: cbrun title args
xterm -T $1 -e bash -c 'export LD_LIBRARY_PATH=$0;shift;$@' $LD_LIBRARY_PATH $@
--- End quote ---
To use set up Codeblocks parameter (Settings/Environment) - terminal to launch console program:
<path_to_script> $TITLE
I tried to make it work directly from parameter (without script) but it become too complex. Maybe i just miss something.
---------
And about second one. For some reason C::B doesn't add "lib" prefix to dynamic libraries but linker expect it. Just add it by hand (so output of project A become libMyLib.so). (But i think this problem was solved lOOng ago.)
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version