Compiling on Mac ... problem with the prerequisites with homebrew

Having trouble installing or compiling FreeCAD? Get help here.
nyholku
Posts: 149
Joined: Wed Dec 28, 2016 4:18 pm

Re: Compiling on Mac ... problem with the prerequisites with homebrew

Postby nyholku » Sat Dec 31, 2016 10:19 am

Update:

If I set:

Code: Select all

-DFREECAD_USE_EXTERNAL_SMESH="1" 
then the compilation proceeds for some files and then fails with:

Code: Select all

make
[  0%] Generating moc_Debugger.cpp
[  0%] Generating moc_FutureWatcherProgress.cpp
Scanning dependencies of target FreeCADBase
[  0%] Building C object src/Base/CMakeFiles/FreeCADBase.dir/__/CXX/cxxextensions.c.o
[  0%] Building CXX object src/Base/CMakeFiles/FreeCADBase.dir/__/CXX/cxx_extensions.cxx.o
[  0%] Building CXX object src/Base/CMakeFiles/FreeCADBase.dir/__/CXX/cxxsupport.cxx.o
[  0%] Building CXX object src/Base/CMakeFiles/FreeCADBase.dir/__/CXX/IndirectPythonInterface.cxx.o
[  0%] Building CXX object src/Base/CMakeFiles/FreeCADBase.dir/Axis.cpp.o
[  0%] Building CXX object src/Base/CMakeFiles/FreeCADBase.dir/AxisPyImp.cpp.o
In file included from /Users/nyholku/FreeCAD/FreeCAD-git/src/Base/AxisPyImp.cpp:30:
In file included from /Users/nyholku/FreeCAD/build/src/Base/AxisPy.cpp:6:
/usr/local/include/boost/filesystem/path.hpp:157:55: error: no member named 'move' in namespace 'std'
    path(path&& p) BOOST_NOEXCEPT { m_pathname = std::move(p.m_pathname); }
                                                 ~~~~~^
/usr/local/include/boost/filesystem/path.hpp:159:27: error: no member named 'move' in namespace 'std'
      { m_pathname = std::move(p.m_pathname); return *this; }
                     ~~~~~^
In file included from /Users/nyholku/FreeCAD/FreeCAD-git/src/Base/AxisPyImp.cpp:30:
In file included from /Users/nyholku/FreeCAD/build/src/Base/AxisPy.cpp:7:
/usr/local/include/boost/filesystem/operations.hpp:281:22: error: no member named 'move' in namespace 'std'
      m_value = std::move(rhs.m_value);
Interesting, no std::move ...
nyholku
Posts: 149
Joined: Wed Dec 28, 2016 4:18 pm

Re: Compiling on Mac ... problem with the prerequisites with homebrew

Postby nyholku » Sat Dec 31, 2016 11:27 am

Progress update:

I set:

Code: Select all

export MACOSX_DEPLOYMENT_TARGET=10.11
I don't think the code will run on 10.10 but this is just to rehearse the compilation problems.

And now the compilation progresses nicely (with a lot of virtual function override warnings but I
guess they are benign) until:

Code: Select all

[ 63%] Building CXX object src/Mod/MeshPart/App/CMakeFiles/MeshPart.dir/CurveProjector.cpp.o
[ 63%] Building CXX object src/Mod/MeshPart/App/CMakeFiles/MeshPart.dir/MeshAlgos.cpp.o
[ 63%] Building CXX object src/Mod/MeshPart/App/CMakeFiles/MeshPart.dir/Mesher.cpp.o
/Users/nyholku/FreeCAD/FreeCAD-git/src/Mod/MeshPart/App/Mesher.cpp:41:10: fatal error: 'SMESH_Gen.hxx' file not found
#include <SMESH_Gen.hxx>
I guess I will next try without `-DFREECAD_USE_EXTERNAL_SMESH="1"`
nyholku
Posts: 149
Joined: Wed Dec 28, 2016 4:18 pm

Re: Compiling on Mac ... problem with the prerequisites with homebrew

