Problems building FreeCAD (in macOS)

Having trouble installing or compiling FreeCAD? Get help here.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
jmplonka
Posts: 138
Joined: Tue Dec 20, 2016 7:47 am
Location: Vaihingen (Enz), Germany

Re: problems in build

Post by jmplonka »

It seems to be working:

Code: Select all

OS: macOS 12.3
Word size of FreeCAD: 64-bit
Version: 0.20.28730 (Git)
Build type: Release
Branch: master
Hash: 4358a9ba7031a61f1ade26958b74f95ff8daf1cf
Python 3.9.12, Qt 5.15.3, Coin 4.0.0, OCC 7.5.3
Locale: English/Germany (en_DE)
Thanks to all
aqsss
Posts: 4
Joined: Wed Apr 20, 2022 5:59 pm

Re: problems in build

Post by aqsss »

jmplonka wrote: Thu Apr 21, 2022 12:17 pm It seems to be working:

Code: Select all

OS: macOS 12.3
Word size of FreeCAD: 64-bit
Version: 0.20.28730 (Git)
Build type: Release
Branch: master
Hash: 4358a9ba7031a61f1ade26958b74f95ff8daf1cf
Python 3.9.12, Qt 5.15.3, Coin 4.0.0, OCC 7.5.3
Locale: English/Germany (en_DE)
Thanks to all
Do you mind to share the full instruction of your successful build?
jmplonka
Posts: 138
Joined: Tue Dec 20, 2016 7:47 am
Location: Vaihingen (Enz), Germany

Re: problems in build

Post by jmplonka »

aqsss wrote: Fri Apr 22, 2022 5:59 pm Do you mind to share the full instruction of your successful build?
From a new macOS (no Conda) , verify that your python3 version is something like 3.8.x.
I created a folder ~/dev/FreeCAD and opened the terminal there.
1. install homebrew:

Code: Select all

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
2. build FreeCAD:
Everything is quite straightforward, except the red part (yes I like variables 8-), makes things easier to read ):

Code: Select all

PYTHON_VERSION=3.9
HOMEBREW_PATH=/opt/homebrew/opt
PYTHON_FRAMEWORK=$HOMEBREW_PATH/python@$PYTHON_VERSION/Frameworks/Python.framework/Versions/$PYTHON_VERSION
SOURCE_DIR=freecad_sources
BUILD_DIR=freecad_build
#BUILD_TYPE="Debug"
BUILD_TYPE="Release"

# fetch the sources from GitHub
git clone https://github.com/FreeCAD/FreeCAD.git $SOURCE_DIR

# install freecad dependencies via homebrew
brew tap freecad/freecad
brew install eigen
brew install --only-dependencies freecad

# some libraries are not linked correctly by default
brew link --overwrite pyside@2 tbb@2020
# ... and switch back to python3.9!
brew unlink python@3.10 python@3.9
brew link --force python@$PYTHON_VERSION

# dive into the build folder
mkdir -p $BUILD_DIR
cd $BUILD_DIR

# export path to installed dependencies, nglib required for Salome MESH!
export PREFIX_PATH="\
$HOMEBREW_PATH/opencascade@7.5.3;\
$HOMEBREW_PATH/qt@5;\
$HOMEBREW_PATH/vtk@8.2;\
$HOMEBREW_PATH/nglib@6.2.2104/Contents/Resources;"

# on macOS ARM -DBUILD_WEB is set to OFF -> no Start-WB
cmake \
  -DCMAKE_BUILD_TYPE=$BUILD_TYPE \
  -DCMAKE_PREFIX_PATH="$PREFIX_PATH" \
  -DFREECAD_CREATE_MAC_APP=1 \
  -DCMAKE_INSTALL_PREFIX="./.." \
  -DFREECAD_USE_EXTERNAL_KDL=1 \
  -DBUILD_FEM_NETGEN=1 \
  -DBUILD_ENABLE_CXX_STD=C++17 \
  -DBUILD_WEB=OFF \
  -Wno-dev \
  -DPYTHON_EXECUTABLE=python$PYTHON_VERSION \
  -DPYTHON_INCLUDE_DIR=$PYTHON_FRAMEWORK/include/python$PYTHON_VERSION \
  -DPYTHON_LIBRARY=$PYTHON_FRAMEWORK/lib/libpython$PYTHON_VERSION.dylib \
  ../$SOURCE_DIR

