Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compile against opencascade 7.8.0 fails #4393

Closed
adrianinsaval opened this issue Mar 4, 2024 · 12 comments · Fixed by #4398
Closed

compile against opencascade 7.8.0 fails #4393

adrianinsaval opened this issue Mar 4, 2024 · 12 comments · Fixed by #4398

Comments

@adrianinsaval
Copy link
Contributor

I get this error when trying to compile against occt 7.8:

ninja: error: '/app/lib/libTKSTEP.so', needed by 'ifcwrap/_ifcopenshell_wrapper.so', missing and no known rule to make it
Error: module IfcOpenShell: Child process exited with code 1

this is because some occt libs have been reorginized, see https://dev.opencascade.org/doc/overview/html/occt__upgrade.html#upgrade_occt780

cc @bgbsww while this is not a hard dependency for freecad main we ship it in our bundles, I think it's required by some arch wb functionalities and/or some of the addons that will be combined into it (@yorikvanhavre would know better what it's used for). If you have some spare time it would be nice to get help in migrating this to occt 7.8 too

@bgbsww
Copy link

bgbsww commented Mar 4, 2024

~~ Hmm. I bet the issue is https://github.com/FreeCAD/FreeCAD/blob/e0ecd213b2c34673cb58b9ee04f3a3db152e4b09/src/Mod/TechDraw/App/Makefile.am#L45 which doesn't use the libraries that were located at ~~ https://github.com/FreeCAD/FreeCAD/blob/e0ecd213b2c34673cb58b9ee04f3a3db152e4b09/cMake/FindOCC.cmake#L159-L164 is a useful example. I don't understand at a glance why there's a standalone Makefile.am here or what the correct path is - presumably update this to cmake? Looks like an anomoly. Man, I need to clear my eyes more carefully first thing in the morning. This is a separate project. In any case, the advice below stands.

@aothms
Copy link
Member

aothms commented Mar 4, 2024

We have a hardcoded list here.

set(OPENCASCADE_LIBRARY_NAMES
TKernel TKMath TKBRep TKGeomBase TKGeomAlgo TKG3d TKG2d TKShHealing TKTopAlgo TKMesh TKPrim TKBool TKBO
TKFillet TKSTEP TKSTEPBase TKSTEPAttr TKXSBase TKSTEP209 TKIGES TKOffset TKHLR
# @todo investigate the exact conditions when this is necessary
TKBin
)

Some help would be very welcome if you know already what to do for 7.8 compatibility.

@bgbsww
Copy link

bgbsww commented Mar 4, 2024

Yes, see the second link above. You need to pull the TKIGES, TKSTEP, TKSTEPAttr, TKSTEP209 and TKSTEPBase out of the OPENCASCADE_LIBRARY_NAMES and then add a following if/else/endif clause that inserts either those five, or else TKDESTEP and TKDEIGES depending on the OCC_VERSION_STRING.


 set(OPENCASCADE_LIBRARY_NAMES 
     TKernel TKMath TKBRep TKGeomBase TKGeomAlgo TKG3d TKG2d TKShHealing TKTopAlgo TKMesh TKPrim TKBool TKBO 
     TKFillet  TKXSBase TKOffset TKHLR 
  
     # @todo investigate the exact conditions when this is necessary 
     TKBin 
 ) 
  if(OCC_VERSION_STRING VERSION_LESS 7.8.0)
    list(APPEND OPENCASCADE_LIBRARY_NAMES  TKIGES TKSTEPBase TKSTEPAttr TKSTEP209 TKSTEP)
  else(OCC_VERSION_STRING VERSION_LESS 7.8.0)
    list(APPEND OPENCASCADE_LIBRARY_NAMES TKDESTEP TKDEIGES)
  endif(OCC_VERSION_STRING VERSION_LESS 7.8.0)

I'd just do that, except I don't know how to run this build or test it yet, so if somebody else is already set, maybe they can? Or educate me.

@adrianinsaval
Copy link
Contributor Author

adrianinsaval commented Mar 5, 2024

looks like it works, although I did had to add the logic to define OCC_VERSION_STRING, copied straight from freecad's FIndOCC. Thanks!

@bgbsww
Copy link

bgbsww commented Mar 5, 2024

Oh, yeah. Duh. CMake isn't going to magically define OCC package strings. That's the right approach, glad you got it all going.

@yorikvanhavre
Copy link
Contributor

yorikvanhavre commented Mar 6, 2024

BTW - given the rapid evolution of IfcOpenShell and thanks to the build service it has, I'm working on a tool to allow users to download and update their version of IfcOpenShell on the fly, from inside FreeCAD. We could then stop bundling it with FreeCAD.

@adrianinsaval to reply your question above, IfcOpenShell is used 1) to import/export IFC files in Arch/BIM WB, and 2) as an engine when using NativeIFC. It is never a hard requirement to use Arch/BIM, only if you want to work with IFC.

The fact that it is bundled in our installer comes from a time when it was somewhat harder to get your hands on a compatible build of IfcOpenShell, and many windows users had asked for it... And we can't say no to users... 😅

@adrianinsaval
Copy link
Contributor Author

The fact that it is bundled in our installer comes from a time when it was somewhat harder to get your hands on a compatible build of IfcOpenShell, and many windows users had asked for it... And we can't say no to users... 😅

don't we need to always match the occt and python versions?

@aothms
Copy link
Member

aothms commented Mar 7, 2024

The typical way shape data is exchanged between ifcopenshell and other libs is through string serializations of the occt topology. So there isn't a strict requirement on matching occt versions. Somewhere recently (7.7? / 7.8?) a new version v3 of the occt serialization format is introduced though, so that might result in incompatibilities if one keeps using the statically linked ifcopenshell binaries with 7.5. But the scenarios of passing topology data from freecad to ifcopenshell are probably limited.

@yorikvanhavre
Copy link
Contributor

But the scenarios of passing topology data from freecad to ifcopenshell are probably limited.

Indeed, that does not happen. For that, we use the API to create IFC objects. Serialization to strings is only used for ifcopenshell -> freecad.

@martin-bernhard
Copy link

The typical way shape data is exchanged between ifcopenshell and other libs is through string serializations of the occt topology. So there isn't a strict requirement on matching occt versions. Somewhere recently (7.7? / 7.8?) a new version v3 of the occt serialization format is introduced though, so that might result in incompatibilities if one keeps using the statically linked ifcopenshell binaries with 7.5. But the scenarios of passing topology data from freecad to ifcopenshell are probably limited.

To avoid incompatibility between serialized shapes from OCCT, you can explicitly use the v1 format, even with OCCT 7.8, so that it can be read with older versions of OCCT, too.

@aothms
Copy link
Member

aothms commented Jun 14, 2024

To avoid incompatibility between serialized shapes from OCCT, you can explicitly use the v1 format, even with OCCT 7.8, so that it can be read with older versions of OCCT, too.

True, but that requires a change in the IfcOpenShell C++ code, which is troublesome for most users.

@martin-bernhard if you have the code ready a PR would be appreciated :)

@martin-bernhard
Copy link

I dont't have a running version, but you should mainly replace line 245 by the following line:

BRepTools::Write(s, sstream, true, false, TopTools_FormatVersion_VERSION_1);

The constant TopTools_FormatVersion_VERSION_1 is defined in the TopTools_FormatVersion.hxx header file with the integer value 1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants