在freebsd上构建32位libcurl的正确方法是什么?

时间:2018-06-27 20:42:51

标签: libcurl freebsd 32-bit

我需要在freebsd上构建一个32位的libcurl.so。

如果我这样运行./configure:

CFLAGS="-m32" CPPFLAGS="-m32" LDFLAGS="-L/usr/lib32 -m32" ./configure --prefix=/usr/home/debby/libcurl2

在config.log中出现以下错误:

configure:4373: checking whether the C compiler works
configure:4395: gcc -m32 -m32 -L/usr/lib32 -m32 conftest.c  >&5
/usr/local/bin/ld: i386:x86-64 architecture of input file `/usr/lib/crt1.o' is incompatible with i386 output
/usr/local/bin/ld: i386:x86-64 architecture of input file `/usr/lib/crti.o' is incompatible with i386 output
/usr/local/bin/ld: i386:x86-64 architecture of input file `/usr/local/lib/gcc6/gcc/x86_64-portbld-freebsd11.1/6.4.0/crtbegin.o' is incompatible with i386 output
/usr/local/bin/ld: i386:x86-64 architecture of input file `/usr/local/lib/gcc6/gcc/x86_64-portbld-freebsd11.1/6.4.0/crtend.o' is incompatible with i386 output
/usr/local/bin/ld: i386:x86-64 architecture of input file `/usr/lib/crtn.o' is incompatible with i386 output

我什至以正确的方式来对待吗?我应该在./configure命令行上指定--build和--host,如果是的话,应使用什么值?

=========

更新

使用@Wodin建议的第一个链接,我进行如下配置:

export CFLAGS="-m32 -march=i686 -mmmx -msse -msse2 -mfancy-math-387 -DCOMPAT_32BIT"
#export CPPFLAGS="-m32 -march=i686 -mmx -msse -msse2 -DCOMPAT_32BIT"
export LDFLAGS="-m32 -L/usr/lib32 -B/usr/lib32"
./configure --prefix=/usr/home/debby/libcurl

然后make失败,因为我没有32位运行时库

[debby@GServerBuild ~/curl-7.60.0]$ make install
Making install in lib
  CCLD     libcurl.la
/usr/local/bin/ld: i386:x86-64 architecture of input file `/usr/lib/crti.o' is incompatible with i386 output
/usr/local/bin/ld: i386:x86-64 architecture of input file `/usr/local/lib/gcc6/gcc/x86_64-portbld-freebsd11.1/6.4.0/crtbeginS.o' is incompatible with i386 output
/usr/local/bin/ld: i386:x86-64 architecture of input file `/usr/local/lib/gcc6/gcc/x86_64-portbld-freebsd11.1/6.4.0/crtendS.o' is incompatible with i386 output
/usr/local/bin/ld: i386:x86-64 architecture of input file `/usr/lib/crtn.o' is incompatible with i386 output
collect2: error: ld returned 1 exit status
*** Error code 1

根据提供的第二个链接,看来我需要从/ usr / src构建那些空的库。

我正在尝试使用fetch -o /tmp ftp://ftp.freebsd.org/pub/ uname -s /releases/ uname -m / uname -r |如此处所述,剪切-d'-'-f1,2 /src.txzhttps://unix.stackexchange.com/questions/204956/how-do-you-install-the-freebsd10-kernel-sources 并将在这里更新其余部分的运行方式

1 个答案:

答案 0 :(得分:0)

您正在使用/ usr / local / bin / ld,它是来自端口的binutils。可能没有32位支持。尝试设置LD。

    LD=/usr/bin/ld CFLAGS="-m32" CPPFLAGS="-m32" LDFLAGS="-L/usr/lib32" ./configure --libdir=/usr/local/lib32

我还用readelf检查了文件。

    readelf -h lib/.libs/libcurl.so
  

ELF标头:

     

魔术:7f 45 4c 46 01 01 01 09 00 00 00 00 00 00 00 00 00

     

类别:ELF32

     

数据:2的补码,小尾数

     

版本:1(当前)

     

OS / ABI:FreeBSD

最好的方法是在端口中复制Makefile并进行设置。

PKGNAMEPREFIX="lib32-"
CFLAGS+="-m32"
CPPFLAGs+="-m32"
LDFLAGS+="-L/usr/lib32"
CONFIGURE_ARGS+="--libdir="${LOCALBASE}/lib32"