开发者

Is it possible to build a self-contained library with gcc (i.e., one which statically incorporates its dependencies)?

开发者 https://www.devze.com 2023-02-14 02:10 出处:网络
I\'m trying to build a library with gcc (actually, MinGW) which depends on stdlibc++. I want to build mylib such that all of its dependencies get incorporated into it, so that anyone linking with myli

I'm trying to build a library with gcc (actually, MinGW) which depends on stdlibc++. I want to build mylib such that all of its dependencies get incorporated into it, so that anyone linking with mylib doesn't开发者_如何学运维 need to link against stdlibc++ (or, if they do, it's because their own code depends on stdlibc++). Can this be done?


Use ar -x to extract the .o files you need from the original library (libstdc++, in your case). Include those .o files with your own when you link your library. Make sure the distribution terms of the original library are compatible with those of your own.

0

精彩评论

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