编译时跳过不兼容的库

发布于 2024-09-06 17:15:53 字数 599 浏览 5 评论 0原文

当我尝试在本地计算机上编译项目的副本时,收到一条错误消息,指出它正在跳过不兼容的库。当我在工作中使用服务器上托管的实时版本时,情况并非如此[它完美地存在]。

其他各种网站让我相信这可能是一个环境问题,因为我正在 64 位 Ubuntu 发行版上进行开发,并且我假设服务器版本在 32 位上运行。尽管如此,将我的环境变量设置为:

CFLAGS+=" -m32"
CXXFLAGS+=" -m32"

我仍然收到相同的编译错误:

/usr/bin/ld: skipping incompatible /dvlpmnt/libPI-Http.a when searching for -lPI-Http

Can haz Tutorial?

==编辑==

这是我遵循 Jonathan 的建议时收到的输出:

http.o: ELF 32-bit LSB relocatable, Intel 80386, version 1 (SYSV), not stripped

显然,所讨论的库毕竟是 32 位的?

When I try to compile a copy of my project on my local machine, I get an error stating that it 's skipping over incompatible libraries. This isn't the case when I'm messing around with the live version hosted on the server at work [it makes perfectly there].

Various other sites have lead me to believe that this might be an environment issue, as I'm developing on a 64-bit distro of Ubuntu and I assume the server version is running on 32-bit. Nevertheless, after setting my environment variables to:

CFLAGS+=" -m32"
CXXFLAGS+=" -m32"

I still receive the same compile error of:

/usr/bin/ld: skipping incompatible /dvlpmnt/libPI-Http.a when searching for -lPI-Http

Can haz tutorial?

==Edit==

This was the output I recieved when I followed Jonathan's advice:

http.o: ELF 32-bit LSB relocatable, Intel 80386, version 1 (SYSV), not stripped

Apparently, the library in question is 32-bit after all?

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

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

发布评论

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

评论(2

善良天后 2024-09-13 17:16:02

通常,这本身并不是错误;这是一个警告,表明它找到的第一个与编译器/链接器的 -lPI-Http 参数匹配的文件无效。当找不到具有正确内容的其他库时,就会发生错误。

因此,您需要查看 /dvlpmnt/libPI-Http.a 是 32 位目标文件还是 64 位目标文件的库 - 如果您这样做,它很可能是 64 位使用 -m32 选项进行编译。然后,您需要确定其他位置是否有替代的 32 位 libPI-Http.alibPI-Http.so 文件。如果是这样,请确保包含它的目录列在链接器的 -L/some/where 参数中。如果没有,那么您将需要从某处获取或构建该库的 32 位版本。

要确定该库中的内容,您可能需要执行以下操作:

mkdir junk
cd junk
ar x /dvlpmnt/libPI-Http.a
file *.o
cd ..
rm -fr junk

file”步骤告诉您存档中的对象文件是什么类型。剩下的只是确保你不会弄得一团乱,无法轻易清理。

Normally, that is not an error per se; it is a warning that the first file it found that matches the -lPI-Http argument to the compiler/linker is not valid. The error occurs when no other library can be found with the right content.

So, you need to look to see whether /dvlpmnt/libPI-Http.a is a library of 32-bit object files or of 64-bit object files - it will likely be 64-bit if you are compiling with the -m32 option. Then you need to establish whether there is an alternative libPI-Http.a or libPI-Http.so file somewhere else that is 32-bit. If so, ensure that the directory that contains it is listed in a -L/some/where argument to the linker. If not, then you will need to obtain or build a 32-bit version of the library from somewhere.

To establish what is in that library, you may need to do:

mkdir junk
cd junk
ar x /dvlpmnt/libPI-Http.a
file *.o
cd ..
rm -fr junk

The 'file' step tells you what type of object files are in the archive. The rest just makes sure you don't make a mess that can't be easily cleaned up.

旧情别恋 2024-09-13 17:16:01

该消息实际上并不是错误 - 它只是一个警告,表明相关文件的架构不正确(例如 32 位与 64 位、错误的 CPU 架构)。链接器将继续寻找正确类型的库。

当然,如果您还收到类似 can't find lPI-Http 的错误,那么您就有问题了 :-) 在

不知道具体解决方法的情况下,很难提出确切的补救措施。你的构建系统和 makefile 的详细信息,但这里有一些在黑暗中的镜头:

  1. 只是为了检查:通常你会添加
    标记为 CFLAGS 而不是
    CTAGS - 你确定这是
    正确的? (您所拥有的可能是正确的 - 这取决于您的构建系统!)
  2. 通常该标志也需要传递给链接器 - 因此您可能还需要修改 LDFLAGS

如果这没有帮助- 您能否发布完整的错误输出,以及正在执行的实际命令(例如 gcc foo.c -m32 -Dxxx 等)?

That message isn't actually an error - it's just a warning that the file in question isn't of the right architecture (e.g. 32-bit vs 64-bit, wrong CPU architecture). The linker will keep looking for a library of the right type.

Of course, if you're also getting an error along the lines of can't find lPI-Http then you have a problem :-)

It's hard to suggest what the exact remedy will be without knowing the details of your build system and makefiles, but here are a couple of shots in the dark:

  1. Just to check: usually you would add
    flags to CFLAGS rather than
    CTAGS - are you sure this is
    correct? (What you have may be correct - this will depend on your build system!)
  2. Often the flag needs to be passed to the linker too - so you may also need to modify LDFLAGS

If that doesn't help - can you post the full error output, plus the actual command (e.g. gcc foo.c -m32 -Dxxx etc) that was being executed?

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