简体   繁体   中英

Attempting to compile a GNU library on OS X for 32 and 64 bit

thanks in advance for any help on this, I have scoured the web and can't quite get this to work.

I am trying to compile from source the libgcrypt library from GNU on a mac running OS X 10.9.4. I need to compile to a 32 bit binary which I will later use lipo to blend with the 64 bit one (I have the 64 bit part working). I am trying to be able to reference the libgcrypt binary from both 32 and 64 bit programs. Link here: http://www.gnu.org/software/libgcrypt/

I have grabbed an un-tared the source.

I have used the following configure:

$ ./configure -host=i386-apple-darwin10.5.0 CFLAGS='-arch i386' LDFLAGS='-arch i386'

Which results in:

    Libgcrypt v1.6.2 has been configured as follows:

    Platform:                  Darwin (i386-apple-darwin10.5.0)
    Hardware detection module: hwf-x86
    Enabled cipher algorithms: arcfour blowfish cast5 des aes twofish
                               serpent rfc2268 seed camellia idea salsa20
                               gost28147
    Enabled digest algorithms: crc gostr3411-94 md4 md5 rmd160 sha1
                               sha256 sha512 tiger whirlpool stribog

    Enabled kdf algorithms:    s2k pkdf2 scrypt
    Enabled pubkey algorithms: dsa elgamal rsa ecc
    Random number generator:   default
    Using linux capabilities:  no
    Try using Padlock crypto:  yes
    Try using AES-NI crypto:   yes
    Try using Intel PCLMUL:    yes
    Try using DRNG (RDRAND):   yes
    Try using Intel AVX:       yes
    Try using Intel AVX2:      yes
    Try using ARM NEON:        n/a

But when I try and make (or sudo make), boom!

Making all in src
/bin/sh ../libtool  --tag=CC   --mode=link gcc -I/opt/local/include -arch i386 -Wall  -arch i386 -o mpicalc mpicalc-mpicalc.o libgcrypt.la -L/opt/local/lib -lgpg-error  
libtool: link: gcc -I/opt/local/include -arch i386 -Wall -arch i386 -o .libs/mpicalc mpicalc-mpicalc.o  ./.libs/libgcrypt.dylib -L/opt/local/lib -lgpg-error
ld: warning: ignoring file /opt/local/lib/libgpg-error.dylib, file was built for x86_64 which is not the architecture being linked (i386): /opt/local/lib/libgpg-error.dylib
Undefined symbols for architecture i386:
  "_gpg_strerror", referenced from:
      _print_mpi in mpicalc-mpicalc.o
      _scan_mpi in mpicalc-mpicalc.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [mpicalc] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2

Also of possible interest:

$ g++ --version Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1 Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn) Target: x86_64-apple-darwin13.3.0 Thread model: posix

Relevant web links:

https://gmplib.org/list-archives/gmp-discuss/2010-September/004312.html

Many, many thanks in advance for any help.

Okay, I have solved this, and hopefully other folks will find this of interest.

The configure flags above aren't quite right. The proper configure command is (-m32 is needed):

./configure -host=i386-apple-darwin CFLAGS='-arch i386 -m32 ' LDFLAGS='-arch i386 -m32 '

This will properly compile. FYI, In order for the 32-bit libgcrypt library to compile, you will need a 32 bit version of libgpg-error.

With the 32 bit versions of these libraries compiled, I used lipo to blend the 32-bit and 64-bit versions so that both 32-bit programs and 64-bit programs can both access these libraries.

lipo -create ./libgcrypt.20.dylib /usr/local/lib/libgcrypt.20.dylib -output /tmp/libgcrypt.20.dylib

sudo mv /tmp/libgcrypt.20.dylib /usr/local/lib/libgcrypt.20.dylib

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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