简体   繁体   English

Autotools:使用单个Makefile创建32位和64位库吗?

[英]Autotools: create a 32-bit and 64-bit library with a single makefile?

I am trying to convert a project to autotools. 我正在尝试将项目转换为自动工具。 My project consists of a program and a library. 我的项目包括一个程序和一个库。 The library is not linked with the program. 该库与程序链接。 Instead, the library will be linked with other programs to communicate with my program. 相反,该库将与其他程序链接以与我的程序进行通信。 My program is 64-bit, but I need both a 32-bit and a 64-bit library to make sure it can be used by any program. 我的程序是64位的,但是我需要32位和64位的库,以确保可以被任何程序使用。 I can't figure out how to do this - it seems like autotools only supports one host architecture for the entire package. 我不知道该怎么做-似乎自动工具仅支持整个软件包的一种主机体系结构。

I've tried setting the -m32 flag to get a 32-bit library, but that doesn't work because the linker tries to link with /usr/lib instead of /usr/lib32. 我尝试将-m32标志设置为获取32位库,但这不起作用,因为链接器尝试使用/ usr / lib而不是/ usr / lib32进行链接。 Even if I add /usr/lib32 to the linker flags, I still get errors like this: 即使将/ usr / lib32添加到链接器标志,我仍然会收到如下错误:

/usr/bin/ld: i386:x86-64 architecture of input file `/usr/lib/gcc/x86_64-unknown-linux-gnu/4.8.0/../../../../lib/crti.o' is incompatible with i386 output
/usr/bin/ld: i386:x86-64 architecture of input file `/usr/lib/gcc/x86_64-unknown-linux-gnu/4.8.0/crtbeginS.o' is incompatible with i386 output
/usr/bin/ld: i386:x86-64 architecture of input file `/usr/lib/gcc/x86_64-unknown-linux-gnu/4.8.0/crtendS.o' is incompatible with i386 output
/usr/bin/ld: i386:x86-64 architecture of input file `/usr/lib/gcc/x86_64-unknown-linux-gnu/4.8.0/../../../../lib/crtn.o' is incompatible with i386 output

So I guess this isn't the right way to do it. 所以我想这不是正确的方法。 I could create a separate package for the library of course, but I want to avoid that. 我当然可以为该库创建一个单独的程序包,但我想避免这种情况。 Is it possible to keep everything in one package? 有可能将所有物品都放在一个包装中吗?

The solution doesn't have to be cross-platform, this program is linux-only. 解决方案不必是跨平台的,该程序仅适用于linux。

Most Linux distros that I know of that support 64-bit have 2 versions of each lib package: a 32-bit and a 64-bit. 据我所知,大多数Linux发行版都支持64位,每个lib软件包都有2个版本:32位和64位。 Since autotools supports only one host architecture, it would be easiest to do two builds. 由于自动工具仅支持一种主机体系结构,因此最容易进行两种构建。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM