Mac Compile Help

Having trouble installing or compiling FreeCAD? Get help here.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
peterl94
Veteran
Posts: 1001
Joined: Thu May 23, 2013 7:31 pm
Location: United States

Re: Mac Compile Help

Post by peterl94 »

Hi jamesl73,

I've been atempting a mac build too and had the same problem. I solved it by setting LIBRARY_PATH environment variable to the path of the gfortran library. I'm sure there is a cmake variable that would have the same effect, but I didn't take the time to find out.
jamesl73
Posts: 20
Joined: Sun Jun 23, 2013 10:07 pm

Re: Mac Compile Help

Post by jamesl73 »

I set the LIBRARY_PATH (to the library, libgfortran.a, instead of the executable) and got to the next error.
[ 0%] Built target coin
[ 1%] Built target soqt
[ 1%] Built target Driver
[ 2%] Built target SMDS
[ 2%] Built target DriverDAT
[ 3%] Built target DriverSTL
[ 4%] Built target SMESHDS
[ 4%] Built target DriverUNV
Linking CXX shared library ../../../lib/MEFISTO2.so
Undefined symbols for architecture x86_64:
"_aisoar_", referenced from:
aptrte(long, double, long, long*, R2*, long, R2*, long&, R2*&, long&, long*&, long&) in aptrte.cpp.o
"_azeroi_", referenced from:
aptrte(long, double, long, long*, R2*, long, R2*, long&, R2*&, long&, long*&, long&) in aptrte.cpp.o
"_fasoar_", referenced from:
aptrte(long, double, long,
Did you succeed in compiling on Mac?
peterl94
Veteran
Posts: 1001
Joined: Thu May 23, 2013 7:31 pm
Location: United States

Re: Mac Compile Help

Post by peterl94 »

I had that error too... I discovered it was because the fortran code wasn't being built and linked to the c++ code, which was caused by a if statement in the main CMakeLists.txt.

Code: Select all

# Needed for salomesmesh
if(CMAKE_COMPILER_IS_GNUCXX)
ENABLE_LANGUAGE(Fortran)
endif(CMAKE_COMPILER_IS_GNUCXX)
So if you are using the defualt compiler on a mac (Apple's clang), the fortran stuff won't get enabled. I tried just removeing the if statment so I could use clang, but it failed with other errors, so you will have to use GCC instead.

And yes, I eventually did get it to compile ;) (I think that was the last compiler error I had)
jamesl73
Posts: 20
Joined: Sun Jun 23, 2013 10:07 pm

Re: Mac Compile Help

Post by jamesl73 »

Could you provide some more detailed step by step instructions on your successful compile? Would you share your compile with the rest of us?

I tried setting compiler to gcc by setting these enviroment variables
declare -x CC="gcc"
declare -x CPP="gcc"
declare -x CXX="gcc"
but didnt get too far in the compile
Linking CXX shared library ../../../bin/pivy/_coin.so
Undefined symbols for architecture x86_64:
"std::terminate()", referenced from:
__wrap_SoVRMLFontStyle_getFontName in coin_wrap.cpp.o
__wrap_SoInput_getHeader in coin_wrap.cpp.o
__wrap_SbImage_searchForFile in coin_wrap.cpp.o
__wrap_SbDPMatrix___mul____SWIG_0 in coin_wrap.cpp.o
__wrap_SbDPMatrix_transpose in coin_wrap.cpp.o
__wrap_SbDPMatrix_identity in coin_wrap.cpp.o
__wrap_SbDPMatrix_inverse in coin_wrap.cpp.o
...
[cut]
...
"___cxa_guard_abort", referenced from:
_SWIG_This in coin_wrap.cpp.o
"___cxa_guard_acquire", referenced from:
_PySwigObject_type in coin_wrap.cpp.o
_PySwigPacked_type in coin_wrap.cpp.o
_SWIG_This in coin_wrap.cpp.o
"___cxa_guard_release", referenced from:
_PySwigObject_type in coin_wrap.cpp.o
_PySwigPacked_type in coin_wrap.cpp.o
_SWIG_This in coin_wrap.cpp.o
"___gxx_personality_v0", referenced from:
Dwarf Exception Unwind Info (__eh_frame) in coin_wrap.cpp.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
make[2]: *** [bin/pivy/_coin.so] Error 1
make[1]: *** [src/3rdParty/Pivy-0.5/CMakeFiles/coin.dir/all] Error 2
make: *** [all] Error 2
I comented out the if statement and did get further into the compile but diied on a missing file
[ 0%] Built target coin
[ 1%] Built target soqt
[ 1%] Built target Driver
[ 2%] Built target SMDS
[ 2%] Built target DriverDAT
[ 3%] Built target DriverSTL
[ 4%] Built target SMESHDS
[ 4%] Built target DriverUNV
[ 4%] Built target MEFISTO2
[ 5%] Built target SMESH
[ 7%] Built target StdMeshers
[ 7%] Building CXX object src/Base/CMakeFiles/FreeCADBase.dir/PersistencePyImp. cpp.o
In file included from /Users/james/Documents/Source/FreeCAD/src/Base/Persistence PyImp.cpp:25:
In file included from /Users/james/Documents/Source/FreeCAD/src/Base/Writer.h:32 :
/Users/james/Documents/Source/FreeCAD/src/zipios++/zipios-config.h:51:13: fatal error:
'config.h' file not found
# include <config.h>
^
1 error generated.
make[2]: *** [src/Base/CMakeFiles/FreeCADBase.dir/PersistencePyImp.cpp.o] Error 1
make[1]: *** [src/Base/CMakeFiles/FreeCADBase.dir/all] Error 2
make: *** [all] Error 2
peterl94
Veteran
Posts: 1001
Joined: Thu May 23, 2013 7:31 pm
Location: United States

Re: Mac Compile Help

Post by peterl94 »

Well, my build is not in a shareable state yet, but I can tell you what I did.

First of all, I compiled all of the debendencies manually, because I'm trying to put together a "LibPack" like there is for windows (otherwise, I probably would have used macports).

So these are the libraries I'm using:
boost 1.49.0
eigen3
xerces-c 3.1.1
Qt 4.8.5
Coin 3.1.3
SoQt 1.5.0
OCE 0.12
swig 1.3.40 (newer versions don't work!?)
freetype 2.5.0 (optional, but some features will be disabled)
Pivy 0.3.0 (probably can let freecad compile its own)
PyQt 4.10.2 (I think PySide is recomended now, instead of PyQt)

I always do an out of source build when I can, so:

Code: Select all

mkdir fc-builld
cd fc-build
By the way, I checked out the master branch from github.

Now for the configuring. I used ccmake (the CMake curses interface) because I was doing this over ssh, but cmake-gui is probably easier.

Code: Select all

ccmake ../FreeCAD_sf_master
Next, hit 'c' to do the initial configure, and make sure all of the correct libraries are found. Since I installed the dependencies to not-standard location, I had to fill in all the paths manually, but you probably won't have to. Now you will need to change some defaults. In the advanced mode, change CMAKE_CXX_COMPILER to /usr/bin/g++ and CMAKE_C_COMPILER to /usr/bin/gcc Also, I was just noticing that you could probably set CMAKE_EXE_LINKER_FLAGS, instead of the LIBRARY_PATH environment variable. (In my case it would be: -L /usr/local/gfortran/lib). The other variables I changed were CMAKE_BUILD_TYPE to Debug, FREECAD_USE_FREETYPE to ON, FREECAD_USE_EXTERNAL_PIVY to ON, and PYTHON_LIBRARY to /usr/lib/libpython2.7.dylib (because that's what the other libraries were linked to). After I was done changing things, I reconfigured, and then hit 'g' to generate the Makefiles.

Finally, you should be able to compile FreeCAD:

Code: Select all

make -j3
I had to do a couple more things before I could get FreeCAD to run. The first thing I had to do was set DYLD_LIBRARY_PATH, because I didn't run make install (at least I think that's why). The second thing I had to solve was Qt was unable to find qt_menu.nib (if you are using the Qt Framework you shouldn't have this problem). The problem was Qt was expecting to be run from within a bundle. So in my build folder, I created a MacOS folder and copied the FreeCAD executable into it, and then copied qt_menu.nib to folder named Resources at the same level as the MacOS folder (since I compiled Qt myself qt_menu.nib was located in qt-everywhere-opensource-src-4.8.5/src/gui/mac, I'm not sure where it would be on your system).

