静态库未包含在生成的 LLVM 可执行文件中

发布于 2024-08-28 00:25:35 字数 1060 浏览 7 评论 0原文

我正在尝试使用 LLVM 编译 ac 程序,但在获取一些静态库时遇到问题。我已经使用 LLVM 成功编译了这些静态库,例如,存在 libogg.a 和 ogg.l.bc。

但是,当我尝试构建最终程序时,它不包含静态 ogg 库。我尝试了各种编译器选项,其中最值得注意的是:

gcc oggvorbis.c -O3 -Wall -I$OV_DIR/include -l$OV_DIR/lib/libogg.a -l$OV_DIR/lib/libvorbis.a -o test.exe

这会产生以下输出(为简洁起见,缩短了目录):

$OV_DIR/include/vorbis/vorbisfile.h:75: warning: ‘OV_CALLBACKS_DEFAULT’ defined but not used
$OV_DIR/include/vorbis/vorbisfile.h:82: warning: ‘OV_CALLBACKS_NOCLOSE’ defined but not used
$OV_DIR/include/vorbis/vorbisfile.h:89: warning: ‘OV_CALLBACKS_STREAMONLY’ defined but not used
$OV_DIR/include/vorbis/vorbisfile.h:96: warning: ‘OV_CALLBACKS_STREAMONLY_NOCLOSE’ defined but not used
llvm-ld: warning: Cannot find library '$OV_DIR/lib/ogg.l.bc'
llvm-ld: warning: Cannot find library '$OV_DIR/lib/vorbis.l.bc'
WARNING: While resolving call to function 'main' arguments were dropped!

我发现这令人困惑,因为 $OV_DIR/lib/ogg.l.bc 确实存在,就像 vorbis.l 一样。 bc 并且它们都是每个人都可读的(它们的包含目录也是如此)。

有人知道我做错了什么吗?

谢谢,

马特

I am trying to compile a c program using LLVM and I am having trouble getting some static libraries included. I have successfully compiled those static libraries using LLVM and, for example, libogg.a is present, as is ogg.l.bc.

However, when I try to build the final program, it does not include the static ogg library. I've tried various compiler options with the most notable being:

gcc oggvorbis.c -O3 -Wall -I$OV_DIR/include -l$OV_DIR/lib/libogg.a -l$OV_DIR/lib/libvorbis.a -o test.exe

This results in the following output (directories shortened for brevity):

$OV_DIR/include/vorbis/vorbisfile.h:75: warning: ‘OV_CALLBACKS_DEFAULT’ defined but not used
$OV_DIR/include/vorbis/vorbisfile.h:82: warning: ‘OV_CALLBACKS_NOCLOSE’ defined but not used
$OV_DIR/include/vorbis/vorbisfile.h:89: warning: ‘OV_CALLBACKS_STREAMONLY’ defined but not used
$OV_DIR/include/vorbis/vorbisfile.h:96: warning: ‘OV_CALLBACKS_STREAMONLY_NOCLOSE’ defined but not used
llvm-ld: warning: Cannot find library '$OV_DIR/lib/ogg.l.bc'
llvm-ld: warning: Cannot find library '$OV_DIR/lib/vorbis.l.bc'
WARNING: While resolving call to function 'main' arguments were dropped!

I find this perplexing because $OV_DIR/lib/ogg.l.bc DOES exist, as does vorbis.l.bc and they are both readable (as are their containing directories) by everyone.

Does anyone have any idea with what I am doing wrong?

Thanks,

Matt

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

作妖 2024-09-04 00:25:35

正如放松所说,
-l 后跟库名称。

例如,在Linux库命名约定中,
如果库名为 libogg,

-logg 将在库目录中查找并选择*最佳匹配。

您可以将目录添加到列表中:

  1. -L 选项是将以下文件夹临时添加到列表中的方法之一。
  2. 环境变量 LD_LIBRARY_PATH 也会影响大多数 Linux/Unix 上的列表 >使用 GNU 工具。

gcc 可能会找到名称与请求的库名称匹配的静态库文件和共享库文件。

例如,

libogg.a
libogg.so

这就是为什么有一个 gcc 选项 -static

-静态
在支持动态链接的系统上,这会阻止链接
与共享库。关于其他
系统,此选项无效。

如果您只想直接使用共享或静态库文件,就像目标文件一样,
然后给出他们的路径,没有任何选择,比如

gcc oggvorbis.c the_path/libogg.a

As unwind said,
-l is followed by the library name.

For example, in linux library naming conventions,
if a library is named libogg,

-logg will find and choose the *best match in the library directories.

You can add a directory into the list:

  1. -L option is one of the way to add the following folder to the list temporarily.
  2. The environment variable LD_LIBRARY_PATH also affects the list on most of Linux/Unix > with GNU tools.

gcc may find both static and shared library files whose name matches with the requested library name.

For example,

libogg.a
libogg.so

That's why there is a gcc option, -static

-static
On systems that support dynamic linking, this prevents linking
with the shared libraries. On other
systems, this option has no effect.

If you just want to use a shared or static library file - directly, just as an object file,
then give their path without any option, like

gcc oggvorbis.c the_path/libogg.a
潦草背影 2024-09-04 00:25:35

我不认为 -l 选项需要路径。您应该将它们分开,并使用 -L 选项来设置路径,然后只需使用带有 -l 的普通库名称:

$ gcc oggvorbis.c -O3 -Wall -I$OV_DIR/include -L$OV_DIR/lib -logg -lvorbis -o test.exe

另请注意,像这样使用时,您不要包含库名称的“lib”和“.a”部分。

I don't think the -l option expects paths. You should split those out, and use the -L option to set the paths, then just use plain library names with -l:

$ gcc oggvorbis.c -O3 -Wall -I$OV_DIR/include -L$OV_DIR/lib -logg -lvorbis -o test.exe

Also note that when used like this, you don't include the "lib" and ".a" parts of the library name.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文