Posted by
xanderdin on
Sep 07, 2019; 11:28am
URL: https://forum.librecad.org/Help-wanted-to-build-on-MacOS-tp5717273p5717717.html
I've got successful build on MacOS 10.14. But because I do not own a real Mac I've done it in the cloud. I'm not familiar with MacOS specifics and what I got is a result of number of trials and errors. First, I tried to build with default clang compiler and the build always failed with an error. Then I tried to build with gcc but qmake tried hard to disallow me that. I tried linking installed gcc tools to /usr/local/bin, ~/bin, played with PATH and other environment variables, but every time qmake was giving me the following error:
Project ERROR: failed to parse default search paths from compiler output
Looking into .qmake.stash file showed me that despite anything I did to use gcc, qmake always used the same path down below Xcode directory:
...
QMAKE_MAC_SDK.macx-g++.macosx.QMAKE_CC = /Applications/Xcode_10.2.1.app/Contents/Developer/usr/bin/gcc
QMAKE_MAC_SDK.macx-g++.macosx.QMAKE_CXX = /Applications/Xcode_10.2.1.app/Contents/Developer/usr/bin/g++
...
And that 'gcc' when run with --version occured to be clang:
Apple LLVM version 10.0.1 (clang-1001.0.46.4)
So I forced and made a real gcc to be at that location and finally got a result. I cannot recommend my approach for a personal computer but it is safe in the cloud where for each build there is a new fresh virtual machine image.
My steps include installation of dependencies:
brew install \
boost@1.60 \
gcc@9 \
qt5
brew link qt5 --force
Forcing real 'gcc' to be inside Xcode directory:
sudo xcode-select -s /Applications/Xcode_10.2.1.app/Contents/Developer
sudo ln -f -s /usr/local/bin/gcc-9 /Applications/Xcode_10.2.1.app/Contents/Developer/usr/bin/gcc
sudo ln -f -s /usr/local/bin/gcc-9 /Applications/Xcode_10.2.1.app/Contents/Developer/usr/bin/cc
sudo ln -f -s /usr/local/bin/g++-9 /Applications/Xcode_10.2.1.app/Contents/Developer/usr/bin/g++
sudo ln -f -s /usr/local/bin/g++-9 /Applications/Xcode_10.2.1.app/Contents/Developer/usr/bin/c++
sudo ln -f -s /usr/local/bin/gcc-ar-9 /Applications/Xcode_10.2.1.app/Contents/Developer/usr/bin/ar
sudo ln -f -s /usr/local/bin/gcc-nm-9 /Applications/Xcode_10.2.1.app/Contents/Developer/usr/bin/nm
sudo ln -f -s /usr/local/bin/gcc-ranlib-9 /Applications/Xcode_10.2.1.app/Contents/Developer/usr/bin/ranlib
Inside cloned LibreCAD directory I do the following:
echo "BOOST_DIR = /usr/local/opt/boost@1.60/" >> ./librecad/src/custom.pro
echo "BOOST_LIBDIR = /usr/local/opt/boost@1.60/" >> ./librecad/src/custom.pro
echo "QT_CONFIG -= no-pkg-config" >> ./librecad/src/custom.pro
./scripts/build-osx.sh -q="-spec macx-g++"
And everything builds OK resulting in LibreCAD.dmg file.
If you are interested in all my trial and errors (for MacOS, Windows and Linux) please see git history of my commits here:
https://github.com/xanderdin/LibreCAD/commits/play_with_azureAnd resulting cloud builds with logs are available here:
https://dev.azure.com/xanderdin/PlayWithAzure/_build?definitionId=1&_a=summary Please note, the build history and logs are available for no more than 30 days and then will be automatically deleted by cloud provider.
Hope my build experience is helpful.