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

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

Related

Compile boost as universal library (Intel and Apple Silicon architectures)

I am trying to build boost library as dylib on MacOS. I need to build it for both the Intel architecture and the upcoming Apple Silicon (arm64) architecture.
I downloaded boost and ran the following commands:
./bootstrap.sh
./b2 -address-model=64 architecture=combined -a
lipo -archs always shows produced dylibs architecture is x86_64.
I have Xcode12 beta and MacOS Catalina 10.15.7,
I can build a sample universal library if I create a project in Xcode and set archs arm64 x86_64 in build settings.
Running command ./b2 cxxflags="-arch arm64 -arch x86_64" fails with following errors:
"clang++" -x c++ -fvisibility-inlines-hidden -m64 -O3 -Wall -fvisibility=hidden -Wno-inline -arch arm64 -arch x86_64 -ftemplate-depth-255 -fvisibility=hidden -fvisibility-inlines-hidden -DBOOST_ALL_NO_LIB=1 -DNDEBUG -I"." -c -o "bin.v2/libs/serialization/build/clang-darwin-12.0/release/link-static/threading-multi/visibility-hidden/polymorphic_xml_iarchive.o" "libs/serialization/src/polymorphic_xml_iarchive.cpp"
...failed clang-darwin.compile.c++ bin.v2/libs/serialization/build/clang-darwin-12.0/release/link-static/threading-multi/visibility-hidden/polymorphic_xml_iarchive.o...
clang-darwin.compile.c++ bin.v2/libs/serialization/build/clang-darwin-12.0/release/link-static/threading-multi/visibility-hidden/polymorphic_xml_oarchive.o
In file included from libs/serialization/src/polymorphic_xml_oarchive.cpp:16:
In file included from ./boost/serialization/config.hpp:18:
In file included from ./boost/config.hpp:57:
In file included from ./boost/config/platform/macos.hpp:28:
In file included from ./boost/config/detail/posix_features.hpp:18:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/unistd.h:71:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/_types.h:27:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/sys/_types.h:32:
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/sys/cdefs.h:807:2: error: Unsupported architecture
#error Unsupported architecture
^
In file included from libs/serialization/src/polymorphic_xml_oarchive.cpp:16:
In file included from ./boost/serialization/config.hpp:18:
In file included from ./boost/config.hpp:57:
In file included from ./boost/config/platform/macos.hpp:28:
In file included from ./boost/config/detail/posix_features.hpp:18:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/unistd.h:71:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/_types.h:27:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/sys/_types.h:33:
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/machine/_types.h:34:2: error: architecture not supported
#error architecture not supported
^
In file included from libs/serialization/src/polymorphic_xml_oarchive.cpp:16:
In file included from ./boost/serialization/config.hpp:18:
In file included from ./boost/config.hpp:57:
In file included from ./boost/config/platform/macos.hpp:28:
In file included from ./boost/config/detail/posix_features.hpp:18:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/unistd.h:71:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/_types.h:27:
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/sys/_types.h:55:9: error: unknown type name '__int64_t'
typedef __int64_t __darwin_blkcnt_t; /* total blocks */
^
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/sys/_types.h:56:9: error: unknown type name '__int32_t'; did you mean '__int128_t'?
typedef __int32_t __darwin_blksize_t; /* preferred block size */
^
note: '__int128_t' declared here
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/sys/_types.h:57:9: error: unknown type name '__int32_t'; did you mean '__int128_t'?
typedef __int32_t __darwin_dev_t; /* dev_t */
^
note: '__int128_t' declared here
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/sys/_types.h:60:9: error: unknown type name '__uint32_t'; did you mean '__uint128_t'?
typedef __uint32_t __darwin_gid_t; /* [???] process and group IDs */
^
note: '__uint128_t' declared here
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/sys/_types.h:61:9: error: unknown type name '__uint32_t'; did you mean '__uint128_t'?
typedef __uint32_t __darwin_id_t; /* [XSI] pid_t, uid_t, or gid_t*/
^
The following works for me on Big Sur using Xcode 12.2. On Catalina 10.15.7 (19H15) I get the same error messages as OP.
./bootstrap.sh --with-libraries=regex,date_time
./b2 architecture=combined cxxflags="-arch x86_64 -arch arm64"
I'm on Monterey with an M1 (XCode 13.1) and failed to get any of the other answers to work, but I combined stuff from Navan and Petr along with some other bits to get the libboost_coroutine to work on x86_64. I arrived at the following script which builds all the boost libraries (why not, it doesn't take long on the M1):
#!/bin/sh
rm -rf arm64 x86_64 universal stage bin.v2
rm -f b2 project-config*
./bootstrap.sh cxxflags="-arch x86_64 -arch arm64" cflags="-arch x86_64 -arch arm64" linkflags="-arch x86_64 -arch arm64"
./b2 toolset=clang-darwin target-os=darwin architecture=arm abi=aapcs cxxflags="-arch arm64" cflags="-arch arm64" linkflags="-arch arm64" -a
mkdir -p arm64 && cp stage/lib/*.dylib arm64
./b2 toolset=clang-darwin target-os=darwin architecture=x86 cxxflags="-arch x86_64" cflags="-arch x86_64" linkflags="-arch x86_64" abi=sysv binary-format=mach-o -a
mkdir x86_64 && cp stage/lib/*.dylib x86_64
mkdir universal
for dylib in arm64/*; do
lipo -create -arch arm64 $dylib -arch x86_64 x86_64/$(basename $dylib) -output universal/$(basename $dylib);
done
for dylib in universal/*; do
lipo $dylib -info;
done
This script prints out the lipo info for each dylib in the universal directory, so you can see quickly that every one has both x86_64 and arm64 inside. I had the following result, maybe it's useful for you to see if your output matches:
Architectures in the fat file: universal/libboost_atomic.dylib are: x86_64 arm64
Architectures in the fat file: universal/libboost_chrono.dylib are: x86_64 arm64
Architectures in the fat file: universal/libboost_container.dylib are: x86_64 arm64
Architectures in the fat file: universal/libboost_context.dylib are: x86_64 arm64
Architectures in the fat file: universal/libboost_contract.dylib are: x86_64 arm64
Architectures in the fat file: universal/libboost_coroutine.dylib are: x86_64 arm64
Architectures in the fat file: universal/libboost_date_time.dylib are: x86_64 arm64
Architectures in the fat file: universal/libboost_filesystem.dylib are: x86_64 arm64
Architectures in the fat file: universal/libboost_graph.dylib are: x86_64 arm64
Architectures in the fat file: universal/libboost_iostreams.dylib are: x86_64 arm64
Architectures in the fat file: universal/libboost_locale.dylib are: x86_64 arm64
Architectures in the fat file: universal/libboost_log.dylib are: x86_64 arm64
Architectures in the fat file: universal/libboost_log_setup.dylib are: x86_64 arm64
Architectures in the fat file: universal/libboost_numpy27.dylib are: x86_64 arm64
Architectures in the fat file: universal/libboost_prg_exec_monitor.dylib are: x86_64 arm64
Architectures in the fat file: universal/libboost_program_options.dylib are: x86_64 arm64
Architectures in the fat file: universal/libboost_python27.dylib are: x86_64 arm64
Architectures in the fat file: universal/libboost_random.dylib are: x86_64 arm64
Architectures in the fat file: universal/libboost_regex.dylib are: x86_64 arm64
Architectures in the fat file: universal/libboost_serialization.dylib are: x86_64 arm64
Architectures in the fat file: universal/libboost_stacktrace_addr2line.dylib are: x86_64 arm64
Architectures in the fat file: universal/libboost_stacktrace_basic.dylib are: x86_64 arm64
Architectures in the fat file: universal/libboost_stacktrace_noop.dylib are: x86_64 arm64
Architectures in the fat file: universal/libboost_system.dylib are: x86_64 arm64
Architectures in the fat file: universal/libboost_thread.dylib are: x86_64 arm64
Architectures in the fat file: universal/libboost_timer.dylib are: x86_64 arm64
Architectures in the fat file: universal/libboost_type_erasure.dylib are: x86_64 arm64
Architectures in the fat file: universal/libboost_unit_test_framework.dylib are: x86_64 arm64
Architectures in the fat file: universal/libboost_wave.dylib are: x86_64 arm64
Architectures in the fat file: universal/libboost_wserialization.dylib are: x86_64 arm64
After spending considerable amount of time here:
https://github.com/bfgroup/b2/issues/105
I was able to compile boost on arm64. The command line is:
./b2 architecture=arm address-model=64 asmflags=--target=arm64-apple-darwin21.2.0 cflags=--target=arm64-apple-darwin21.2.0 cxxflags=--target=arm64-apple-darwin21.2.0 linkflags=--target=arm64-apple-darwin21.2.0 -s NO_LZMA=1 -s NO_ZSTD=1 abi=aapcs
the LZMA and ZSTD flags are there since I did not have an universal binary for those libs on my machine.
I was facing the same issue and came across this answer, which was for creating universal binaries for i386 and x86_64.
To summarise the answer, you need to run ./b2 twice ( with different toolsets as clang always builds for x86_64, even if you pass the appropriate CXXFlags
This is the script I used to first individually generate the libraries I required and then combined them using lipo
#!/bin/sh
rm -rf arm64 x86_64 universal
./bootstrap.sh --with-toolset=clang --with-libraries=thread,system,filesystem,program_options,serialization
./b2 cxxflags="-arch arm64" toolset=darwin -a
mkdir -p arm64 && cp stage/lib/*.dylib arm64
./b2 toolset=clang cxxflags="-arch arm64 -arch x86_64" -a
mkdir x86_64 && cp stage/lib/*.dylib x86_64
mkdir universal
for dylib in arm64/*; do
lipo -create -arch arm64 $dylib -arch x86_64 x86_64/$(basename $dylib) -output universal/$(basename $dylib);
done
You don't need to use lipo, you can pass
-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk to cxxflags and it will build a universal library out of the box.
I followed the answer by Navan Chauhan which seems to be the way to go on macOS 10.15.7 with Xcode 12.3.
My only issue was that the build system was adding additional -arch armv4t clang option (or something similar) which fails the build. Using the architecture=combine cannot work as well as it is able to manage Intel and PowerPC only. What does work for me instead is:
bootstrap.sh --with-toolset=clang-darwin and cxxflags, cflags and linkflags set to -arch x86_64 -arch arm64 plus additional options.
x86_64 build: b2 toolset=clang-darwin target-os=darwin architecture=x86 stage and cxxflags, cflags and linkflags set to -arch x86_64 only (plus additional options).
arm64 build: b2 toolset=clang-darwin target-os=darwin architecture=arm abi=aapcs stage and cxxflags, cflags and linkflags set to -arch arm64 only (plus additional options).
Merge libraries with lipo…
I've been forced to set the ABI also as the automatic-guess-something is not able to recognize Apple Silicon goal therefor some assembly stuff is not compiled – hence missing symbols later on during the build. Finally the armv4t issue is solved by the clang-darwin toolset.
The only caveat of this at the moment is that both builds go into the same architectural/configuration directories which can be solved by custom user-config.jam or by immediate call to install just after each stage which is what I did.
Works on:
Host platform: Intel
macOS 10.15.7
Xcode 12.3 (with Command Line Tools installed)
Boost 1.75.0 (dependent compression and ICU libraries already compiled as universal)
For macOS with M1 building boost 1.81.0
./bootstrap.sh
sudo ./b2 -address-model=64 architecture=arm+x86 install
Libraries that support both architectures are installed

Build and install Boost 1.60 in 32 bit on a 64 bit Mac OS X El Capitan

I have an application that use the 32 bit boost library( 1.48 ). The 1.48 version of boost was pre built on 32 bit platform and uses older C++ standards.
For example file libboost_wserialization.dylib gives
libboost_wserialization.dylib: Mach-O universal binary with 2 architectures
libboost_wserialization.dylib (for architecture i386): Mach-O dynamically linked shared library i386
libboost_wserialization.dylib (for architecture x86_64): Mach-O 64-bit dynamically linked shared library x86_64
The requirements have changed and i want to link/use the boost 1.60 with C++ 11 and 32 bit.
I have downloaded the 1.60 boost and modified the bootstrap.sh to include application specific lib and include directories.
I am running the following command
./b2 cxxflags="-std=c++0x -stdlib=libc++" linkflags="-stdlib=libc++" address-model=32 architecture=x86 install
I get the following error
error: unknown target CPU 'i686' for all the files.
If i install the default then I don get the 32 bit version of the boost libraries and application fails to link.
How do i get rid of this error ?. The machine that i am building boost on is Mac OS X El capitan 64 bit.
The entire error is
"clang++" -x c++ -std=c++0x -stdlib=libc++ -O3 -O3 -Wno-inline -Wall -march=i686 -DBOOST_ALL_NO_LIB=1 -DBOOST_MATH_TR1_DYN_LINK=1 -DNDEBUG -I"." -I"libs/math/src/tr1" -c -o "bin.v2/libs/math/build/clang-darwin-4.2.1/release/address-model-32/threading-multi/atanh.o" "libs/math/build/../src/tr1/atanh.cpp"
...failed clang-darwin.compile.c++ bin.v2/libs/math/build/clang-darwin-4.2.1/release/address-model-32/threading-multi/atanh.o...
clang-darwin.compile.c++ bin.v2/libs/math/build/clang-darwin-4.2.1/release/address-model-32/threading-multi/cbrt.o
error: unknown target CPU 'i686'
Try with address-model=64.
More info: http://www.boost.org/build/doc/html/bbv2/reference/tools.html#bbv2.reference.tools.compiler.darwin

How to resolve build errors in OSX cctools?

I am attempting to build tools from the CCtools collection for OSX, under OSX. I am doing this for research purposes.
When I run the makefile for the entire project I get a linker error:
=========== /Applications/Xcode.app/Contents/Developer/usr/bin/make all for misc =============
cc -Os -DLTO_SUPPORT -DTRIE_SUPPORT -g -Wall -I. -I./../include -I. -I/usr/local/include -c -o ./lipo.o lipo.c
cc -nostdlib -r \
-o ./lipo.private.o \
./lipo.o -L./../libstuff -lstuff
cc -o ./lipo.NEW \
./lipo.private.o
Undefined symbols for architecture x86_64:
"_is_llvm_bitcode_from_memory", referenced from:
_main in lipo.private.o
_check_archive in lipo.private.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [lipo.NEW] Error 1
make: *** [all] Error 1
Running the make files of the individual tools nets me a similar linker error. This occurs for all versions of the CCtools I have tried (Including 877.5, the latest source, and 862, the version that my installed tools are at.)
What am I missing to make the tools compile?
How can I coax the linker to let me know what library I am missing?
Where can I find instruction to make the tools compile?
Additional info:
I have XCode and developer tools installed, and I build projects all the time.
I also have gcc installed from brew.
I must be missing something stupid.
I cannot give you the exact solution for your version 877.5 but the overall problem is that the compilation requires some of the LLVM code on your machine. It might be as simple as missing include directories for the LLVM headers or can require linking some of the LLVM libraries. In your case, they seem to be related to LLVM Bitcode somehow.
In my case, I have just built a subset of the more recent version cctools-895. It complained about a missing symbol related to LLVM's llvm-c/lto.h header. The error went away when I added the following to the problematic file's compilation rules:
-I/opt/llvm-7.0.0/include/
The version of LLVM 7 was a random guess that worked because I had it on my machine. You might want to tailor your include paths to point to the correct version of LLVM that the cctools are supposed to be built with.
The easiest way to get the LLVM on your machine is to get a binary version from the LLVM Download page.

building 32 exe on 64 bit open suse linux gives link error

In my VM, I have installed open suse linux 64 bit.
Trying to build an exe for 32 bit.
But on running the command :
g++ prg1.cpp -o prg1 -m32
I get the following error:
/usr/lib64/gcc/x86_64-suse-linux/4.8/../../../../x86_64-suse-linux/bin/ld:
skipping incompatible
/usr/lib64/gcc/x86_64-suse-linux/4.8/libstdc++.so when searching for
-lstdc++ /usr/lib64/gcc/x86_64-suse-linux/4.8/../../../../x86_64-suse-linux/bin/ld:
skipping incompatible /usr/lib64/gcc/x86_64-suse-linux/4.8/libstdc++.a
when searching for -lstdc++
/usr/lib64/gcc/x86_64-suse-linux/4.8/../../../../x86_64-suse-linux/bin/ld:
cannot find -lstdc++ collect2: error: ld returned 1 exit status
To build for 32 i have installed the necessary rpms for 32 bit.
On running
g++ -print-search-dirs , the output is
install: /usr/lib64/gcc/x86_64-suse-linux/4.8/ programs:
=/usr/lib64/gcc/x86_64-suse-linux/4.8/:/usr/lib64/gcc/x86_64-suse-linux/4.8/:/usr/lib64/gcc/x86_64-suse-linux/:/usr/lib64/gcc/x86_64-suse-linux/4.8/:/usr/lib64/gcc/x86_64-suse-linux/:/usr/lib64/gcc/x86_64-suse-linux/4.8/../../../../x86_64-suse-linux/bin/x86_64-suse-linux/4.8/:/usr/lib64/gcc/x86_64-suse-linux/4.8/../../../../x86_64-suse-linux/bin/
libraries:
=/usr/lib64/gcc/x86_64-suse-linux/4.8/:/usr/lib64/gcc/x86_64-suse-linux/4.8/../../../../x86_64-suse-linux/lib/x86_64-suse-linux/4.8/:/usr/lib64/gcc/x86_64-suse-linux/4.8/../../../../x86_64-suse-linux/lib/../lib64/:/usr/lib64/gcc/x86_64-suse-linux/4.8/../../../x86_64-suse-linux/4.8/:/usr/lib64/gcc/x86_64-suse-linux/4.8/../../../../lib64/:/lib/x86_64-suse-linux/4.8/:/lib/../lib64/:/usr/lib/x86_64-suse-linux/4.8/:/usr/lib/../lib64/:/usr/lib64/gcc/x86_64-suse-linux/4.8/../../../../x86_64-suse-linux/lib/:/usr/lib64/gcc/x86_64-suse-linux/4.8/../../../:/lib/:/usr/lib/
Although the 32 bit libstdc++ is also installed, the linker is not able to link to it. Is any specific flag required to tell the linker to build 32 bit
Or I have to install any other package?
To build for 32 i have installed the necessary rpms for 32 bit.
No, you have not.
Note that in order to build programs you need 32-bit runtime and development libraries. I am guessing that you've installed the former, but not the latter.

Building Portaudio on OSX 10.7.5 using SDK10.6 or 10.7 fails

I am still having trouble building the Portaudio library on my system, which is OSX 10.7.5 with Xcode 4.3.2, having Command Line Tools installed and having SDK10.6 and SDK10.7 under
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/
I describe shortly (also for others that run into the same problem) what I have done so far (following different solutions I have found on the web).
1) I downloaded "Portaudio" / pa_stable_v19_20111121.tgz (last stable release) from:
www.portaudio.com/download.html
2) I read the instructions on building Portaudio here:
www.portaudio.com/docs/v19-doxydocs/compile_mac_coreaudio.html
and tried to compile from a Terminal window with the suggested command:
./configure && make
This resulted (not so surprisingly) in a lot of errors ending with:
llvm-gcc-4.2: error trying to exec '/usr/bin/../llvm-gcc-4.2/bin/powerpc-apple-darwin11-llvm-gcc-4.2': execvp: No such file or directory
lipo: can't open input file: /var/folders/1_/xkp08ky561jg02zjjrpsxg940000gn/T//ccPxCTrJ.out (No such file or directory)
make: * [src/hostapi/coreaudio/pa_mac_core.lo] Error 1
This happens because "ppc" is not supported anymore since OSX 10.5. Moreover the "Developer" folder doesn't exist on OSX 10.7 and everything that was in the Developer folder has moved to
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/
3) I downloaded a patch (mac_configure_patch.txt) to fix "configure" from:
https://www.assembla.com/spaces/portaudio/tickets/216#/activity/ticket:
and copied it to the portaudio directory and applied it by typing in Terminal:
$ patch < mac_configure_patch.txt
A confirmation message said:
patching file configure.in
So everything seems fine. But still Portaudio is trying to build for "ppc".
4) Now I set the ARCHFLAGS, CFLAGS, LDFLAGS to only build for architecture i386 as follows (disabling universal build):
$ MACOSX_DEPLOYMENT_TARGET="10.7" ARCHFLAGS="-arch i386" CFLAGS="-O2 -g -Wall -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk -arch i386 -mmacosx-version-min=10.7" LDFLAGS="-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sd -arch i386 -mmacosx-version-min=10.7" ./configure --disable-mac-universal
5) Further I found that:
A): "#include AudioToolbox.h" in ".include/pa_mac_core.h" should be UNCOMMENTED
B): that "-wError" from "Makefile" (not Makefile.in) should be removed.
accoding to:
http://www.fluxforge.com/blog/building-portaudio-under-os-x-107-lion
6) Now I try to build (using: "sudo make"), compilation starts but but fails with:
ld: framework not found CoreAudio
collect2: ld returned 1 exit status
make: * [lib/libportaudio.la] Error 1
7) So I try to point to the framework using "-F/System/Library/Frameworks -framework CoreAudio"
leading to the following Terminal command:
$ MACOSX_DEPLOYMENT_TARGET="10.7" ARCHFLAGS="-arch i386" CFLAGS="-O2 -g -Wall -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk -arch i386 -mmacosx-version-min=10.7" LDFLAGS="-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sd -arch i386 -mmacosx-version-min=10.7 -F/System/Library/Frameworks -framework CoreAudio" ./configure --disable-mac-universal
which seems to fix the CoreAudio framework issue but results in another error saying:
ld: library not found for -lSystem
collect2: ld returned 1 exit status
make: * [lib/libportaudio.la] Error 1
I am now stuck at this point. Did anyone experience the same problems when trying to build Portaudio on OSX 10.7 using SDK10.6 or SDK10.7. Did anyone find a solution to how to build Portaudio from Terminal?
I am very thankful for any hints!!!
Thanks in advance!
Try the latest svn. If that doesn't work right off the bat, you might need to muck with some of the flags.
eg, in configure.in:
change -Werror to -Wall
add -Wno-deprecated (you shouldn't need this, but just in case)
then run
./configure --disable-mac-universal
and make as usual.
OK, finally I solved the issue. Hope the solution will help others as well. I just forgot to also add the path to the CoreAudio framework to the CFLAGS. Here is the final configure/build command for building portaudio on OSX 10.7.5 using SDK10.7 for architecture i386 & x86_64:
Open a Terminal window in the portaudio directory and type:
MACOSX_DEPLOYMENT_TARGET="10.7" ARCHFLAGS="-arch i386" CFLAGS="-O2 -g -Wall -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk -arch i386 -mmacosx-version-min=10.7 -F/System/Library/Frameworks -framework CoreAudio" LDFLAGS="-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk -arch i386 -mmacosx-version-min=10.7 -F/System/Library/Frameworks -framework CoreAudio" ./configure --disable-mac-universal
If this has finished, you need to edit Makefile and change the mention of -Werror to -Wall.
Then:
make
Voila. There you have your "libportaudio.la" in the portaudio/lib directory. You can now type
sudo make install
(you'll be asked to confirm using your password)
to put the library in the system directory.
Finally you can mess around with Portaudio!
Have fun!
Tried your instructions on Mac OSX Mountain Lion (10.8), and it was progressing a lot in compilation but then was failing with:
In file included from ./test/patest_sine_channelmaps.c:53:
./include/pa_mac_core.h:100:1: error: unknown type name 'AudioDeviceID'
AudioDeviceID PaMacCore_GetStreamInputDevice( PaStream* s );
^
./include/pa_mac_core.h:109:1: error: unknown type name 'AudioDeviceID'
AudioDeviceID PaMacCore_GetStreamOutputDevice( PaStream* s );
^
2 errors generated.
make: *** [bin/patest_sine_channelmaps] Error 1
However, I figured out you can simply use Homebrew (apt-like packet manager for OSX) and it will do the dirty job like a charm. Find binaries and headers in the specified install directory :)
$ brew install portaudio
Warning: It appears you have MacPorts or Fink installed.
Software installed with other package managers causes known problems for
Homebrew. If a formula fails to build, uninstall MacPorts/Fink and try again.
==> Downloading http://www.portaudio.com/archives/pa_stable_v19_20111121.tgz
######################################################################## 100.0%
==> Downloading patches
######################################################################## 100.0%
==> Patching
patching file include/pa_mac_core.h
==> ./configure --prefix=/usr/local/Cellar/portaudio/19.20111121 --enable-mac-un
==> make install
/usr/local/Cellar/portaudio/19.20111121: 8 files, 316K, built in 20 seconds