开发者

By default, does gcc link to static or dynamic standard library?

Ex:

gcc source-file

I think开发者_如何学Go it is dynamic but I'm not sure. Is it system dependent?


It is technically system dependent, but on most systems you're likely to develop for, the answer is "dynamic".

A few systems (mostly very old, embedded, or otherwise specialized) do not support dynamic linking at all, but most developers are unlikely to care about those systems. On those systems, the linker will of course default to linking statically (unless whoever did the port screwed up :)).

Some systems also do not offer static versions of their standard libraries, so you can't statically link them.

On many systems (especially any typical Linux system), you probably have a utility called ldd. You can use ldd <file> to check if it's dynamically linked to the standard library (assuming you know for sure what the library is called, it's usually libc though).


Most linkers prefer dynamic libraries to static when linking, but normally they have flags to explicitly specify the behaviour. It's definitely system dependent - check your linker documentation for details.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