User forums > Using Code::Blocks

[SOLVED]"Cannot open shared object file ..." when running executable from C::B

<< < (3/4) > >>

ejamsa:
With simple console app it doesn't modify LD_LIBRARY_PATH during compilation/linking. As far as i can see from build log, LD_LIBRARY_PATH is modified only before running the app.

oBFusCATed:
This is how it should work. LD_LIBRARY_PATH doesn't matter during compilation/linking. It is a runtime variable.

So if I understand correctly the simple project works as expected and the complex one doesn't?

ejamsa:
No, they work the same way regardless the project type!
When I run "complex one", I get

--- Code: ----------------- Run: Debug in test (compiler: GNU GCC Compiler)---------------

Checking for existence: /home/ejamsa/Projects/sfml/test/bin/Debug/test
Executing: xterm -T test -e /usr/bin/cb_console_runner LD_LIBRARY_PATH=$LD_LIBRARY_PATH:. /home/ejamsa/Projects/sfml/test/bin/Debug/test  (in /home/ejamsa/Projects/sfml/test/.)
Process terminated with status 0 (0 minute(s), 2 second(s))
--- End code ---
Is it possible to print out LD_LIBRARY_PATH before it runs test program? It must be something to do with the LD_LIBRARY_PATH variable. If I open xterm and type

--- Code: ---echo $LD_LIBRARY_PATH
--- End code ---
it displays /home/ejamsa/SFML-2.1/lib, which is correct directory

oBFusCATed:
See how it should look:


--- Code: ---
-------------- Build: Debug in stepping (compiler: GNU GCC Compiler)---------------

g++ -Wall -fexceptions -g -Werror=return-type -Woverloaded-virtual  -c /home/obfuscated/projects/tests/_cb_dbg/stepping/main.cpp -o .obj/debug/main.o
g++ -Wall -fexceptions -g -Werror=return-type -Woverloaded-virtual  -c /home/obfuscated/projects/tests/_cb_dbg/stepping/test.cpp -o .obj/debug/test.o
g++ -Wall -fexceptions -g -Werror=return-type -Woverloaded-virtual  -c /home/obfuscated/projects/tests/_cb_dbg/stepping/test_no_debug.cpp -o .obj/debug/test_no_debug.o
g++ -L/home/obfuscated/ -o bin/debug/stepping .obj/debug/main.o .obj/debug/test.o .obj/debug/test_no_debug.o   
Output file is bin/debug/stepping with size 29.06 KB
Process terminated with status 0 (0 minute(s), 0 second(s))
0 error(s), 4 warning(s) (0 minute(s), 0 second(s))
 

-------------- Run: Debug in stepping (compiler: GNU GCC Compiler)---------------

Checking for existence: /home/obfuscated/projects/tests/_cb_dbg/stepping/bin/debug/stepping
Executing: xterm -T stepping -g 200x80 -bg gray -fg black -e /usr/bin/cb_console_runner LD_LIBRARY_PATH=$LD_LIBRARY_PATH:.:/home/obfuscated/ /home/obfuscated/projects/tests/_cb_dbg/stepping/bin/debug/stepping  (in /home/obfuscated/projects/tests/_cb_dbg/stepping/.)

--- End code ---

I've added /home/obfuscated to the linker's search paths and as you can see it is set in LD_LIBRARY_PATH as it should.
I don't know why it doesn't work for you.

ejamsa:
I got it to work finally!
It works if I right click project->Build options...->Search directories->Linker and add the directory there.
If I go Settings->Compiler...->Search directories->Linker and add linker search directory, then running the executable from C::B won't work as SFML's lib directory won't be added to LD_LIBRARY_PATH!

What i don't understand is that why such difference between global and project settings?
Also LD_LIBRARY_PATH should contain SFML's lib directory regardless of settings in C::B because I've added it to ~/.bashrc! This is the reason why i don't understand why

--- Code: ---Executing: xterm -T test -e /usr/bin/cb_console_runner LD_LIBRARY_PATH=$LD_LIBRARY_PATH:. /home/ejamsa/Projects/sfml/test/bin/Debug/test  (in /home/ejamsa/Projects/sfml/test/.)
--- End code ---
doesn't work as this command only appends current path to LD_LIBRARY_PATH

Thank you, oBFusCATed, for helping me to get it work!
If anyone knows answers to questions above, can you please shed some light on that?

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version