Help linking against OCE

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
User avatar
shoogen
Posts: 2823
Joined: Thu Dec 01, 2011 5:24 pm

Help linking against OCE

Postby shoogen » Wed Feb 19, 2014 10:01 pm

I tried to add the bopcheck and bopargcheck of DRAWEXE to the Part module. I can compile and link. But I get unresolved sysmbols message when loading the part module.
What do I have to do besides adding headers to link against OCE?
jobermayr
Posts: 88
Joined: Fri Dec 02, 2011 4:39 pm
Location: Bavaria that's near Germany

Re: Help linking against OCE

Postby jobermayr » Wed Feb 19, 2014 10:29 pm

Try to add "TKTopTest" to "Part_LIBS" ...
jobermayr
Posts: 88
Joined: Fri Dec 02, 2011 4:39 pm
Location: Bavaria that's near Germany

Re: Help linking against OCE

Postby jobermayr » Wed Feb 19, 2014 10:57 pm

Oh no. It is:

static
Standard_Integer bopcheck (Draw_Interpretor&, Standard_Integer, const char** );

static
Standard_Integer bopargcheck (Draw_Interpretor&, Standard_Integer, const char** );


So you must do it via
void BOPTest::CheckCommands(Draw_Interpretor& theCommands)
(http://dev.opencascade.org/doc/refman/h ... bf728cc335)
jobermayr
Posts: 88
Joined: Fri Dec 02, 2011 4:39 pm
Location: Bavaria that's near Germany

Re: Help linking against OCE

Postby jobermayr » Sat Feb 22, 2014 10:30 pm

Can you manage it via BOPTest::CheckCommands or shall I ask OCE maintainers whether they agree with making bopcheck and bopargcheck PUBLIC?
User avatar
shoogen
Posts: 2823
Joined: Thu Dec 01, 2011 5:24 pm

Re: Help linking against OCE

Postby shoogen » Sat Feb 22, 2014 10:34 pm

jobermayr wrote:Can you manage it via BOPTest::CheckCommands or shall I ask OCE maintainers whether they agree with making bopcheck and bopargcheck PUBLIC?
I postponed the issue.
But what do you mean by public? It's LGPL 2.1.
jobermayr
Posts: 88
Joined: Fri Dec 02, 2011 4:39 pm
Location: Bavaria that's near Germany

Re: Help linking against OCE

Postby jobermayr » Sat Feb 22, 2014 10:56 pm

shoogen wrote:But what do you mean by public? It's LGPL 2.1.
static vs. PUBLIC functions:
static = internal, not visible and accessible from outside of the library
PUBLIC = default, visible and accessible from other libraries/binaries (see: "$ readelf --wide -s $lib")

You can switch behavior (static default, PUBLIC exception) via "-fvisibility=hidden".
User avatar
shoogen
Posts: 2823
Joined: Thu Dec 01, 2011 5:24 pm

Re: Help linking against OCE

Postby shoogen » Wed May 07, 2014 3:13 pm

Now i got the opposite problem. I'd like to link FreeCAD against an occt development version.
When loading Part.so if get an unresolved symbol error. After demangeling the culprit seems to be "Geom2dAdaptor_Curve::NbSamples() const"
What do i have to do now?
User avatar
shoogen
Posts: 2823
Joined: Thu Dec 01, 2011 5:24 pm

Re: Help linking against OCE

Postby shoogen » Wed May 07, 2014 3:58 pm

I spotted two problems so far.
1. The RPATH is wrong.

Code: Select all

//Path to a library.
OCC_LIBRARY:FILEPATH=/home/user/occt/lib

Code: Select all

$ objdump -x Mod/Part/Part.so |grep RPATH
  RPATH                /home/user/occt:/home/user/fc-build-occt/lib:/usr/lib/x86_64-linux-gnu:
the last element in the path "/lib" was silently removed
2. FreeCAD expects the libraries to have the suffix .so.8 whereas occt only created .so files.
User avatar
shoogen
Posts: 2823
Joined: Thu Dec 01, 2011 5:24 pm

Re: Help linking against OCE

Postby shoogen » Wed May 07, 2014 4:18 pm

After removing the default version from /usr/local i get linker errors

Code: Select all

/usr/bin/ld: cannot find -lTKFillet
User avatar
shoogen
Posts: 2823
Joined: Thu Dec 01, 2011 5:24 pm

[SOLVED] Re: Help linking against OCE

Postby shoogen » Wed May 07, 2014 4:38 pm

The following workaround did the trick

Code: Select all

@@ -461,6 +461,9 @@ else(FREECAD_LIBPACK_USE)
             message("-- OpenCASCADE include directory: ${OCC_INCLUDE_PATH}")
             message("-- OpenCASCADE shared libraries directory: ${OCC_LIB_PATH}
         endif()
+    set(OCC_LIBRARY_DIR
+        /home/user/occt/lib
+        )
     endif()
OS: Debian GNU/Linux 7.5 (wheezy)
Platform: 64-bit
Version: 0.14.3545 (Git)
Branch: master
Hash: 3b5cdda8792b13eaf17d77149589cca0cbeda1df
Python version: 2.7.3
Qt version: 4.8.2
Coin version: 3.1.3
SoQt version: 1.5.0
OCC version: 6.7.2
cron