NGsolve stable and nightlies won't work for us. Let's try to solve the dependency/Debian packaging hell ourselves

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
triplus
Veteran
Posts: 9471
Joined: Mon Dec 12, 2011 4:45 pm

Re: NGsolve stable and nightlies won't work for us. Let's try to solve the dependency/Debian packaging hell ourselves

Post by triplus »

Hi Matthias and welcome.
mhochsteger wrote: Tue Jan 23, 2018 11:51 am I'm part of the Netgen team and we stumbled over this discussion by coincidence. I to admit that the pull request/discussion initiated by looo didn't get much attention. Anyway, I had a look at his repository (https://github.com/looooo/netgen-1) and merged parts of it.
Please take a look at the current master and let me know what you need.

looo wrote: Tue Jan 23, 2018 5:56 pm Maybe someone can try to build netgen directly on ubuntu. It seems some of the issues I had were related to the old gcc used for conda (gcc4.8)
I can confirm compiling latest:

https://github.com/NGSolve/netgen

On Ubuntu 16.04 against OCC 7.1 from the PPA works (cmake -DUSE_OCC="1" ..) now without issues detected.
If I understand correctly you are only interested in nglib? In this case you can turn off most dependencies (TCL/TK, Python) with "cmake -DUSE_PYTHON=OFF -DUSE_GUI=OFF", so the suggested patches related to Python bindings should be irrelevant.
Thanks for the info. I am guessing for the PPA purposes we can disable everything not needed. But as there is a plan to get Netgen in Debian. There likely such features won't be disabled by default.

P.S. Any chance defining a custom path to OCC in for example cmake-gui could be added in the future?
triplus
Veteran
Posts: 9471
Joined: Mon Dec 12, 2011 4:45 pm

Re: NGsolve stable and nightlies

Post by triplus »

kkremitzki wrote: Thu Jan 18, 2018 5:19 pm The OCCT 7.2 package is now available on my PPA at https://launchpad.net/~kkremitzki/+arch ... tu/freecad, ppa:kkremitzki/freecad.

Note however that this should not be considered a final version of the package, for example the -7.2.0 suffix on package names causes problems if you already have the freecad-daily PPA.
Could you by any chance build a package for Ubuntu 16.04 and using:

Code: Select all

cmake -DBUILD_SHARED_LIBRARY_NAME_POSTFIX="Daily" ..
https://forum.freecadweb.org/viewtopic. ... 70#p210665

I can after test the package from the PPA. To see if that resolves the issue with shared libraries conflict when installing the package:

https://forum.freecadweb.org/viewtopic. ... 40#p210191
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

Re: NGsolve stable and nightlies won't work for us. Let's try to solve the dependency/Debian packaging hell ourselves

Post by looo »

mhochsteger wrote:I'm part of the Netgen team and we stumbled over this discussion by coincidence. I to admit that the pull request/discussion initiated by looo didn't get much attention. Anyway, I had a look at his repository (https://github.com/looooo/netgen-1) and merged parts of it.
Please take a look at the current master and let me know what you need.
It seems I wrote my comment yesterday at the same time as you have replied.
So this are great news! I had a short look at the stuff now in netgen/master, and most of the things necesarry for FreeCAD with occt7.2 are now available. With https://github.com/NGSolve/netgen/pull/ ... w-91098374 we should be able to use netgen/master again.,
mhochsteger wrote:If I understand correctly you are only interested in nglib? In this case you can turn off most dependencies (TCL/TK, Python) with "cmake -DUSE_PYTHON=OFF -DUSE_GUI=OFF", so the suggested patches related to Python bindings should be irrelevant
Yes exactly allthough I think FreeCAD would benefit from netgen-python bindings. But first concentrate on the important things.
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

Re: NGsolve stable and nightlies won't work for us. Let's try to solve the dependency/Debian packaging hell ourselves

Post by looo »

I tried to use netgen-master for a conda-package.

1. without any changes I get compile errors (I think this is gcc4.8 relevant, but maybe we can find a solution):

Code: Select all

/home/conda/projects/netgen-1/libsrc/interface/nginterface.cpp: In function ‘void Ng_LoadMesh(const char*)’:
/home/conda/projects/netgen-1/libsrc/interface/nginterface.cpp:122:39: error: use of deleted function ‘std::basic_ifstream<char>::basic_ifstream(const std::basic_ifstream<char>&)’
       auto infile = ifstream (filename);
                                       ^
In file included from /home/conda/projects/netgen-1/libsrc/include/mystdlib.h:6:0,
                 from /home/conda/projects/netgen-1/libsrc/interface/nginterface.cpp:1:
/opt/conda/conda-bld/netgen_1516797311421/_b_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placeh/gcc/include/c++/fstream:427:11: note: ‘std::basic_ifstream<char>::basic_ifstream(const std::basic_ifstream<char>&)’ is implicitly deleted because the default definition would be ill-formed:
     class basic_ifstream : public basic_istream<_CharT, _Traits>
           ^
/opt/conda/conda-bld/netgen_1516797311421/_b_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placeh/gcc/include/c++/fstream:427:11: error: use of deleted function ‘std::basic_istream<char>::basic_istream(const std::basic_istream<char>&)’
In file included from /opt/conda/conda-bld/netgen_1516797311421/_b_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placeh/gcc/include/c++/iostream:40:0,
                 from /home/conda/projects/netgen-1/libsrc/include/mystdlib.h:4,
                 from /home/conda/projects/netgen-1/libsrc/interface/nginterface.cpp:1:
/opt/conda/conda-bld/netgen_1516797311421/_b_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placeh/gcc/include/c++/istream:58:11: note: ‘std::basic_istream<char>::basic_istream(const std::basic_istream<char>&)’ is implicitly deleted because the default definition would be ill-formed:
     class basic_istream : virtual public basic_ios<_CharT, _Traits>
           ^
/opt/conda/conda-bld/netgen_1516797311421/_b_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placeh/gcc/include/c++/istream:58:11: error: use of deleted function ‘std::basic_ios<char>::basic_ios(const std::basic_ios<char>&)’
In file included from /opt/conda/conda-bld/netgen_1516797311421/_b_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placeh/gcc/include/c++/ios:44:0,
                 from /opt/conda/conda-bld/netgen_1516797311421/_b_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placeh/gcc/include/c++/ostream:38,
                 from /opt/conda/conda-bld/netgen_1516797311421/_b_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placeh/gcc/include/c++/iostream:39,
                 from /home/conda/projects/netgen-1/libsrc/include/mystdlib.h:4,
                 from /home/conda/projects/netgen-1/libsrc/interface/nginterface.cpp:1:
/opt/conda/conda-bld/netgen_1516797311421/_b_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placeh/gcc/include/c++/bits/basic_ios.h:66:11: note: ‘std::basic_ios<char>::basic_ios(const std::basic_ios<char>&)’ is implicitly deleted because the default definition would be ill-formed:
     class basic_ios : public ios_base
           ^
In file included from /opt/conda/conda-bld/netgen_1516797311421/_b_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placeh/gcc/include/c++/ios:42:0,
                 from /opt/conda/conda-bld/netgen_1516797311421/_b_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placeh/gcc/include/c++/ostream:38,
                 from /opt/conda/conda-bld/netgen_1516797311421/_b_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placeh/gcc/include/c++/iostream:39,
                 from /home/conda/projects/netgen-1/libsrc/include/mystdlib.h:4,
                 from /home/conda/projects/netgen-1/libsrc/interface/nginterface.cpp:1:
/opt/conda/conda-bld/netgen_1516797311421/_b_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placeh/gcc/include/c++/bits/ios_base.h:786:5: error: ‘std::ios_base::ios_base(const std::ios_base&)’ is private
     ios_base(const ios_base&);
     ^
In file included from /opt/conda/conda-bld/netgen_1516797311421/_b_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placeh/gcc/include/c++/ios:44:0,
                 from /opt/conda/conda-bld/netgen_1516797311421/_b_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placeh/gcc/include/c++/ostream:38,
                 from /opt/conda/conda-bld/netgen_1516797311421/_b_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placeh/gcc/include/c++/iostream:39,
                 from /home/conda/projects/netgen-1/libsrc/include/mystdlib.h:4,
                 from /home/conda/projects/netgen-1/libsrc/interface/nginterface.cpp:1:
/opt/conda/conda-bld/netgen_1516797311421/_b_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placeh/gcc/include/c++/bits/basic_ios.h:66:11: error: within this context
     class basic_ios : public ios_base
           ^
In file included from /home/conda/projects/netgen-1/libsrc/include/mystdlib.h:6:0,
                 from /home/conda/projects/netgen-1/libsrc/interface/nginterface.cpp:1:
/opt/conda/conda-bld/netgen_1516797311421/_b_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placeh/gcc/include/c++/fstream:427:11: error: use of deleted function ‘std::basic_ios<char>::basic_ios(const std::basic_ios<char>&)’
     class basic_ifstream : public basic_istream<_CharT, _Traits>
           ^
/opt/conda/conda-bld/netgen_1516797311421/_b_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placeh/gcc/include/c++/fstream:427:11: error: use of deleted function ‘std::basic_filebuf<char>::basic_filebuf(const std::basic_filebuf<char>&)’
/opt/conda/conda-bld/netgen_1516797311421/_b_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placeh/gcc/include/c++/fstream:72:11: note: ‘std::basic_filebuf<char>::basic_filebuf(const std::basic_filebuf<char>&)’ is implicitly deleted because the default definition would be ill-formed:
     class basic_filebuf : public basic_streambuf<_CharT, _Traits>
           ^
In file included from /opt/conda/conda-bld/netgen_1516797311421/_b_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placeh/gcc/include/c++/ios:43:0,
                 from /opt/conda/conda-bld/netgen_1516797311421/_b_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placeh/gcc/include/c++/ostream:38,
                 from /opt/conda/conda-bld/netgen_1516797311421/_b_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placeh/gcc/include/c++/iostream:39,
                 from /home/conda/projects/netgen-1/libsrc/include/mystdlib.h:4,
                 from /home/conda/projects/netgen-1/libsrc/interface/nginterface.cpp:1:
/opt/conda/conda-bld/netgen_1516797311421/_b_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placeh/gcc/include/c++/streambuf:802:7: error: ‘std::basic_streambuf<_CharT, _Traits>::basic_streambuf(const std::basic_streambuf<_CharT, _Traits>&) [with _CharT = char; _Traits = std::char_traits<char>]’ is private
       basic_streambuf(const basic_streambuf& __sb)
       ^
In file included from /home/conda/projects/netgen-1/libsrc/include/mystdlib.h:6:0,
                 from /home/conda/projects/netgen-1/libsrc/interface/nginterface.cpp:1:
/opt/conda/conda-bld/netgen_1516797311421/_b_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placeh/gcc/include/c++/fstream:72:11: error: within this context
     class basic_filebuf : public basic_streambuf<_CharT, _Traits>
2. applying https://github.com/looooo/netgen-1/comm ... 75f9ff25b3 and compiling with

Code: Select all

 -DUSE_PYTHON=OFF   -DUSE_GUI=OFF -DCMAKE_CXX_FLAGS='-fabi-version=6'
finish build. For usage in FreeCAD we need the additional patch as I already mentioned in the previous post.

3. building with

Code: Select all

DUSE_PYTHON=ON -DUSE_GUI=OFF -DCMAKE_CXX_FLAGS='-fabi-version=6' 
doesn't find pybind11 headers. I suggest to find pythonheader location with this:

Code: Select all

find_package(PythonInterp)
find_package(PythonLibs)
include_directories( ${PYTHON_INCLUDE_DIRS})
This is maybe not working in a multi-python environment (like ubuntu) where python2 is default. Maybe it would be possible to use a custom variable for pybind11 headers like already available in the current master, and only check for default python-headers if no custom location for pybind11 headers are given. But the best is maybe to not depend on netgens-python binding until python2 is dead. ;)
mhochsteger
Posts: 4
Joined: Tue Jan 23, 2018 11:31 am

Re: NGsolve stable and nightlies won't work for us. Let's try to solve the dependency/Debian packaging hell ourselves

Post by mhochsteger »

looo wrote: Wed Jan 24, 2018 12:58 pm 2. applying https://github.com/looooo/netgen-1/comm ... 75f9ff25b3 and compiling with
Could you try the following patch instead?

Code: Select all

diff --git a/libsrc/interface/nginterface.cpp b/libsrc/interface/nginterface.cpp
index edce339..ab4ef71 100644
--- a/libsrc/interface/nginterface.cpp
+++ b/libsrc/interface/nginterface.cpp
@@ -119,7 +119,7 @@ void Ng_LoadMeshFromStream ( istream & input )
 void Ng_LoadMesh (const char * filename)
 {
   {
-      auto infile = ifstream (filename);
+      infile ifstream (filename);
       if(!infile.good())
           throw NgException(string("Error opening file ") + filename);
   }
looo wrote: Wed Jan 24, 2018 12:58 pm 3. building with

Code: Select all

DUSE_PYTHON=ON -DUSE_GUI=OFF -DCMAKE_CXX_FLAGS='-fabi-version=6' 
doesn't find pybind11 headers.
Does it not find pybind11 or the Python3 headers?
Did you try to set CMAKE_PREFIX_PATH to the conda build dir in the conda script?

Code: Select all

  -DCMAKE_PREFIX_PATH=${PREFIX} #[linux]
  -DCMAKE_PREFIX_PATH=%LIBRARY_PREFIX% #[windows]
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

Re: NGsolve stable and nightlies won't work for us. Let's try to solve the dependency/Debian packaging hell ourselves

Post by looo »

mhochsteger wrote:Could you try the following patch instead?
works! :D
Does it not find pybind11 or the Python3 headers?
Did you try to set CMAKE_PREFIX_PATH to the conda build dir in the conda script?
yes, I use this build script:
https://github.com/FreeCAD/FreeCAD_Cond ... n/build.sh

pybind11 headers are normally stored in python_header_dir/pybind11. I am not using the git submodule, as conda has a package for pybind11.

Code: Select all

├── include
│   └── python3.6m
│       └── pybind11
I think this structure is not only conda-specific. I tested to install pybind11 with pip and it gives the same install-structure. So I guess this is more or less the default install location of pybind11.
So simple adding the default python include-dir would be the easiest way to support pybind11 packages. I guess this is done anyway? so simple checking for pybind11 after including the python headers would solve this issue.
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

Re: NGsolve stable and nightlies won't work for us. Let's try to solve the dependency/Debian packaging hell ourselves

Post by looo »

btw.: I used it the other way round:

Code: Select all

# infile ifstream (filename);
ifstream infile (filename);
mhochsteger
Posts: 4
Joined: Tue Jan 23, 2018 11:31 am

Re: NGsolve stable and nightlies won't work for us. Let's try to solve the dependency/Debian packaging hell ourselves

Post by mhochsteger »

looo wrote: Wed Jan 24, 2018 3:34 pm btw.: I used it the other way round
Of course, my fault...

This, the pointer reset in OCC mesh generation and the pybind header issue should be fixed on master now.

Another thing:
I strongly advise you to set "-DUSE_NATIVE_ARCH=OFF" on Linux/Mac for packaging, otherwise the code will be built with the '-march=native' compile flag and will not run on all x64 architectures.
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

Re: NGsolve stable and nightlies won't work for us. Let's try to solve the dependency/Debian packaging hell ourselves

Post by looo »

mhochsgteger wrote:Of course, my fault...

This, the pointer reset in OCC mesh generation and the pybind header issue should be fixed on master now.
I can now directly pull the source from ngsolve/netgen master to build packages for conda. Also the python bindings work without any changes. For FreeCAD netgen works at runtime (generating meshes works). One little thing remaining is the detection of the netgen-headers/libs via cmake. We use our own script there. The version of netgen was previously stored in mydefs.hpp. Somehow this is not available anymore and it seems the version is now available via 'NetgenConfig.cmake'. There the version is set to a variable called 'PACKAGE_VERSION'. Would it be possible to rename this variable into something like: 'NETGEN_VERSION', NETGEN_PACKAGE_VERSION' to not have any clashes with other cmake-variables.
mhochsteger wrote:Another thing:
I strongly advise you to set "-DUSE_NATIVE_ARCH=OFF" on Linux/Mac for packaging, otherwise the code will be built with the '-march=native' compile flag and will not run on all x64 architectures.
nice to know. I always wondered why I can use builds from my old machine on the newer machine, but not the other way. I guess setting "-DUSE_NATIVE_ARCH=OFF" will fix this.
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

Re: NGsolve stable and nightlies won't work for us. Let's try to solve the dependency/Debian packaging hell ourselves

Post by looo »

I wonder why the arguments for getting the python lib directory are needed.
https://github.com/NGSolve/netgen/blob/ ... s.txt#L115

Code: Select all

get_python_lib(1,0,'')
While this works on linux, it breaks the python-bindings-installation for windows. Using the function without arguments works for windows+conda.
Post Reply