Postby nyholku » Sat Dec 31, 2016 12:42 pm

Moderate success I think!

With '-DFREECAD_USE_EXTERNAL_SMESH="0"' the build completed and when I double click on the 'bin/FreeCAD' the FreeCAD window appears and seems to work and on the terminal I can see:

Code: Select all

Last login: Thu Dec 29 19:28:58 on ttys003
nyholkus-MBP-5:~ nyholku$ /Users/nyholku/FreeCAD/build/bin/FreeCAD ; exit;
FreeCAD 0.17, Libs: 0.17R9422 (Git)
© Juergen Riegel, Werner Mayer, Yorik van Havre 2001-2016
  #####                 ####  ###   ####  
  #                    #      # #   #   # 
  #     ##  #### ####  #     #   #  #   # 
  ####  # # #  # #  #  #     #####  #   # 
  #     #   #### ####  #    #     # #   # 
  #     #   #    #     #    #     # #   #  ##  ##  ##
  #     #   #### ####   ### #     # ####   ##  ##  ##

During initialization the error No module named PySide occurred in /Users/nyholku/FreeCAD/build/Mod/Ship/InitGui.py
During initialization the error No module named PySide occurred in /Users/nyholku/FreeCAD/build/Mod/Plot/InitGui.py
During initialization the error No module named PySide occurred in /Users/nyholku/FreeCAD/build/Mod/Draft/InitGui.py
During initialization the error No module named PySide occurred in /Users/nyholku/FreeCAD/build/Mod/Arch/InitGui.py
No module named PySide
Coin warning in cc_glglue_instance(): Error when setting up the GL context. This can happen if there is no current context, or if the context has been set up incorrectly.
Failed to import BOPTools package:
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/nyholku/FreeCAD/build/Mod/Part/BOPTools/__init__.py", line 47, in importAll
    from . import JoinFeatures
  File "/Users/nyholku/FreeCAD/build/Mod/Part/BOPTools/JoinFeatures.py", line 35, in <module>
    from PySide import QtCore, QtGui
<type 'exceptions.ImportError'>: No module named PySide
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/nyholku/FreeCAD/build/Mod/Part/AttachmentEditor/Commands.py", line 27, in <module>
    from PySide import QtCore
<type 'exceptions.ImportError'>: No module named PySide
Unknown command 'Sketcher_ProfilesHexagon1'
2016-12-31 12:35:17.534 FreeCAD[10487:1760044] modalSession has been exited prematurely - check for a reentrant call to endModalSession:

I guess the PySide thing maybe related to -DFREECAD_USE_EXTERNAL_PIVY="1", don't know, will investigate, maybe I don't need that for my needs.

Interesting that while I was targeting Macos 10.11 it works on 10.10 too. Great.
nyholku
Posts: 149
Joined: Wed Dec 28, 2016 4:18 pm

Re: Compiling on Mac ... problem with the prerequisites with homebrew

Postby nyholku » Sat Dec 31, 2016 12:59 pm

To recap for posterity what we have learned.

My installation:

Xcode 7.2.1
Macos 10.10.5
homebrew 1.1.5
CMake stable 3.7.1

To install the prerequisites I think that at the end all that was needed was:

Code: Select all

brew tap homebrew/science
brew tap freecad/freecad
brew install --only-dependencies freecad --with-freecad-bottles
To get it compile it was necessary to set from the Terminal bash command line:

Code: Select all

export MACOSX_DEPLOYMENT_TARGET=10.11
Apparently Xcode 7.2.1 does not support targeting Macos 10.10 (Yosemite) out of the box and since I'm on
10.10 this gets detected and the deployment target is set to the unsupported
target. Fortunately it looks like targeting 10.11 is good enough to run the resulting binaries in 10.10.

I then emptied my build directory and configured FreeCAD with CMake like this:

Code: Select all

cmake -DBUILD_FEM_NETGEN="1"  -DFREECAD_CREATE_MAC_APP="1" ../FreeCAD-git
and was able to perform a successful compilation and FreeCAD starts and seems to run!!


