Building Qt 5.6 on macOS for the Raspberry Pi 3 - macos

I am trying to set up a cross compiling environment for the Raspberry Pi 3 on my Mac because compiling on the Pi just became to slow.
Following this guide I successfully created a cross compiler using crosstool-ng that is able to compile a simple "Hello World" program that runs on the Pi.
I try to follow the RaspberryPi2EGLFS-Guide on the Qt wiki.
It is written for Ubuntu but that should not make a difference when you have a compiler for your host system, does it?
I created the sysroot and fixed symbolic links as described in the guide, but the configure command for Qt fails.
./configure \
-release \
-opensource -confirm-license \
-make libs \
-opengl es2 \
-device linux-rpi3-g++ \
-sysroot $SYSROOT \
-opensource -confirm-license -make libs \
-prefix /usr/local/qt5pi -extprefix ~/dev/raspi/qt5pi \
-hostprefix ~/dev/raspi/qt5 \
-device-option CROSS_COMPILE=$TOOLCHAIN \
-v
There, $TOOLCHAIN points to the toolchain I compiled and $SYSROOT is the sysroot I set up according to the guide.
But the command fails with a bunch of errors because header files could not be found:
fatal error: sys/cdefs.h: No such file or directory
fatal error: zconf.h: No such file or directory
fatal error: sys/types.h: No such file or directory
Edit 12-14-2016
Apparently the compiler can't determine the cpu architecture:
/Volumes/xtools/armv8-rpi3-linux-gnueabihf/lib/gcc/armv8-rpi3-linux-gnueabihf/5.2.0/../../../../armv8-rpi3-linux-gnueabihf/bin/ld.gold: error: /Volumes/xtools/armv8-rpi3-linux-gnueabihf/armv8-rpi3-linux-gnueabihf/sysroot/usr/lib/crti.o: unknown CPU architecture
From my (limited) understanding, these headers should apear somewhere in $SYSROOT.
I have checked my sysroot, the missing headers a located in $SYSROOT/usr/include/arm-arm-linux-gnueabihf/.
I created a symlink from there to $SYSROOT/sys but that did not work either.
Am I missing something?
Other threads suggest installing g++-multilib on the host system, but there is no multlib-equivalent on macOS.

Related

Can't build old libstdc++.so.6 (gcc-5 on arm-glibc-2.13) with version symbols included (leading to libstdc++.so.6: no version information available)

I need to run a dotnet5 app (or build dotnet5 from source) to be compatible with arm machines with very old glibc (as low as glibc-2.13, cannot be upgraded because these are semi-embedded systems).
The target machines come with libstdc++ based on gcc <5.1 and therefore don't support the necessary C++11 ABI.
First solution was to "just" get an arm-binary libstdc++.so.6.0.21 from somewhere and trying to run the app with it (via LD_LIBRARY_PATH). This almost worked, but this libstdc++ depended on glibc-2.16.
Next solution: build gcc >=5.1 (including libstdc++) from source in my debian-wheezy-armhf container, which is based on glibc-2.13.
This works quite well, though I have to force a few things because the gcc build process at some stages seems to believe it's cross-building (but not really?), getting errors like this: cannot find bits/predefs.h and hard- vs. soft-float errors. These were solved by doing the build like this (Makefile rule executed in build container):
C_INCLUDE_PATH=/usr/include:/usr/include/$$(gcc -print-multiarch); \
CPATH=/usr/include:/usr/include/$$(gcc -print-multiarch); \
LIBRARY_PATH=/usr/lib:/usr/lib/$$(gcc -print-multiarch); \
CFLAGS="-mfloat-abi=hard"; \
CXXFLAGS="-mfloat-abi=hard"; \
LDFLAGS="-mfloat-abi=hard"; \
export LIBRARY_PATH C_INCLUDE_PATH CPATH CFLAGS CXXFLAGS LDFLAGS; \
../gcc-5.5.0/configure --enable-languages=c,c++ --enable-shared=libgcc,libstdc++ `#--build=$$(gcc -print-multiarch)` --disable-multilib --disable-bootstrap --prefix=/build/install \
&& make -j24 && make install
... but the resulting libstdc++ doesn't contain version symbols:
> objdump -p .build/arm-glibc2.13/install/lib/libstdc++.so.6.0.21 | grep GLIBCXX
# nothing
/build/gcc-5.5.0-build/armv7l-unknown-linux-gnueabihf/libstdc++-v3/config.log shows:
configure:78121: WARNING: === You have requested GNU symbol versioning, but
configure:78123: WARNING: === you are not building a shared libgcc_s.
configure:78125: WARNING: === Symbol versioning will be disabled.
so that appears to be the reason. But why am I not building a shared libgcc_s? Even with --enable-shared=libgcc,libstdc++ (which is supposed to be the default anyway) it doesn't work...
Any ideas?