So currently, I don't have a application bundle, and am just launching FreeCAD with a shell script.

Hopefully that is enough information for you. I'll be happy to help, if you have any more problems.

Good luck!
Peter
User avatar
NormandC
Veteran
Posts: 18589
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

Re: Mac Compile Help

Post by NormandC »

peterl94 wrote:freetype 2.5.0 (optional, but some features will be disabled)
The freetype library is used by a single feature, the Draft "Shape from text" tool.

This tool allows easy extruding of text in FreeCAD, it would be a shame not to include it! :)

https://plus.google.com/u/0/11805138286 ... 47TsjFvGde
Image
peterl94
Veteran
Posts: 1001
Joined: Thu May 23, 2013 7:31 pm
Location: United States

Re: Mac Compile Help

Post by peterl94 »

Ah, yeah that is a cool feature :)

Update on qt_menu.nib:
There is no need to mess around with a special directory structure, qt_menu.nib just needs to be in the lib folder with the Qt libraries.
jamesl73
Posts: 20
Joined: Sun Jun 23, 2013 10:07 pm

Re: Mac Compile Help

Post by jamesl73 »

normandc wrote: The freetype library is used by a single feature, the Draft "Shape from text" tool.

This tool allows easy extruding of text in FreeCAD, it would be a shame not to include it! :)
Where do I find that tool?

Edit: This is taking the thread on a tangent, but I see the option is available in a newwer build, but the latest windows version available actually gives an error that it was not compiled with truetype

OS: Windows 7
Platform: 32-bit
Version: 0.14.2192 (Git)
Branch: master
Hash: b63f9d7a2b440e1363508976ec105dac31d7f698
Python version: 2.6.2
Qt version: 4.5.2
Coin version: 3.1.0
SoQt version: 1.4.1
OCC version: 6.5.1
User avatar
NormandC
Veteran
Posts: 18589
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

Re: Mac Compile Help

Post by NormandC »

I'm sorry, apparently the Draft Shape from text tool does not work on Windows yet, because a newer LibPack to be used by the people preparing Windows installers needs to be created first.

viewtopic.php?f=17&t=3915&start=10#p32423

The rest of the topic just linked seems to contain relevant info on building it on Mac.
Post Reply