I do get a warning in the terminal about PySide:

Code: Select all

During initialization the error No module named PySide occurred in /Users/nyholku/FreeCAD/build/Mod/Ship/InitGui.py
but I'm pretty happy with the progress so far:

That is it, I hope this helps someone.

PS

What a mess the world of C/C++ tool chain is ... always, always such a mess to get any non-trivial cross platform project to compile on all platforms despite of the best efforts of developers and community. And no cure in sight.

PPS

A fair warning: I did initially go through installing manually all the prerequisites listed
in the (outdated) wiki page:

http://www.freecadweb.org/wiki/?title=CompileOnMac

So here is a complete list of what I have installed with homebrew on my machine:

Code: Select all

brew list --versions
arpack 3.4.0
bison 3.0.4
boost 1.63.0
boost-python 1.63.0
ccache 3.3.3
cmake 3.7.0 3.7.1
coin 3.1.3
colordiff 1.0.16
curl 7.51.0
dirmngr 1.1.1_2
dos2unix 7.3.4
eigen 3.3.1
eigen32 3.2.10
epstool 3.08
fftw 3.3.5
fltk 1.3.4
fontconfig 2.12.1_2
freeimage 3.17.0
freetype 2.7
ftgl 2.1.3-rc5
gawk 4.1.4_1
gcc 6.2.0
gd 2.2.3_1
gdbm 1.12
ghostscript 9.19
gl2ps 1.3.9_2
glpk 4.60
gmp 6.1.1
gnu-sed 4.2.2
gnupg2 2.0.30_2
gnuplot 5.0.5
gpg-agent 2.0.30_1
gradle 3.2.1
graphicsmagick 1.3.25
hdf5 1.8.17 1.8.18
imagemagick 6.9.6-8
isl 0.17.1
jpeg 8d
libassuan 2.4.3_1
libgcrypt 1.7.5
libgpg-error 1.26
libksba 1.3.5
libmpc 1.0.3
libpng 1.6.26 1.6.27
libtiff 4.0.7
libtool 2.4.6_1
libusb 1.0.20
libusb-compat 0.1.5
little-cms2 2.8
lua 5.2.4_4
lzip 1.18
matplotlib 1.5.1
maven 3.3.9
med-file 3.2.0
mercurial 4.0.1
metis 5.1.0
mpfr 3.1.5
nglib 5.3.1
numpy 1.11.2
oce 0.17.2_1
opencascade 7.0.0
openssl 1.0.2j
orocos-kdl 1.3.0_1
p7zip 16.02
pcre 8.39
pinentry 0.9.7
pivy HEAD-8eab90908f2a
pkg-config 0.29.1_2
plotutils 2.6_1
pstoedit 3.70_1
pth 2.0.7
pyqt5 5.7
pyside 1.2.2_1
pyside-tools 0.2.15
python 2.7.13 HEAD
python3 3.5.2_3
qhull 2015.2
qrupdate 1.1.2_4
qscintilla2 2.9.3_3
qt 4.8.7_2
qt5 5.7.0
readline 7.0.1
rpm2cpio 1.3
shiboken 1.2.2
sip 4.18.1
sqlite 3.15.2
suite-sparse 4.5.3
swig 3.0.10_1
szip 2.1
tbb 4.4-20161004 4.4-20161128
texinfo 6.3
transfig 3.2.5e
veclibfort 0.4.2_3
vtk 7.1.0_1
webp 0.5.1
xerces-c 3.1.4
xz 5.2.2
Last edited by nyholku on Sun Jan 01, 2017 5:16 pm, edited 1 time in total.
peterl94
Posts: 1000
Joined: Thu May 23, 2013 7:31 pm
Location: United States

Re: Compiling on Mac ... problem with the prerequisites with homebrew

Postby peterl94 » Sat Dec 31, 2016 6:30 pm

