Compile w/Py3 & Qt5 for Dummies

Having trouble installing or compiling FreeCAD? Get help here.
User avatar
NormandC
Posts: 18534
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

Re: Compile w/Py3 & Qt5 for Dummies

Postby NormandC » Thu Jan 10, 2019 3:01 am

Well, after several tries, I gave up on using cmake-gui. The compilation would always fails around 60%, and the error messages indicated that Qt4 still seemed to be used.

Here's an excerpt:

Code: Select all

/usr/include/qt4/QtCore/qstring.h:1277:8: error: ‘QBool’ does not name a type; did you mean ‘bool’?
 inline QBool QStringRef::contains(QLatin1String s, Qt::CaseSensitivity cs) const
        ^~~~~
        bool
/usr/include/qt4/QtCore/qstring.h:1279:8: error: ‘QBool’ does not name a type; did you mean ‘bool’?
 inline QBool QStringRef::contains(QChar c, Qt::CaseSensitivity cs) const
        ^~~~~
        bool
/usr/include/qt4/QtCore/qstring.h:1281:8: error: ‘QBool’ does not name a type; did you mean ‘bool’?
 inline QBool QStringRef::contains(const QStringRef &s, Qt::CaseSensitivity cs) const
        ^~~~~
        bool
src/Mod/Draft/App/CMakeFiles/DraftUtils.dir/build.make:158: recipe for target 'src/Mod/Draft/App/CMakeFiles/DraftUtils.dir/DraftDxf.cpp.o' failed
make[2]: *** [src/Mod/Draft/App/CMakeFiles/DraftUtils.dir/DraftDxf.cpp.o] Error 1
CMakeFiles/Makefile2:3413: recipe for target 'src/Mod/Draft/App/CMakeFiles/DraftUtils.dir/all' failed
make[1]: *** [src/Mod/Draft/App/CMakeFiles/DraftUtils.dir/all] Error 2

I finally succeeded in compiling FreeCAD with Py3/Qt5 using the CLI based on triplus' simple line of code.
https://forum.freecadweb.org/viewtopic. ... 40#p275323
wmayer
Site Admin
Posts: 14060
Joined: Thu Feb 19, 2009 10:32 am

Re: Compile w/Py3 & Qt5 for Dummies

Postby wmayer » Thu Jan 10, 2019 9:53 am

BUILD_QT5 is also a switch in the CMake GUI you have to check.
User avatar
NormandC
Posts: 18534
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

Re: Compile w/Py3 & Qt5 for Dummies

Postby NormandC » Thu Jan 10, 2019 12:32 pm

But I did check it. What's odd is I succeeded in compiling with Qt5 and Py2. But trying to set switches for Py3 and Qt5 from cmake-gui repeatedly fails for me with the error above. And I started from a clean build folder at least two times.
User avatar
Moult
Posts: 153
Joined: Sat Jan 05, 2019 11:46 am
Contact:

Re: Compile w/Py3 & Qt5 for Dummies

Postby Moult » Sat Jan 12, 2019 11:12 am

Good day all. I have successfully compiled FreeCAD on Gentoo with Python 3 and Qt5.

First, I needed all the dependencies. I found out pretty quickly that there are quite a lot of dependencies, and they are a little tricky to get all in one place. Even in Gentoo they are not all there in the tree. I was lucky to find that there is a Gentoo overlay by waebbl which has an ebuild for FreeCAD. By attempting to emerge that, it resolves all the dependencies.

Resolving dependencies will be different on your system, but that ebuild does list all of the required packages (see L50-90), which can help guide you.

Now, all that's left is to compile FreeCAD itself. This is relatively straightforward:

Code: Select all

$ git clone https://github.com/FreeCAD/FreeCAD.git
$ cd FreeCAD
$ cmake -DPYTHON_LIBRARY=/usr/lib64/libpython3.6m.so -DPYTHON_INCLUDE_DIR=/usr/include/python3.6m -DBUILD_QT5=ON -DPYTHON_PACKAGES_PATH=/usr/lib64/python3.6/site-packages -DPYTHON_EXECUTABLE=/usr/bin/python3.6 .
$ make
$ ./bin/FreeCAD
Please note that library "*.so" file, include directory, site-packages path, and executable may be different. The Unix "locate" command may help you find out where yours are on your system. You will know if it works if in the cmake step it says it finds the python 3 version for boost, and the python 3 executable.

Keep in mind that you will need to make sure you are doing it on a fresh clone. If you have messed around, you should reset your git directory:

Code: Select all

