Hi,
I´m actually working on porting some project to OS X using Code::Blocks. First of all, I use Code::Blocks for the Linux port as well - without any problems. I use the Mac Version 8.02-p2. I actually face two problems which might be strongly linked to each other:
1. Dynamic Library path set incorrectlyThe following scenario: The project-file for the dynamic library is located in root/dir/subdir, the output-file is written to: root/bin. All paths are given relative, therefore output filename would be:
../../bin/lib.dynlib. The working directory of the dynlib is set to
../../bin. The project compiles and links as intended, alright so far. But now, as soon as I execute the binary it can´t find the dynlib. The working directory is
../bin, that´s the relative path from the binaries project file to the bin-folder. The thing is: According to the output, the dynamic linker tries to find
../../bin/lib.dynlib, what is the output filename of the dynlib. It seems to treat it as a absolute path somehow. I cannot see this behavior under GNU/Linux.
I then thought I might tell the linker manually where to find the dynamic libs by setting the path manually in the linker options via
But this didn´t change a thing. What temporarily fixed the thing is to set the dynlib path manually in the terminal session via
DYLD_LIBRARY_PATH=<full path to bin folder>
But this is not really an option. Therefore: How can I fix this?
2. Working directory of librariesI´m actually not sure whether this is a Code::Blocks-problem, but I guess it is somehow. The working directory (given by getwd()) of the binary is correctly the absolute version of
/root/bin. But when I call this function from a library (surprisingly no matter whether this is a static or dynamic one), I get
/root. I set the working directories of the dynamic libraries correctly, for instance
../../bin for the above example (setting the relative path). I wonder how it finally becomes
/root, I mean I could think of
/root/dir/subdir or /root/bin as possible options, but why
../ ?
I tried to find the solution myself, but I couldn´t. I really hope someone can help me.
Thanks a lot & best Regards,
badday
PS: If further information is required, just let me know it