ana(conda) windows packaging

Having trouble installing or compiling FreeCAD? Get help here.
peterl94
Posts: 1000
Joined: Thu May 23, 2013 7:31 pm
Location: United States

Re: ana(conda) windows packaging

Postby peterl94 » Sun Mar 26, 2017 12:40 pm

looo wrote:building with everything disabled gives a linking problem with PyCXX
I was able to solve that by simply exporting the symbols.

Code: Select all

diff --git a/src/CXX/Python3/IndirectPythonInterface.hxx b/src/CXX/Python3/IndirectPythonInterface.hxx
index 5ffaf43..a4c0cf4 100644
--- a/src/CXX/Python3/IndirectPythonInterface.hxx
+++ b/src/CXX/Python3/IndirectPythonInterface.hxx
@@ -175,8 +175,8 @@ PYCXX_EXPORT int &_Py_TabcheckFlag();
 PYCXX_EXPORT int &_Py_VerboseFlag();
 PYCXX_EXPORT int &_Py_UnicodeFlag();
 
-void _XINCREF( PyObject *op );
-void _XDECREF( PyObject *op );
+PYCXX_EXPORT void _XINCREF( PyObject *op );
+PYCXX_EXPORT void _XDECREF( PyObject *op );
 
 PYCXX_EXPORT char *__Py_PackageContext();
 };