I wonder if it somehow linked the system python instead of the homebrew one. Can you open freecad and enter the following lines in the python console? Post the output here. Additionally can you post your CMakeCache.txt (located inside the build folder)?

Code: Select all

import sys
for p in sys.path: print p
nyholku
Posts: 149
Joined: Wed Dec 28, 2016 4:18 pm

Re: Compiling on Mac ... problem with the prerequisites with homebrew

Postby nyholku » Sun Jan 01, 2017 10:53 am

Happy New Year!

Here you go, output from Python console below and CMakeCache.txt attached.

Code: Select all

Python 2.7.13 (default, Dec 18 2016, 07:03:34) 
[GCC 4.2.1 Compatible Apple LLVM 7.0.2 (clang-700.1.81)] on darwin
Type 'help', 'copyright', 'credits' or 'license' for more information.
>>> import WebGui
>>> from StartPage import StartPage
>>> import sys
>>> for p in sys.path: print p
... 
/Users/nyholku/FreeCAD/build/Mod
/Users/nyholku/FreeCAD/build/lib64
/Users/nyholku/FreeCAD/build/lib
/Users/nyholku/FreeCAD/build/Mod/Drawing
/Users/nyholku/FreeCAD/build/Mod/Inspection
/Users/nyholku/FreeCAD/build/Mod/Idf
/Users/nyholku/FreeCAD/build/Mod/Part
/Users/nyholku/FreeCAD/build/Mod/Robot
/Users/nyholku/FreeCAD/build/Mod/Arch
/Users/nyholku/FreeCAD/build/Mod/Path
/Users/nyholku/FreeCAD/build/Mod/.DS_Store
/Users/nyholku/FreeCAD/build/Mod/Mesh
/Users/nyholku/FreeCAD/build/Mod/Raytracing
/Users/nyholku/FreeCAD/build/Mod/Material
/Users/nyholku/FreeCAD/build/Mod/Web
/Users/nyholku/FreeCAD/build/Mod/Complete
/Users/nyholku/FreeCAD/build/Mod/TechDraw
/Users/nyholku/FreeCAD/build/Mod/Import
/Users/nyholku/FreeCAD/build/Mod/Test
/Users/nyholku/FreeCAD/build/Mod/Draft
/Users/nyholku/FreeCAD/build/Mod/Points
/Users/nyholku/FreeCAD/build/Mod/Start
/Users/nyholku/FreeCAD/build/Mod/Spreadsheet
/Users/nyholku/FreeCAD/build/Mod/Fem
/Users/nyholku/FreeCAD/build/Mod/OpenSCAD
/Users/nyholku/FreeCAD/build/Mod/MeshPart
/Users/nyholku/FreeCAD/build/Mod/Plot
/Users/nyholku/FreeCAD/build/Mod/Ship
/Users/nyholku/FreeCAD/build/Mod/Measure
/Users/nyholku/FreeCAD/build/Mod/PartDesign
/Users/nyholku/FreeCAD/build/Mod/Image
/Users/nyholku/FreeCAD/build/Mod/Show
/Users/nyholku/FreeCAD/build/Mod/ReverseEngineering
/Users/nyholku/FreeCAD/build/Mod/Sketcher
/Users/nyholku/FreeCAD/build/bin
/Users/nyholku
/usr/local/opt/python/Frameworks/Python.framework/Versions/2.7/lib/python27.zip
/usr/local/opt/python/Frameworks/Python.framework/Versions/2.7/lib/python2.7
/usr/local/opt/python/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin
/usr/local/opt/python/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac
/usr/local/opt/python/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages
/usr/local/opt/python/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk
/usr/local/opt/python/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old
/usr/local/opt/python/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload

/Users/nyholku/FreeCAD/build/Macro
/Users/nyholku/Library/Application Support/FreeCAD/Mod
>>> 
Attachments
CMakeCache.txt
(102.71 KiB) Downloaded 39 times
blacey
Posts: 370
Joined: Tue Dec 08, 2015 11:28 pm

Re: Compiling on Mac ... problem with the prerequisites with homebrew