# see https://forum.freecadweb.org/viewtopic.php?p=507588#p507588 for path to icu4c
export LIBRARY_PATH="$HOMEBREW_PATH/icu4c/lib"

# yepp - it's an MAC Studio  ;) 
time sh -c 'cmake --build . -j20'
time sh -c 'cmake --install .'
I wasn't able to move the FreeCAD.app into programs folder, but copy did the trick :o
The olefin, xlrd, xlwt and xlutils packages where missing and I installed them in the FC's python console:

Code: Select all

import subprocess

def install(name):
    subprocess.call(['pip', 'install', name])

install('olefile')
install('xlrd')
install('xlrt')
install('xlutils')
Now I was able to use my plugins (InventorLoader and Importer3D).
Regards
Jens
aqsss
Posts: 4
Joined: Wed Apr 20, 2022 5:59 pm

Re: problems in build

Post by aqsss »

jmplonka wrote: Fri Apr 22, 2022 6:27 pm
aqsss wrote: Fri Apr 22, 2022 5:59 pm Do you mind to share the full instruction of your successful build?
From a new macOS (no Conda) , verify that your python3 version is something like 3.8.x.
I created a folder ~/dev/FreeCAD and opened the terminal there.
1. install homebrew:

Code: Select all

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
2. build FreeCAD:
Everything is quite straightforward, except the red part (yes I like variables 8-), makes things easier to read ):

Code: Select all

PYTHON_VERSION=3.9
HOMEBREW_PATH=/opt/homebrew/opt
PYTHON_FRAMEWORK=$HOMEBREW_PATH/python@$PYTHON_VERSION/Frameworks/Python.framework/Versions/$PYTHON_VERSION
SOURCE_DIR=freecad_sources
BUILD_DIR=freecad_build
#BUILD_TYPE="Debug"
BUILD_TYPE="Release"

# fetch the sources from GitHub
git clone https://github.com/FreeCAD/FreeCAD.git $SOURCE_DIR

# install freecad dependencies via homebrew
brew tap freecad/freecad
brew install eigen
brew install --only-dependencies freecad

# some libraries are not linked correctly by default
brew link --overwrite pyside@2 tbb@2020
# ... and switch back to python3.9!
brew unlink python@3.10 python@3.9
brew link --force python@$PYTHON_VERSION

# dive into the build folder
mkdir -p $BUILD_DIR
cd $BUILD_DIR

# export path to installed dependencies, nglib required for Salome MESH!
export PREFIX_PATH="\
$HOMEBREW_PATH/opencascade@7.5.3;\
$HOMEBREW_PATH/qt@5;\
$HOMEBREW_PATH/vtk@8.2;\
$HOMEBREW_PATH/nglib@6.2.2104/Contents/Resources;"

# on macOS ARM -DBUILD_WEB is set to OFF -> no Start-WB
cmake \
  -DCMAKE_BUILD_TYPE=$BUILD_TYPE \
  -DCMAKE_PREFIX_PATH="$PREFIX_PATH" \
  -DFREECAD_CREATE_MAC_APP=1 \
  -DCMAKE_INSTALL_PREFIX="./.." \
  -DFREECAD_USE_EXTERNAL_KDL=1 \
  -DBUILD_FEM_NETGEN=1 \
  -DBUILD_ENABLE_CXX_STD=C++17 \
  -DBUILD_WEB=OFF \
  -Wno-dev \
  -DPYTHON_EXECUTABLE=python$PYTHON_VERSION \
  -DPYTHON_INCLUDE_DIR=$PYTHON_FRAMEWORK/include/python$PYTHON_VERSION \
  -DPYTHON_LIBRARY=$PYTHON_FRAMEWORK/lib/libpython$PYTHON_VERSION.dylib \
  ../$SOURCE_DIR

# see https://forum.freecadweb.org/viewtopic.php?p=507588#p507588 for path to icu4c
export LIBRARY_PATH="$HOMEBREW_PATH/icu4c/lib"