Spurious ld error on macOS (M1 processor)

I have a C project which uses libcairo. On my intel Mac, compiling Cairo with the attached script produces a x86_64 static library, which can be used without issue.
On a M1 Mac (Mac mini, though I doubt that's a factor), I've made sure to set -arch x86_64 everywhere (the output binary is used on Intel). Cairo builds successfully and produces a static library. When building a program that relies on it however, I get the following error message at link stage:
ld: warning: ignoring file (...)/lib/libcairo.a, building for macOS-x86_64 but attempting to link with file built for macOS-x86_64
Undefined symbols for architecture x86_64:
"_cairo_create", referenced from:
_av_display_new in libavionics.a(display.c.o)
(...)
I've made sure to set the CMAKE_OSX_ARCHITECTURES flag to x86_64 in CMake. I can replicate the problem by creating a dummy project in Xcode and building for x86_64. A dummy project using freetype2 (built using the same method), builds & run without errors. I'm at a bit of a loss here, given that the error message says that the architectures don't match (and yet are both macOS-x86_64.
lipo -info libcairo.a returns Non-fat file: libcairo.a is architecture: x86_64.
My Cairo build script is the following:
CAIRO_CONFOPTS_COMMON="--enable-static --disable-egl --disable-glesv2 \
--disable-glesv3 --disable-glx --disable-gl --disable-valgrind \
--disable-xlib --enable-ft --disable-shared --disable-xlib-xrender \
--disable-xcb --disable-svg --disable-full-testing --disable-interpreter \
--disable-gallium --disable-beos --disable-cogl --disable-directfb \
--disable-fc --disable-ps --disable-glesv2 --disable-win32 \
--disable-win32-font --disable-drm --disable-png --disable-script --disable-quartz \
--disable-wgl --disable-gobject --disable-trace --disable-symbol-lookup --disable-zlib"
ARCH_FLAGS="-arch\\ x86_64\\ -mmacosx-version-min=10.9"
export GNUMAKEFLAGS=--no-print-directory
cd cairo
# Make sure we use the libraries we built, and not the system ones
export pixman_CFLAGS="-I$OUTDIR/include/pixman-1"
export pixman_LIBS="$OUTDIR/lib/libpixman-1.a"
export FREETYPE_CFLAGS="-I$OUTDIR/include/freetype2"
export FREETYPE_LIBS="$OUTDIR/lib/libfreetype.a"
export PKG_CONFIG_PATH="$OUTDIR/lib/pkgconfig"
eval LDFAGS="-fvisibility=hidden\\ $ARCH_FLAGS" \
CFLAGS="-fvisibility=hidden\\ $ARCH_FLAGS" \
CXXFLAGS="-fvisibility=hidden\\ $ARCH_FLAGS" \
./configure --prefix=$OUTDIR $CAIRO_CONFOPTS_COMMON $ADDCONF || exit 1
make -j9 || exit 1
make install || exit 1

'make install' failed after 'make' KiCad on OS X 10.10

i'm trying to install kicad on osx 10.10. After successfully build make, failed
make install at
-- fixup_bundle
-- app='/Users/bolor/Downloads/KiCad/bin/eeschema.app/Contents/MacOS/eeschema'
-- libs=''
-- dirs=''
-- fixup_bundle: preparing...
-- warning: embedded item does not exist '/Users/bolor/Downloads/KiCad/bin/eeschema.app/Contents/MacOS/libboost_chrono-mt.dylib'
--
warning: cannot resolve item '#loader_path/libboost_chrono-mt.dylib'
possible problems:
need more directories?
need to use InstallRequiredSystemLibraries?
run in install tree instead of build tree?
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/otool: can't open file: #loader_path/libboost_chrono-mt.dylib (No such file or directory)
CMake was configured like below:
cmake ../kicad \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ \
-DCMAKE_OSX_DEPLOYMENT_TARGET=10.10 \
-DwxWidgets_CONFIG_EXECUTABLE=../wx-bin/bin/wx-config \
-DKICAD_SCRIPTING=OFF \
-DKICAD_SCRIPTING_MODULES=OFF \
-DKICAD_SCRIPTING_WXPYTHON=OFF \
-DCMAKE_INSTALL_PREFIX=../bin \
-DCMAKE_BUILD_TYPE=Release \
-DKICAD_SKIP_BOOST=ON \
-DCMAKE_OSX_SYSROOT=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk
does anyone know how to solve this?
thanks!
i have saved all the build log in a txt file and put on dropbox readable
here
I am pretty sure that's a bug in kicad's CMake script.
Other have the same problem, see https://gist.github.com/rhaamo/497d3c94929b69874411
In
http://www.mikrocontroller.net/topic/380428
they say it either works with -DKICAD_SKIP_BOOST=ON or with letting kicad build its own Boost library.

Cross-compiling static QEMU for Windows

I've been trying to compile a static QEMU executable for Windows on a Debian box, and ran into some problems. (I'm using this guide as a reference.)
When I compile without the static flag everything works but when I compile using the static flag I get the following error during the call to configure:
ERROR: zlib check failed
Make sure to have the zlib libs and headers installed.
This is the command line:
WORK=/media/Work/qemu
cd $WORK/build/w32
(export PKG_CONFIG_PATH=$WORK/install/w32/lib/pkgconfig ;
export PKG_CONFIG_PREFIX=$WORK/install/w32 ;
#export BASH_X=-x ;
bash $BASH_X ../../qemu.git/configure --target-list="i386-softmmu" \
--cross-prefix=i686-w64-mingw32- \
--extra-ldflags="-L$WORK/install/w32/lib" \
--extra-cflags="-I$WORK/install/w32/include" \
--static \
)
You can disable the zlib test using the command line input
./configure --disable-zlib-test
Zlib will be needed to build qemu, but it will not test for the library during configure. If the library is available in the proper location during build process, you can try the above command to proceed.