Postby blacey » Thu Jan 12, 2017 5:13 am

nyholku wrote:To recap for posterity what we have learned.

My installation:

Xcode 7.2.1
Macos 10.10.5
homebrew 1.1.5
CMake stable 3.7.1
@nyholku, FYI, we build FreeCAD on 10.10 targeting 10.10 using Xcode 6.4 on Travis CI. I also have a 10.10 VM with Xcode 6.4 that I use to mimic the Travis system and am also able to build reliably on 10.10. Here is the output of [urlhttps://travis-ci.org/FreeCAD/FreeCAD/jobs/191082062#L784-L806]brew config from the latest FreeCAD build on Travis[/url]

Code: Select all

HOMEBREW_VERSION: 1.1.7
ORIGIN: https://github.com/Homebrew/brew
HEAD: 9cce3414fbd39d146d97911dbb3bf07fffaa1080
Last commit: 2 days ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: dfb64ee434b94456e21a74704fdbb5ac8aaf9db0
Core tap last commit: 3 hours ago
HOMEBREW_PREFIX: /usr/local
HOMEBREW_REPOSITORY: /usr/local/Homebrew
HOMEBREW_CELLAR: /usr/local/Cellar
HOMEBREW_BOTTLE_DOMAIN: https://homebrew.bintray.com
CPU: dual-core 64-bit nehalem
Homebrew Ruby: 2.0.0-p481
Clang: 6.1 build 602
Git: 2.3.2 => /Applications/Xcode.app/Contents/Developer/usr/bin/git
Perl: /usr/bin/perl
Python: /usr/local/bin/python => /usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/bin/python2.7
Ruby: /Users/travis/.rvm/rubies/ruby-2.0.0-p643/bin/ruby
Java: 1.8.0_45
macOS: 10.10.5-x86_64
Xcode: 6.4
CLT: 7.2.0.0.1.1447826929
Bottom-line, you should be able to target 10.10 if you use Xcode 6.4 instead of 7.2. If you really want to use Xcode 7.2, you can copy the 10.10 SDK from the Xcode 6.4 disk image available for download on developer.apple.com but I recommend that you use the same config that we use on Travis.

Also, you can download the latest builds, that will run on 10.10+, from the GitHub Releases area

@peterl94 and anyone else building on Sierra, nglib has been fixed to build and install properly on El Capitan and Sierra.
nyholku
Posts: 149
Joined: Wed Dec 28, 2016 4:18 pm

Re: Compiling on Mac ... problem with the prerequisites with homebrew

Postby nyholku » Sun Jan 15, 2017 8:31 am

Hi blacey,

thanks for looking at this thread and commenting.

I did not mention that I had previously tried copying the SDK to XCode 7.2 and it did NOT work for me.

I put it here:

Code: Select all

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk
Maybe this is wrong.

But with deployment target 10.11 the code compiles and seems to work. I have not found any problem in using FreeCAD (at least I can use the Part Design and Sketcher work benches.

I do get these errors at start up, but like I said it does not seem to matter:

Code: Select all

During initialization the error dlopen(/Applications/FreeCAD.app/Contents/lib/Part.so, 2): Symbol not found: __ZN5boost16re_detail_10600012perl_matcherIPKcNSt3__19allocatorINS_9sub_matchIS3_EEEENS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEE14construct_initERKNS_11basic_regexIcSC_EENS_15regex_constants12_match_flagsE
  Referenced from: /Applications/FreeCAD.app/Contents/lib//libFreeCADBase.dylib
  Expected in: /usr/local/opt/boost/lib/libboost_regex-mt.dylib
 in /Applications/FreeCAD.app/Contents/lib//libFreeCADBase.dylib occurred in /Users/nyholku/Library/Preferences/FreeCAD/Mod/cloud9/Init.py
During initialization the error No module named PySide occurred in /Users/nyholku/FreeCAD/build/Mod/Ship/InitGui.py
During initialization the error No module named PySide occurred in /Users/nyholku/FreeCAD/build/Mod/Plot/InitGui.py
Hello from ~/Library/PreferencesFreeCAD/Mod/cloud9/InitGUI.py TEST1
During initialization the error No module named PySide occurred in /Users/nyholku/FreeCAD/build/Mod/Draft/InitGui.py
During initialization the error No module named PySide occurred in /Users/nyholku/FreeCAD/build/Mod/Arch/InitGui.py
No module named PySide
Coin warning in cc_glglue_instance(): Error when setting up the GL context. This can happen if there is no current context, or if the context has been set up incorrectly.
Failed to import BOPTools package:
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/nyholku/FreeCAD/build/Mod/Part/BOPTools/__init__.py", line 47, in importAll
    from . import JoinFeatures
  File "/Users/nyholku/FreeCAD/build/Mod/Part/BOPTools/JoinFeatures.py", line 35, in <module>
    from PySide import QtCore, QtGui
<type 'exceptions.ImportError'>: No module named PySide
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/nyholku/FreeCAD/build/Mod/Part/AttachmentEditor/Commands.py", line 27, in <module>
    from PySide import QtCore
<type 'exceptions.ImportError'>: No module named PySide
Can't find Origin for "Body"
Can't find Origin for "Body"
Can't find Origin for "Body001"
Can't find Origin for "Body001"
cheers Kusti


PS

<off-topic-ran>

Since I last tried building this a few weeks ago my environment had rotted and CMake could not find Qt4.This was because I had used miniconda3 to install Qt5 in order to try the pythonocc. Removing miniconda3 solved the issue but all this package management and fighting the C/C++ toolchain is so frustrating.

Nobody's fault but it seem so be beyond repair.

Don't know if this is my C/C++ skill set that is lacking or what but this so frustrating wasting time in just getting things to compile and waiting for the compile to finish. And the next time I come back to a project it is broken again. Most of my stuff is done with Java and I never ever have these issues, just include all the .jars I need in my project and I'm done (and I mean done, like I never see any compilation, it happens so fast that I don't notice it, my FreeCAD make from scratch took 19min32sec on 2.6GHz i7 8GB 512 GB SSD MacBook Pro).

</off-topic-rant>
blacey
Posts: 370
Joined: Tue Dec 08, 2015 11:28 pm

Re: Compiling on Mac ... problem with the prerequisites with homebrew

Postby blacey » Sun Jan 15, 2017 3:02 pm

@nyholku,

A few things:

1) From your error messages, it seems that PySide is no longer available to your FreeCAD build. You should try running

Code: Select all

brew install --only-dependencies FreeCAD/freecad/freecad
again to ensure all the dependencies are still installed. If you want to wipe your freecad dependencies and start over, you can try

Code: Select all

brew deps FreeCAD/freecad/freecad | xargs brew uninstall --ignore-dependencies
Then simply re-install the dependencies using the freecad formula above. NOTE: for some reason, homebrew doesn't always install all dependencies so I usually run brew install twice until brew tells me that all dependencies have been satisfied.
2) If you have ccache installed, subsequent compiles will take much less time.
3) Unless you are doing development, you might find it much easier to simply download the builds from the GItHub releases. Everytime a pull request is merge or one of the devs commits to master, Travis CI builds for Linux, Windows and macOS and deploys a disk image with the latest build to GitHub. The images include the last commit SHA and you will see that they are as current as building it yourself.

Cheers,
Bruce
Last edited by blacey on Sun Jan 15, 2017 3:44 pm, edited 1 time in total.
nyholku
Posts: 149
Joined: Wed Dec 28, 2016 4:18 pm

Re: Compiling on Mac ... problem with the prerequisites with homebrew

Postby nyholku » Sun Jan 15, 2017 3:07 pm

Hi Bruce,

thanks for the tips. I will try them and report back.

Yeah, I'm building from source cause I hope to be able to do some development and contribute. I certainly don't compile C/C++ stuff just for fun ;)

wbr Kusti