# yepp - it's an MAC Studio  ;) 
time sh -c 'cmake --build . -j20'
time sh -c 'cmake --install .'
I wasn't able to move the FreeCAD.app into programs folder, but copy did the trick :o
The olefin, xlrd, xlwt and xlutils packages where missing and I installed them in the FC's python console:

Code: Select all

import subprocess

def install(name):
    subprocess.call(['pip', 'install', name])

install('olefile')
install('xlrd')
install('xlrt')
install('xlutils')
Now I was able to use my plugins (InventorLoader and Importer3D).
Regards
Jens
Thanks mate! It works flawlessly. However, when I open the application by "open FreeCAD.app". The gui will show up but the bottom "Report View" windows will show the following error message

Code: Select all

13:57:17  Addon Manager Warning: Could not import QtWebEngineWidgets, it seems to be missing from your system. Please use your system's package manager to install the python3-pyside2.qtwebengine* and python3-pyside2.qtwebchannel packages, and if possible alert your package creator to the missing dependency. Display of package README will be limited until this dependency is resolved.
Did you have the same issue before?
jmplonka
Posts: 138
Joined: Tue Dec 20, 2016 7:47 am
Location: Vaihingen (Enz), Germany

Re: problems in build

Post by jmplonka »

aqsss wrote: Mon Apr 25, 2022 6:01 am ... However, when I open the application by "open FreeCAD.app". The gui will show up but the bottom "Report View" windows will show the following error message

Code: Select all

13:57:17  Addon Manager Warning: Could not import QtWebEngineWidgets, it seems to be missing from your system. Please use your system's package manager to install the python3-pyside2.qtwebengine* and python3-pyside2.qtwebchannel packages, and if possible alert your package creator to the missing dependency. Display of package README will be limited until this dependency is resolved.
Did you have the same issue before?
Yes, it's because of the disabled Web-Feature.
aqsss
Posts: 4
Joined: Wed Apr 20, 2022 5:59 pm

Re: problems in build

Post by aqsss »

jmplonka wrote: Mon Apr 25, 2022 6:09 am
aqsss wrote: Mon Apr 25, 2022 6:01 am ... However, when I open the application by "open FreeCAD.app". The gui will show up but the bottom "Report View" windows will show the following error message

Code: Select all

13:57:17  Addon Manager Warning: Could not import QtWebEngineWidgets, it seems to be missing from your system. Please use your system's package manager to install the python3-pyside2.qtwebengine* and python3-pyside2.qtwebchannel packages, and if possible alert your package creator to the missing dependency. Display of package README will be limited until this dependency is resolved.
Did you have the same issue before?
Yes, it's because of the disabled Web-Feature.
Got it. Thx again for the detail instruction. I can finally run native arm64 FreeCAD on Macbook M1. :)
jmplonka
Posts: 138
Joined: Tue Dec 20, 2016 7:47 am
Location: Vaihingen (Enz), Germany

Re: problems in build

Post by jmplonka »

How can I get rid of the install errors:

Code: Select all

error: /Library/Developer/CommandLineTools/usr/bin/install_name_tool: for: ./FreeCAD.app/Contents/lib/PartDesignGui.so (for architecture arm64) option "-add_rpath ./FreeCAD/FreeCAD.app/Contents/lib" would duplicate path, file already has LC_RPATH for: ./dev/FreeCAD/FreeCAD.app/Contents/libb
the missing LC_RPATH:

Code: Select all

