User forums > Using Code::Blocks
Static Library in Static Library using Code::Blocks?
The_GTA:
Hello Code::Blocks crew,
I have the same problem as described here:
http://forums.codeblocks.org/index.php/topic,11522.msg78462.html#msg78462
Under MSVC I am able to include static libraries in static libraries, but I cannot do so with Code::Blocks. But GNU tools support it!
Did you know that GNU AR supports "thin libs" using -T option so which basically contain file paths to all objects and .a files? This way static libraries can include other static libraries.
(https://stackoverflow.com/questions/3821916/how-to-merge-two-ar-static-libraries-into-one , the answer by Guillem Lover)
Unfortunately even with Code::Blocks big scripting system I cannot find a way to add options to the ar command line. But I would prefer that Code::Blocks looked into the Linker options of static library projects and used a thin-lib output if the project were to add other static libraries...
Please help..
- Martin
stahta01:
Do you know your Operation System name and version?
Do you know your Compiler name and version?
Do you know the linking command that you wish to use in Code::Blocks?
If you know the above are you not telling us for a valid reason?
Edit: Did you try adding "-T" without the double quotes to the Linker other options?
Tim S.
The_GTA:
--- Quote from: stahta01 on January 24, 2018, 05:36:54 pm ---Do you know your Operation System name and version?
--- End quote ---
I am using Linux Ubuntu 17.10 Artful.
--- Quote from: stahta01 on January 24, 2018, 05:36:54 pm ---Do you know your Compiler name and version?
--- End quote ---
GCC 7.2.0
--- Quote from: stahta01 on January 24, 2018, 05:36:54 pm ---Do you know the linking command that you wish to use in Code::Blocks?
--- End quote ---
gcc -r -s -T ../lib/linux/Debug/libfs.a *ALL OBJECT FILES*
gcc -r -c -T ../lib/linux/Debug/libfs.a ../../zlib/lib/linux/Debug/libzlib.a
--- Quote from: stahta01 on January 24, 2018, 05:36:54 pm ---If you know the above are you not telling us for a valid reason?
Edit: Did you try adding "-T" without the double quotes to the Linker other options?
Tim S.
--- End quote ---
I have actually managed to fix it by changing the GCC global compiler advanced options. The behavior of "Linking objects to static libraries" was changed. The new script is...
--- Code: ---rm -f $static_output
$lib_linker -r -s -T $static_output $link_objects
$lib_linker -r -c -T $static_output $link_options
--- End code ---
Since static libraries do not use the $link_options otherwise, I can just add all the paths to static library dependencies in the "Build options..." -> "Linker settings" tab -> "Other linker options" editbox. Kind of a hack but it works so I am fine with it. Just that everyone who would want this support has to adjust Code::Blocks global settings... kinda bad.
Here is a step-by-step guide (with images): http://green-candy.osdn.jp/codeblocks_config.html
- Martin
giorgik:
Also I have the same problem of compiling using 2 static libraries of which one calls the other. I use Code :: Blocks 16.1 with the MinGW 7.1 compiler from MSYS2 on Win7 64bit.
If it can serve, I can attach the whole project to it: the 2 static libraries and the test main that uses them.
oBFusCATed:
--- Quote from: giorgik on January 26, 2018, 11:14:00 am ---Also I have the same problem of compiling using 2 static libraries of which one calls the other.
--- End quote ---
I doubt you have the same problem. But you have to share details about your problem to be sure.
The op has posted how to change the compiler settings to make it possible to merge static libs.
--- Quote from: giorgik on January 26, 2018, 11:14:00 am ---If it can serve, I can attach the whole project to it: the 2 static libraries and the test main that uses them.
--- End quote ---
Just link both libraries in the final executable/dll/shared library. This is the standard way of linking to static libs.
Navigation
[0] Message Index
[#] Next page
Go to full version