#pragma comment(lib, "xxx.lib") 在 Linux 下等价? [英] #pragma comment(lib, "xxx.lib") equivalent under Linux?

查看:18
本文介绍了#pragma comment(lib, "xxx.lib") 在 Linux 下等价?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个名为 libunp.a 的静态库文件,我知道我可以使用 gcc -lunp xx 链接到该库.

I have a static library file called libunp.a, I do know I could use gcc -lunp xx to link to the library.

我可以使用 #pragma comment(lib,"xxx.lib") 告诉 Microsoft C/C++ 编译器包含该库;我怎么能在 Linux/GCC 下做到这一点?

I could use #pragma comment(lib,"xxx.lib") to tell the Microsoft C/C++ compiler to include the library; how could I do it under Linux/GCC?

推荐答案

关于编译指示的 GCC 手册页面.

我看到 GCC 不支持源代码中的链接的一个原因是,有时,正确的链接取决于链接顺序;这将要求您确保无论编译顺序如何,链接顺序都正确发生.如果您要进行那么多工作,我想您最好只在命令行(或其他方式)上传递链接器参数.

One reason I saw for GCC not supporting linking in source code was that sometimes, correct linking depends on link order; and this would require you to make sure that the linking order happens correctly no matter the order of compilation. If you're going to go to that much work, you may as well just pass the linker arguments on the command line (or otherwise), I suppose.

这篇关于#pragma comment(lib, "xxx.lib") 在 Linux 下等价?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