error: /Library/Developer/CommandLineTools/usr/bin/install_name_tool: no LC_RPATH load command with path: /opt/homebrew/Cellar/open-mpi/4.1.3/lib found in: ./FreeCAD/FreeCAD.app/Contents/lib/PartDesignGui.so (for architecture arm64), required for specified option "-delete_rpath /opt/homebrew/Cellar/open-mpi/4.1.3/lib"
error: /Library/Developer/CommandLineTools/usr/bin/install_name_tool: no LC_RPATH load command with path: /opt/homebrew/opt/libevent/lib found in: ./FreeCAD/FreeCAD.app/Contents/lib/PartDesignGui.so (for architecture arm64), required for specified option "-delete_rpath /opt/homebrew/opt/libevent/lib"
error: /Library/Developer/CommandLineTools/usr/bin/install_name_tool: no LC_RPATH load command with path: /opt/homebrew/opt/opencascade@7.5.3/lib found in: ./FreeCAD/FreeCAD.app/Contents/lib/PartDesignGui.so (for architecture arm64), required for specified option "-delete_rpath /opt/homebrew/opt/opencascade@7.5.3/lib"
error: /Library/Developer/CommandLineTools/usr/bin/install_name_tool: no LC_RPATH load command with path: ./FreeCAD/freecad_build/Mod/PartDesign found in: ./FreeCAD/FreeCAD.app/Contents/lib/PartDesignGui.so (for architecture arm64), required for specified option "-delete_rpath ./FreeCAD/freecad_build/Mod/PartDesign"
error: /Library/Developer/CommandLineTools/usr/bin/install_name_tool: no LC_RPATH load command with path: ./FreeCAD/freecad_build/Mod/Sketcher found in: ./FreeCAD/FreeCAD.app/Contents/lib/PartDesignGui.so (for architecture arm64), required for specified option "-delete_rpath ./FreeCAD/freecad_build/Mod/Sketcher"
error: /Library/Developer/CommandLineTools/usr/bin/install_name_tool: no LC_RPATH load command with path: ./FreeCAD/freecad_build/Mod/Part found in: ./FreeCAD/FreeCAD.app/Contents/lib/PartDesignGui.so (for architecture arm64), required for specified option "-delete_rpath ./FreeCAD/freecad_build/Mod/Part"
error: /Library/Developer/CommandLineTools/usr/bin/install_name_tool: no LC_RPATH load command with path: ./FreeCAD/freecad_build/lib found in: ./FreeCAD/FreeCAD.app/Contents/lib/PartDesignGui.so (for architecture arm64), required for specified option "-delete_rpath ./FreeCAD/freecad_build/lib"
error: /Library/Developer/CommandLineTools/usr/bin/install_name_tool: no LC_RPATH load command with path: /opt/homebrew/lib found in: ./FreeCAD/FreeCAD.app/Contents/lib/PartDesignGui.so (for architecture arm64), required for specified option "-delete_rpath /opt/homebrew/lib"
And specially of the libicudata error:

Code: Select all

Traceback (most recent call last):
  File "./FreeCAD/freecad_sources/src/Tools/MakeMacBundleRelocatable.py", line 391, in <module>
    main()
  File "./FreeCAD/freecad_sources/src/Tools/MakeMacBundleRelocatable.py", line 374, in main
    build_deps_graph(graph, bundle_path, dir_filter, search_paths)
  File "./FreeCAD/freecad_sources/src/Tools/MakeMacBundleRelocatable.py", line 241, in build_deps_graph
    deps = create_dep_nodes(list_install_names(k2), s_paths)
  File "./FreeCAD/freecad_sources/src/Tools/MakeMacBundleRelocatable.py", line 166, in create_dep_nodes
    raise LibraryNotFound(lib_name + " not found in given search paths")
__main__.LibraryNotFound: libicudata.70.dylib not found in given search paths
I think one of the errors is causing a segmentation fault, when importing Fusion3D or Inventor files.
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: Problems building FreeCAD (in macOS)

Post by Kunda1 »

jmplonka wrote: Fri May 06, 2022 10:53 am And specially of the libicudata error:
libicudata errors looks relevant to https://github.com/FreeCAD/FreeCAD/pull/6784


Aside: @jmplonka are you using https://github.com/FreeCAD/homebrew-freecad to build FC from homebrew?
ipatch wrote: pinged by pinger macro
CC @ipatch (this is related to compiling FC on Mac M1)
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
jmplonka
Posts: 138
Joined: Tue Dec 20, 2016 7:47 am
Location: Vaihingen (Enz), Germany

Re: Problems building FreeCAD (in macOS)

Post by jmplonka »

Kunda1 wrote: Mon May 09, 2022 10:42 pmare you using https://github.com/FreeCAD/homebrew-freecad to build FC from homebrew?
Yes, I do. After completely reinstalling brew and running the first two steps of the Readme, I'm facing now the error:

Code: Select all

Unable to find LC_DYLD_LOAD entry: @rpath/libc++abi.1.dylib
:o
Post Reply