diff --git a/src/CXX/IndirectPythonInterface.cxx b/src/CXX/IndirectPythonInterface.cxx
index dd63bf3..8d23ce5 100644
--- a/src/CXX/IndirectPythonInterface.cxx
+++ b/src/CXX/IndirectPythonInterface.cxx
@@ -427,7 +427,7 @@ PYCXX_EXPORT int &_Py_VerboseFlag()                  { return *ptr_Py_VerboseFla
         _Py_Dealloc((PyObject *)(op))
 #endif
 
-void _XINCREF( PyObject *op )
+PYCXX_EXPORT void _XINCREF( PyObject *op )
 {
     // This function must match the contents of Py_XINCREF(op)
     if( op == NULL )
@@ -440,7 +440,7 @@ void _XINCREF( PyObject *op )
 
 }
 
-void _XDECREF( PyObject *op )
+PYCXX_EXPORT void _XDECREF( PyObject *op )
 {
     // This function must match the contents of Py_XDECREF(op);
     if( op == NULL )

The two other linking errors I haven't been able to fix yet are as follows.

Code: Select all

DocumentObserverPython.cpp.obj : error LNK2019: unresolved external symbol "bool __cdecl Py::operator==(class Py::Object const &,class Py::Object const &)"  referenced in function "public: static void __cdecl App::DocumentObserverPython::removeObserver(class Py::Object const &)" 
PropertyFile.cpp.obj : error LNK2019: unresolved external symbol "struct _typeobject PyFileIO_Type" (?PyFileIO_Type@@3U_typeobject@@A) referenced in function "public: virtual void __cdecl App::PropertyFileIncluded::setPyObject(struct _object *)"
I remember previously figuring out that PyFileIO_Type is not exported on windows. I guess we are going to need to find a way to not use it. The operator== is something I haven't seen before.

I'm still building with everything disabled, so I haven't looked into the other errors yet.
peterl94
Posts: 1000
Joined: Thu May 23, 2013 7:31 pm
Location: United States

Re: ana(conda) windows packaging

Postby peterl94 » Sun Mar 26, 2017 1:06 pm

The operator== just needed to be exported too.

Code: Select all

diff --git a/src/CXX/Python3/Objects.hxx b/src/CXX/Python3/Objects.hxx
index 8f62eac..cf26be9 100644
--- a/src/CXX/Python3/Objects.hxx
+++ b/src/CXX/Python3/Objects.hxx
@@ -429,12 +429,12 @@ namespace Py
     };
 
     //------------------------------------------------------------
-    bool operator==( const Object &o1, const Object &o2 );
-    bool operator!=( const Object &o1, const Object &o2 );
-    bool operator>=( const Object &o1, const Object &o2 );
-    bool operator<=( const Object &o1, const Object &o2 );
-    bool operator<( const Object &o1, const Object &o2 );
-    bool operator>( const Object &o1, const Object &o2 );
+    PYCXX_EXPORT bool operator==( const Object &o1, const Object &o2 );
+    PYCXX_EXPORT bool operator!=( const Object &o1, const Object &o2 );
+    PYCXX_EXPORT bool operator>=( const Object &o1, const Object &o2 );
+    PYCXX_EXPORT bool operator<=( const Object &o1, const Object &o2 );
+    PYCXX_EXPORT bool operator<( const Object &o1, const Object &o2 );
+    PYCXX_EXPORT bool operator>( const Object &o1, const Object &o2 );
 
     //------------------------------------------------------------
 
 
Also, I don't think IndirectPythonInterface.cxx needs to be patched like I did above - just the header IndirectPythonInterface.hxx.
User avatar
sgrogan
Posts: 5636
Joined: Wed Oct 22, 2014 5:02 pm

Re: ana(conda) windows packaging

Postby sgrogan » Sun Mar 26, 2017 1:29 pm

looo wrote: building with everything enabled, smesh explains about a not possible conversation:
I get the exact thing on VC12 see here: viewtopic.php?f=4&t=18748#p158014
I am using all the same libs as I used to compile OCCT 7.0.0
Everything was/is working except the update of OCCT7
I don't know if this helps.
User avatar
looo
Posts: 3182
Joined: Mon Nov 11, 2013 5:29 pm

Re: ana(conda) windows packaging

Postby looo » Sun Mar 26, 2017 1:41 pm

@sgrogan
This solved this specific problem.

Code: Select all

diff --git a/src/3rdParty/salomesmesh/src/StdMeshers/StdMeshers_QuadToTriaAdaptor.cpp b/src/3rdParty/salomesmesh/src/StdMeshers/StdMeshers_QuadToTriaAdaptor.cpp
index 1832f48..3da106a 100644
--- a/src/3rdParty/salomesmesh/src/StdMeshers/StdMeshers_QuadToTriaAdaptor.cpp
+++ b/src/3rdParty/salomesmesh/src/StdMeshers/StdMeshers_QuadToTriaAdaptor.cpp
@@ -736,8 +736,10 @@ bool StdMeshers_QuadToTriaAdaptor::Compute(SMESH_Mesh&         aMesh,
     myElemSearcher = SMESH_MeshAlgos::GetElementSearcher( *meshDS );
 
   const SMESHDS_SubMesh * aSubMeshDSFace;
-  Handle(TColgp_HArray1OfPnt) PN = new TColgp_HArray1OfPnt(1,5);
-  Handle(TColgp_HArray1OfVec) VN = new TColgp_HArray1OfVec(1,4);
+  // Handle(TColgp_HArray1OfPnt) PN = new TColgp_HArray1OfPnt(1,5);
+  // Handle(TColgp_HArray1OfVec) VN = new TColgp_HArray1OfVec(1,4);
+  Handle_TColgp_HArray1OfPnt PN = new TColgp_HArray1OfPnt(1,5);
+  Handle_TColgp_HArray1OfVec VN = new TColgp_HArray1OfVec(1,4);
   vector<const SMDS_MeshNode*> FNodes(5);
   gp_Pnt PC;
   gp_Vec VNorm;
Maybe it would be better to use something like this in the header:

Code: Select all

occ::Handle<TColgp_HArray1OfPnt>
please help with my conda-packaging efforts: https://liberapay.com/looooo/
minimalistic blog: https://looooo.github.io/mini-blog/
User avatar
sgrogan
Posts: 5636
Joined: Wed Oct 22, 2014 5:02 pm

Re: ana(conda) windows packaging

Postby sgrogan » Sun Mar 26, 2017 1:44 pm

looo wrote:This specifics solved this problem.
Way cool! Maybe you could make a pull request and see what wmayer thinks?
This blocks me from upgrading to OCCT7.1 for the daily builds.
Thanks again for all this Windows work :)
User avatar
looo
Posts: 3182
Joined: Mon Nov 11, 2013 5:29 pm

Re: ana(conda) windows packaging

Postby looo » Sun Mar 26, 2017 2:07 pm

I think the best option regarding PyFileIO_Type is to replace it with PyIOBase_Type which should be also available with windows. But I can't find any reference how to link this _io library in. I can import the library from python, but I don't know where it is. As far as I know it is sepperated from the main library...

@sgrogan: I don't know this will really resolve the problem. It is strange that there is no issue with this on linux and mac.
please help with my conda-packaging efforts: https://liberapay.com/looooo/
minimalistic blog: https://looooo.github.io/mini-blog/
User avatar
sgrogan
Posts: 5636
Joined: Wed Oct 22, 2014 5:02 pm

Re: ana(conda) windows packaging

Postby sgrogan » Sun Mar 26, 2017 2:46 pm

looo wrote: @sgrogan: I don't know this will really resolve the problem. It is strange that there is no issue with this on linux and mac.
No C++ coder here, but I will look at wmayers occt7.0 port and see, if there was anything similar.
git commit bca7a186
User avatar
looo
Posts: 3182
Joined: Mon Nov 11, 2013 5:29 pm

Re: ana(conda) windows packaging

Postby looo » Sun Mar 26, 2017 4:57 pm

- added function to check if a PyObject is of pythonclass IOBase: https://github.com/looooo/FreeCAD_Conda ... tch#L20L28 . with this the minimal install is working for me.
- again modified the smesh Handle patch

With all libraries on I am now stuck at Smesh:

Code: Select all

[289/2926] Building CXX object src\3rdParty\salomesmesh\CM...Plugin.dir\src\NETGENPlugin\NETGENPlugin_NETGEN_3D.cpp.obj
FAILED: src/3rdParty/salomesmesh/CMakeFiles/NETGENPlugin.dir/src/NETGENPlugin/NETGENPlugin_NETGEN_3D.cpp.obj
.....
.....
C:\Users\fc-builder\Miniconda3\conda-bld\freecad_1490539705796\work\src\3rdParty\salomesmesh\src\NETGENPlugin\NETGENPlugin_NETGEN_3D.cpp(79): error C2375: "netgen::OCCGenerateMesh": Neudefinition; unterschiedliche Bindung
c:\users\fc-builder\miniconda3\conda-bld\freecad_1490539705796\_b_env\library\include\occ\occgeom.hpp(443): note: Siehe Deklaration von "netgen::OCCGenerateMesh"
C:\Users\fc-builder\Miniconda3\conda-bld\freecad_1490539705796\work\src\3rdParty\salomesmesh\src\NETGENPlugin\NETGENPlugin_NETGEN_3D.cpp(493): error C2568: "=": Auflösung der Funktionsüberladung nicht möglich
please help with my conda-packaging efforts: https://liberapay.com/looooo/
minimalistic blog: https://looooo.github.io/mini-blog/
User avatar
sgrogan
Posts: 5636
Joined: Wed Oct 22, 2014 5:02 pm

Re: ana(conda) windows packaging

Postby sgrogan » Sun Mar 26, 2017 5:34 pm

looo wrote:- again modified the smesh Handle patch
could this be the culprit https://github.com/FreeCAD/FreeCAD/blob ... or.hxx#L23?
Compare to this https://github.com/FreeCAD/FreeCAD/comm ... 7471992L39
User avatar
looo
Posts: 3182
Joined: Mon Nov 11, 2013 5:29 pm

Re: ana(conda) windows packaging

Postby looo » Sun Mar 26, 2017 5:52 pm

https://github.com/FreeCAD/FreeCAD/blob ... hxx#L36L37

I think so. But using Handle(..) is for sure the better way to "handle" this ;) See the patch we are using now:
https://github.com/looooo/FreeCAD_Conda ... mesh.patch
please help with my conda-packaging efforts: https://liberapay.com/looooo/
minimalistic blog: https://looooo.github.io/mini-blog/