Dylib ok at link time but not at runtime

I have a problem linking correctly my project. The project is built with CMAKE. Linking seems fine, but at run time an error is thrown.
Here is the command that was used for linking:
$ /usr/bin/clang -Wl,-search_paths_first -Wl,-headerpad_max_install_names \
CMakeFiles/project.dir/src/conf.c.o CMakeFiles/project.dir/src/tun-compat.c.o \
CMakeFiles/project.dir/src/compress.c.o CMakeFiles/project.dir/src/mc.c.o \
CMakeFiles/project.dir/src/hexdump.c.o CMakeFiles/project.dir/src/server.c.o \
CMakeFiles/project.dir/sys/unix/log.c.o CMakeFiles/project.dir/sys/unix/imsg.c.o \
CMakeFiles/project.dir/ sys/unix/imsg-buffer.c.o CMakeFiles/project.dir/sys/unix/toto.c.o \
CMakeFiles/project.dir/sys/unix/toto.c.o CMakeFiles/project.dir/sys/unix/util.c.o \
CMakeFiles/project.dir/sys/unix/conf.c.o CMakeFiles/project.dir/sys/unix/tntsocket.c.o \
-o bin/project/opt/local/lib/libevent_openssl.dylib /opt/local/lib/libevent_core.dylib \
/usr/lib/libz.dylib /opt/local/lib/libyajl.dylib /opt/local/lib/libtapcfg.dylib
The error I get:
$ ./bin/project
dyld: Library not loaded: build/libtapcfg.dylib
Referenced from: /Users/Antoine/project/./bin/project
Reason: image not found
zsh: trace trap ./bin/project
Additional infos:
$ dyldinfo -dylibs bin/projectattributes
dependent dylibs
/opt/local/lib/libevent_openssl-2.0.5.dylib
/opt/local/lib/libevent_core-2.0.5.dylib
/usr/lib/libz.1.dylib
/opt/local/lib/libyajl.2.dylib
build/libtapcfg.dylib
/usr/lib/libSystem.B.dylib
It looks like black magic to me. The linker is able to find the symbols, but end up by changing the path of the library even if I can't see any difference in the way it is handled in the linking command...
The lib location is /opt/local/lib/libtapcfg.dylib
$ ls -lhF /opt/local/lib/libtapcfg.dylib
-rwxr-xr-x 1 root admin 20K 14 jui 18:05 /opt/local/lib/libtapcfg.dylib*
Does the problem maybe come from the lib I am linking to?
The issue is with how you built and installed libtapcfg.
You seem to have copied it from your local directory to /opt/local/lib and thus its file system path does not match what is stored in the library.
Either leave the lib in your local path or when building it tell the linker where it will end up or copy to /usr/local/lib which is hard coded in the linker. See Apple developer's note on dynamic libraries
You should only put things in /opt/local when using macports by means of a port. In this case create a local portfile which does not have to do much and macports standard work will put the correct information in the library to make it work from /opt/local/lib

Resources