Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using crossbuild to build static external libraries #22

Open
calvn opened this issue Jun 27, 2016 · 6 comments
Open

Using crossbuild to build static external libraries #22

calvn opened this issue Jun 27, 2016 · 6 comments
Labels

Comments

@calvn
Copy link

calvn commented Jun 27, 2016

Is it possible to use crossbuild to build external static libraries for different platforms? More specifically, I would like to build libgit2 and its dependencies statically (openssl and libssh2). I have been encountering one error after another, but it is most likely because I am not familiar enough in the subject matter.

Side note: Both libgit2 and libssh2 uses CMake for the build/install, which in turn depends heavily on pkg-config. I realized that when passing in CROSS_TRIPLE=x86_64-apple-darwin, pkg-config is installed, but otherwise it is not present on the image.

@moul
Copy link
Member

moul commented Jul 4, 2016

Hi @cleung2010

Is it possible to use crossbuild to build external static libraries for different platforms?

yes it is possible, however in some cases, it may be harder than just running the image with the correct env, can you give me some more detail about your issues ?

in CROSS_TRIPLE=x86_64-apple-darwin, pkg-config is installed, but otherwise it is not present on the image

Probably related with #21

@calvn
Copy link
Author

calvn commented Jul 5, 2016

An example would be to build libgit2, openssl, and libssh2 for different operating systems using crossbuild as the base image.

I am trying to get it to work in here, and got linux-amd64 in a functional state. However, I am not sure how to make the darwin-x64 or win-x64 versions build properly.

@moul
Copy link
Member

moul commented Jul 18, 2016

@cleung2010 there is now an /usr/osxcross/bin/osxcross-macports binary in the image, I hope it may help you to install your dependencies for osx targets

@moul moul added the ready label Dec 21, 2016
@clns
Copy link

clns commented Jun 29, 2018

Has anyone managed to build libgit2 (including libssh2 and openssl) on macos with this docker image?

@clns
Copy link

clns commented Jun 29, 2018

I tried the following commands but I get an error on make:

# ./Configure darwin64-x86_64-cc
Configuring OpenSSL version 1.1.1-pre3-dev (0x10101003L) for darwin64-x86_64-cc
Using os-specific seed configuration
Creating configdata.pm
Creating Makefile

**********************************************************************
***                                                                ***
***   If you want to report a building issue, please include the   ***
***   output from this command:                                    ***
***                                                                ***
***     perl configdata.pm --dump                                  ***
***                                                                ***
**********************************************************************
# make depend
# make
/usr/bin/perl "-I." -Mconfigdata "util/dofile.pl" \
    "-oMakefile" crypto/include/internal/bn_conf.h.in > crypto/include/internal/bn_conf.h
/usr/bin/perl "-I." -Mconfigdata "util/dofile.pl" \
    "-oMakefile" crypto/include/internal/dso_conf.h.in > crypto/include/internal/dso_conf.h
/usr/bin/perl "-I." -Mconfigdata "util/dofile.pl" \
    "-oMakefile" include/openssl/opensslconf.h.in > include/openssl/opensslconf.h
make depend && make _all
make[1]: Entering directory '/go/src/github.com/openssl/openssl'
make[1]: Leaving directory '/go/src/github.com/openssl/openssl'
make[1]: Entering directory '/go/src/github.com/openssl/openssl'
cc  -I. -Iinclude -O3 -arch x86_64 -Wall -fPIC -DDSO_DLFCN -DHAVE_DLFCN_H -DNDEBUG -DOPENSSL_NO_STATIC_ENGINE -DOPENSSL_PIC -DOPENSSL_CPUID_OBJ -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DRC4_ASM -DMD5_ASM -DAES_ASM -DVPAES_ASM -DBSAES_ASM -DGHASH_ASM -DECP_NISTZ256_ASM -DX25519_ASM -DPADLOCK_ASM -DPOLY1305_ASM -D_REENTRANT -DL_ENDIAN -DOPENSSLDIR="\"/usr/local/ssl\"" -DENGINESDIR="\"/usr/local/lib/engines-1.1\"" -c -MMD -MF apps/app_rand.d.tmp -MT apps/app_rand.o -c -o apps/app_rand.o apps/app_rand.c
cc: error: x86_64: No such file or directory
cc: error: unrecognized command line option '-arch'
Makefile:696: recipe for target 'apps/app_rand.o' failed
make[1]: *** [apps/app_rand.o] Error 1
make[1]: Leaving directory '/go/src/github.com/openssl/openssl'
Makefile:146: recipe for target 'all' failed
make: *** [all] Error 2

@clns
Copy link

clns commented Jul 2, 2018

After setting export CC="crossbuild cc", make goes further, but it stops with this output error:

# make
...
rm -f apps/openssl
${LDCMD:-crossbuild cc} -O3 -arch x86_64 -Wall -Qunused-arguments -fPIC -L.  \
        -o apps/openssl apps/asn1pars.o apps/ca.o apps/ciphers.o apps/cms.o apps/crl.o apps/crl2p7.o apps/dgst.o apps/dhparam.o apps/dsa.o apps/dsaparam.o apps/ec.o apps/ecparam.o apps/enc.o apps/engine.o apps/errstr.o apps/gendsa.o apps/genpkey.o apps/genrsa.o apps/nseq.o apps/ocsp.o apps/openssl.o apps/passwd.o apps/pkcs12.o apps/pkcs7.o apps/pkcs8.o apps/pkey.o apps/pkeyparam.o apps/pkeyutl.o apps/prime.o apps/rand.o apps/rehash.o apps/req.o apps/rsa.o apps/rsautl.o apps/s_client.o apps/s_server.o apps/s_time.o apps/sess_id.o apps/smime.o apps/speed.o apps/spkac.o apps/srp.o apps/storeutl.o apps/ts.o apps/verify.o apps/version.o apps/x509.o \
        -Wl,-search_paths_first  apps/libapps.a -lssl -lcrypto
ld: archive has no table of contents file 'apps/libapps.a' for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Makefile:6470: recipe for target 'apps/openssl' failed
make[1]: *** [apps/openssl] Error 1
make[1]: Leaving directory '/go/src/github.com/openssl/openssl'
Makefile:146: recipe for target 'all' failed
make: *** [all] Error 2

I tried setting export AR=/usr/x86_64-apple-darwin14/bin/ar but it's the same result.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants