When I compile SQLCIPHER on MacOS 64bit
./configure --enable-tempstore=yes CFLAGS="-DSQLITE_HAS_CODEC -DSQLITE_TEMP_STORE=2" LDFLAGS="/Users/administrator/Documents/openssl/lib/libcrypto.a"
I get 32bit lib libsqlite3.a
But I need a 64bit libsqlite3.a
How I can do this?
The new version of SQLCIPHER does not require OpenSSL anymore.
You first need to configure the build, these are the suggested settings for CommonCrypto rather than SSL as a crypto provider.
./configure --enable-load-extension --enable-tempstore=yes \
--with-crypto-lib=commoncrypto \
CFLAGS="-DSQLITE_HAS_CODEC -DSQLITE_ENABLE_FTS3" \ LDFLAGS="/System/Library/Frameworks/Security.framework/Versions/Current/Security"
Then you need to make it:
make
You will get a 64 bit statically linked SQLLite library.
Have you verified you are linking against a 64-bit version of libcrypto.a since it appears you are building OpenSSL yourself? You will want to run ./Configure darwin64-x86_64-cc if you are building OpenSSL from source for x86_64. The version of OpenSSL found on the system should contain both i386 and x86_64 versions of the architecture, so you shouldn't need to rebuild OpenSSL. Could you run file .libs/sqlite and show the output following a compilation?
Related
I have a Mac which architecture is:
$ arch
arm64
(it supports x86_64 and aarch64).
And I have installed openssl library with brew tool. Now I try to build my application for x86_64 platform (it's Haskell application and the build script is large and complex, so I cannot show it here) and I get an error:
...
<command line>: dlopen(/MyWork/.stack/snapshots/x86_64-osx/b1d675598b9b6c5f516e03f82c45d01becd6003e6128005b2b4acb8628b0f350/9.2.5/lib/x86_64-osx-ghc-9.2.5/libHSHsOpenSSL-0.11.7.2-1JX1qBi8YfpGDjk1ra3OXq-ghc9.2.5.dylib, 0x0005): symbol not found in flat namespace '_DSA_free'
...
However, it works fine for aarch64 platform. After little research I see that my OpenSSL libraries are:
$ file /opt/homebrew/opt/openssl#3/3.0.7/lib/libssl.3.dylib
/opt/homebrew/opt/openssl#3/3.0.7/lib/libssl.3.dylib: Mach-O 64-bit dynamically linked shared library arm64
which seems that it is a library for arm64 and not x86_64, so maybe this is the reason of the error "symbol not found in flat namespace '_DSA_free'".
How to fix it? I guess I need to install the second openssl - for x86_64, I tried arch -x86_64 brew install openssl but I get:
Warning: openssl#3 3.0.7 is already installed and up-to-date.
To reinstall 3.0.7, run:
brew reinstall openssl#3
which makes sense - it is installed already (but for arm64).
How to fix/workaround this problem, so to be able to build the application for both platform while it depends on external libraries like openssl? Maybe there is a way to install openssl for both platform?
EDIT:
Currently I found 2 solutions:
to install libraries from sources setting prefix=/unique/folder/for/arch and to prefix ./configure ..., make, make install by arch -ARCH (where ARCH is x86_64 or arm64).
Another way is to have 2nd Homebrew, it's described here
I am compiling OpenSSL libraries on macOS 10.15, but my application deployment target (which uses these OpenSSL libraries) is 10.12.
So, when I link these libraries with my application I get multiple errors like this:
ld: warning: object file (.../libcrypto.a) was built for newer OXS version (10.15) than being linked (10.12)
The question is:
how to compile OpenSSL to be linked with specific deployment target (in my case it is 10.12)?
When compiling OpenSSL I am trying to configure it like this:
$ ./configure darwin64-x86_64-cc --prefix=/Users/username/openssl --openssldir=/Users/username/openssl/ssl -mmacosx-version-min=10.12
but this does not help.
Ok, I did not execute the command:
$ make distclean
at the end of my previous compilation.
So, it should look like this:
$ ./configure darwin64-x86_64-cc --prefix=/Users/username/openssl --openssldir=/Users/username/openssl/ssl -mmacosx-version-min=10.12
$ make depend
$ make install
$ make distclean
Then all temporary files will be deleted and next compilations with modified sittings will work.
I've tweaked a script for building libjpeg framework here. The key configuration is as follows,
../configure --target i386-apple-darwin9.0 --build i386-apple-darwin9.0 --prefix=$OSXPREFIXDIR/osx-build --disable-dependency-tracking --enable-static=yes --enable-shared=no CFLAGS="-isysroot $XCODE_ROOT/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.5.sdk"
I've been able to create the framework, However it is still built for macOS 10.12 when I use otool -l to check libjpeg object file. Could anyone share a thought?
I have no solution for your compilation problem but if you just want a working libjpeg binary for OS X 10.5+ then you can download it from libjpeg-turbo (either as a static library or as a dynamic one, and both libjpeg and libturbojpeg).
Check: https://libjpeg-turbo.org/Documentation/OfficialBinaries
You'll find a .dmg file on their SourceForge.
Try adding -mmacosx-version-min=10.5 to the CFLAGS. You may not need the target/build parameters, and it may be possible to compile against the latest SDK rather than needing the 10.5 SDK.
I am trying to make command "sudo port install py25-gtk" work. The problem is that (at least) one of the dependencies (gcc44) is not compiling.
I have figured out that it always tries to compile in x86_64 mode but everything else is compiled in i386 mode. Thus, libraries do not match.
I have tried to boot my mac into 64bit mode (various methods), but failed. Also, gmp (dependency of gcc44) does not have x86_64 available.
So my only option to satisfy gcc44 dependency in 32bit mode in macports. How do I do that? How can I force compilation in i368 when "+i386" option fails to do that? +universal fails (gmp does not have x86_64)? Can I download just sources? How do I compile them?
Everything has been tried with and without -f (force) and as root. The problem occurred when I upgraded from leopard (default=i386) to snow leopard (partly x86_64, partly i386).
br,
Juha
... 20 hours later... and after asking the right question:
How to force /usr/bin/gcc -> /usr/bin/gcc -m32?
To force compiler in 32bit mode:
hack the default compiler
- in my case: link /usr/bin/gcc-4.2 to gcc-4.2.sh
#!/bin/sh
/usr/bin/gcc-4.2 -m32 "$#"
br,
Juha
I want to have a static Universal binary lib of Boost. (Preferable the latest stable version, that is 1.43.0, or newer.)
I found many Google hits with similar problems and possible solutions. However, most of them seems outdated. Also none of them really worked.
Right now, I am trying
sudo ./bjam --toolset=darwin --link=static --threading=multi \
--architecture=combined --address-model=32_64 \
--macosx-version=10.4 --macosx-version-min=10.4 \
install
That compiles and install fine. However, the produced binaries seems broken.
az#ip245 47 (openlierox) %file /usr/local/lib/libboost_signals.a
/usr/local/lib/libboost_signals.a: current ar archive random library
az#ip245 49 (openlierox) %lipo -info /usr/local/lib/libboost_signals.a
input file /usr/local/lib/libboost_signals.a is not a fat file
Non-fat file: /usr/local/lib/libboost_signals.a is architecture: x86_64
Edit: It seems that the command was wrong and I must remove the "--" for most options. So the command I am trying now (-a just means to rebuild all):
sudo ./bjam -a toolset=darwin link=static threading=multi \
architecture=combined address-model=32_64 \
macosx-version=10.4 macosx-version-min=10.4 \
install
However, this gives many strange errors (what I already had earlier), all like this:
darwin.compile.c++.pch bin.v2/libs/math/build/darwin-4.2.1/release/address-model-32_64/architecture-combined/link-static/macosx-version-min-10.4/macosx-version-10.4/threading-multi/../src/tr1/pch.hpp.gch
In file included from ./boost/math/special_functions/acosh.hpp:18,
from ./boost/math/special_functions.hpp:15,
from libs/math/build/../src/tr1/pch.hpp:9:
./boost/config/no_tr1/cmath.hpp:21:19: error: cmath: No such file or directory
This could be another problem I have when building Universal binaries: g++ on MacOSX doesn't work with -arch ppc64
I found the problem. It seems that the MacOSX 10.4 SDK is missing a bunch of symlinks for GCC 4.2.
Use this as a test case:
g++ on MacOSX doesn't work with -arch ppc64
It will report multiple errors with GCC 4.2 (missing C++ includes, missing C includes, missing libs). In all cases, you can just fix that by setting a symlink. Search in your SDK for the file and just set the symlink in the same way it is in the MacOSX 10.5 SDK.
After that, it all just worked.
We use Boost compiled for 10.4 here at work. We don't use GCC 4.2 on it though, rather we use GCC 4.0 as Apple's GCC 4.2 is not supported for the MacOS 10.4 SDK. To accomplish this you need a bjam user config file, eg. user-config-darwin.jam. Here's the contents of ours. Modify to your heart's content:
# Boost.Build Configuration
# Compiler configuration
using darwin : 8.11 : /usr/bin/g++-4.0 :
<architecture>"combined"
<address-model>"32" # this can be changed to 32_64 for 32/64 universal builds
<macosx-version>"10.4"
<macosx-version-min>"10.4"
# <root>"/Developer"
<compileflags>""
<linkflags>"" ;
Then, you need to tell bjam to use the user config jam file when compiling:
bjam --user-config=user-config-darwin.jam ... (your other options go here) ...
Now you don't have to mess with symlinks in the system SDK directories.
To build 4-way universal boost static binaries on OSX 10.6 I do the following:
Download boost from the boost website.
Extract the archive and cd into the boost_1_xx_0 folder (where xx is the version of boost you are using).
Run:
./bootstrap.sh and then
./bjam macosx-version=10.6 macosx-version-min=10.4 architecture=combined threading=multi link=static address-model=32_64
This will compile everything except for Boost.MPI (which requires the --with-mpi option). The build products get put in ./stage