$ > .gitignore
$ git clean -df
$ git reset --hard HEAD
For future reference, you can inspect all cmake flags by doing `cmake -LH`.

I hope it helps.
I also blog about 3D rendering, architecture, software and other on thinkMoult.com. RSS / Atom feed available for your convenience.
User avatar
bernd
Posts: 7535
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

Re: Compile w/Py3 & Qt5 for Dummies

Postby bernd » Sat Jan 12, 2019 12:05 pm

Moult wrote:
Sat Jan 12, 2019 11:12 am
... you can inspect all cmake flags by doing `cmake -LH`.
never knew about that one :D
User avatar
bernd
Posts: 7535
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

Re: Compile w/Py3 & Qt5 for Dummies

Postby bernd » Sat Jan 12, 2019 8:47 pm

@Normand: Which ubuntu system are you on?
User avatar
Moult
Posts: 153
Joined: Sat Jan 05, 2019 11:46 am
Contact:

Re: Compile w/Py3 & Qt5 for Dummies

Postby Moult » Sat Jan 12, 2019 9:21 pm

I would like to edit the wiki page https://www.freecadweb.org/wiki/CompileOnUnix to include these instructions, as well as what I have discovered specifically for the Gentoo distribution. (I would also like to fix some of the mistakes I have seen in the tutorials) However, I am told I need an account. Can somebody please help create an account for me? I would like "Moult" to be my username.
I also blog about 3D rendering, architecture, software and other on thinkMoult.com. RSS / Atom feed available for your convenience.
User avatar
NormandC
Posts: 18534
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

Re: Compile w/Py3 & Qt5 for Dummies

Postby NormandC » Sat Jan 12, 2019 10:14 pm

bernd wrote:
Sat Jan 12, 2019 8:47 pm
@Normand: Which ubuntu system are you on?
OS: Ubuntu 18.04.1 LTS
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.15619 (Git)
Build type: Release
Branch: master
Hash: 7d8e5662648b794b5c93e28835a2bf5c1fddffec
Python version: 3.6.7
Qt version: 5.9.5
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: French/Canada (fr_CA)

Moult wrote:
Sat Jan 12, 2019 9:21 pm
I am told I need an account. Can somebody please help create an account for me?
https://forum.freecadweb.org/viewtopic.php?f=21&t=6830
User avatar
Moult
Posts: 153
Joined: Sat Jan 05, 2019 11:46 am
Contact:

Re: Compile w/Py3 & Qt5 for Dummies

Postby Moult » Sun Jan 13, 2019 2:41 am

FYI, wiki page updated.
I also blog about 3D rendering, architecture, software and other on thinkMoult.com. RSS / Atom feed available for your convenience.
reox
Posts: 539
Joined: Sat Aug 13, 2016 10:06 am

Re: Compile w/Py3 & Qt5 for Dummies

Postby reox » Sun Jan 13, 2019 5:02 pm

I got QT5 + Py3.7 working on debian sid using these changes: https://github.com/reox/FreeCAD_gitpack ... f4af524697
I'm not sure about all the cmake variables, maybe some of them are also autogenerated...

But it looks like that freecad is not useable then:

Code: Select all

Traceback (most recent call last):
  File "<string>", line 1, in <module>
<class 'AttributeError'>: 'Gui.ViewProviderDocumentObject' object has no attribute 'Visibility'
Most files I open does not show anything and pressing space on the features gives me this error message.
Should python 3 work already?

Code: Select all

OS: Debian GNU/Linux buster/sid
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.15619 (Git)
Build type: Release
Branch: master
Hash: 7d8e5662648b794b5c93e28835a2bf5c1fddffec
Python version: 3.7.2
Qt version: 5.11.3
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: German/Austria (de_AT)
If you like to replicate this:

Code: Select all

# Not required if you already have a pbuilder environment
sudo pbuilder create

PACKAGINGBRANCH="dailybuild-occt-qt5"
DEBVERSION="0.18+git$(date +%Y%m%d%H%M)-1"

git clone https://github.com/FreeCAD/FreeCAD.git
pushd FreeCAD

git remote add gitpackaging https://github.com/reox/FreeCAD_gitpackaging.git
git remote add gitversioning https://git.launchpad.net/~freecad-maintainers/+git/gitversioning

git remote update

git merge gitpackaging/$PACKAGINGBRANCH --allow-unrelated-histories --no-edit
git merge gitversioning/master --allow-unrelated-histories --no-edit

dch --newversion "$DEBVERSION" --distribution unstable "Daily build"

pdebuild --use-pdebuild-internal

popd