User forums > Help

static linking

(1/2) > >>

phenex:
hi folks,
can anyone explain how i can use the argument "-static" in codeblocks,
i try it since a couple of hours but nothing works.

thanks a lot! phen  8)

phenex:
... i want to link the runtimes static.
i heard the gcc/mingw option for this is "-static", but i dont know how i can use this option in code::blocks.
"build > compiler options > linker > other linker options: -static" doesnt work :(

phen

thomas:
It is difficult to answer when one does not understand the question.
Sarek, Star Trek: The Voyage Home
In other words, it may be helpful if you elaborate "nothing works" a bit more and give more detailled information about your system. A copy of your compiler's/linker's commandline and error messages might be helpful, too. Just "nothing works" is not an awful lot of information.

In general, the -static option does what you want in gcc/MinGW, on systems that do support it, and if the required libraries are found. It normally works without that flag, however, by selecting the correct library (a static one).
If you refer to one of glibc/glibc++/MinGW stub as "the runtime", this is always linked statically anyway.
If you refer to MSVCRT.DLL as "the runtime", then I am afraid this will not work, at least not without a lot of hacking and violating the law.
(EDIT: It's not necessary, anyway, since MSVCRT is/should be on every computer.)

phenex:
hi thomas thanks for the answer.
my problem is, when i make a program with c::b and give it to a friend then always comes this error:
This application has failed to start because the application configuration is incorrect.
i heard i can solve this problem by using '-static', but the size of my app doesnt change if i use it.
because of this i think it doesnt work.

but if i enable the whole commandline output i can see this:

--- Code: ---mingw32-g++.exe    -Os     -IC:\Programme\CodeBlocks\include -c main.cpp -o .objs\main.o
windres.exe -i icon.rc -J rc -o .objs\icon.res -O coff   
mingw32-g++.exe    -LC:\Programme\CodeBlocks\lib -o .\test\test.exe .objs\main.o  .objs\icon.res     -s -static
--- End code ---

phen (please excuse my poor english)

phenex:
is it still to unexactly? :)
please guys give me a hint - its very important for me to solve that problem.

Navigation

[0] Message Index

[#] Next page

Go to full version