OCE 0.18 -> OCCT 7.4.0: Crap ton of namespace issues

Having trouble installing or compiling FreeCAD? Get help here.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
hobbes1069
Posts: 291
Joined: Wed Nov 09, 2011 3:49 pm
Location: Southaven, MS

OCE 0.18 -> OCCT 7.4.0: Crap ton of namespace issues

Post by hobbes1069 »

Since OCE appears to be no longer maintained with OCCT's change to a FOSS license I'm working on moving FreeCAD on Fedora from OCE to OCCT but ran into some weird issues.

After switching from OCE to OCCT and removing netgen-mesher (since it doesn't build with current OCCT) I've started getting a ton of errors like this:

Code: Select all

In file included from /builddir/build/BUILD/FreeCAD-0.18.3/src/3rdParty/salomesmesh/src/MEFISTO2/aptrte.cpp:27:
/builddir/build/BUILD/FreeCAD-0.18.3/src/3rdParty/salomesmesh/inc/Rn.h:183:10: error: 'istream' does not name a type
  183 |   friend istream& operator >>(istream& f,  R4 & P)
      |          ^~~~~~~
/builddir/build/BUILD/FreeCAD-0.18.3/src/3rdParty/salomesmesh/inc/Rn.h:188:10: error: 'istream' does not name a type
  188 |   friend istream& operator >>(istream& f,  R4 * P)
      |          ^~~~~~~
For both istream, ofstream, endl, etc. Patching to "std::<function>" for all instances fixes it but why is this necessary? Why would changing from OCE to OCCT affect namespace?

I also got a linker error that looks to be opengl related... weird.

Anyone know what the heck is going on?

Fedora Rawhide (f32)
gcc 9.2.1.

Thanks,
Richard
User avatar
kkremitzki
Veteran
Posts: 2511
Joined: Thu Mar 03, 2016 9:52 pm
Location: Illinois

Re: OCE 0.18 -> OCCT 7.4.0: Crap ton of namespace issues

Post by kkremitzki »

It's actually an OCCT 7.3.0 -> 7.4.0 change: https://www.opencascade.com/doc/occt-7. ... dnamespace

I encountered some resistance working on the aforementioned upgrade myself and haven't gotten the Debian/Ubuntu packaging updated for it yet. You would have better luck if you could use 7.3.0 for the time being.
Like my FreeCAD work? I'd appreciate any level of support via Patreon, Liberapay, or PayPal! Read more about what I do at my blog.
User avatar
tanderson69
Veteran
Posts: 1626
Joined: Thu Feb 18, 2010 1:07 am

Re: OCE 0.18 -> OCCT 7.4.0: Crap ton of namespace issues

Post by tanderson69 »

occt had some 'using' declarations in a header file. A 'no no'. These were carrying over to any project including it. They have since fixed this and any project that has accidentally took advantage of this will have to be fixed.

http://git.dev.opencascade.org/gitweb/? ... 2dc6001812
User avatar
hobbes1069
Posts: 291
Joined: Wed Nov 09, 2011 3:49 pm
Location: Southaven, MS

Re: OCE 0.18 -> OCCT 7.4.0: Crap ton of namespace issues

Post by hobbes1069 »

Unless it's been fixed in master I probably should submit my patch for fixing all the namespace issues. Also, I got my linker problem sorted.

I was using:

Code: Select all

-DOpenGL_GL_PREFERENCE=GLVND
and getting away with it due to transitive linking of libGL with OCE, but when I switched to OpenCASCADE apparently I wasn't getting it for free anymore.

After hitting my head against the wall and patching freecad to link with libGLU or libGL and getting the same error I tried changing the CMake option to

Code: Select all

-DOpenGL_GL_PREFERENCE=LEGACY
No problems after that but it would probably be a good idea for FreeCAD to use the GL Vendor Neutral path at some point.

Thanks,
Richard
nahshon
Posts: 225
Joined: Wed Jul 24, 2013 8:06 pm

Re: OCE 0.18 -> OCCT 7.4.0: Crap ton of namespace issues

Post by nahshon »

Are there any pre-compiled RPMS for OCCT? I would like to try them with Fedora 31.
User avatar
hobbes1069
Posts: 291
Joined: Wed Nov 09, 2011 3:49 pm
Location: Southaven, MS

Re: OCE 0.18 -> OCCT 7.4.0: Crap ton of namespace issues

Post by hobbes1069 »

I just recently got them built and they are not yet in stable. I was going to push them with FreeCAD 0.18.4 which I just built today.

If you want to pull them manually you can get them from koji:

https://koji.fedoraproject.org/koji/pac ... geID=30181

Thanks,
Richard
nahshon
Posts: 225
Joined: Wed Jul 24, 2013 8:06 pm

Re: OCE 0.18 -> OCCT 7.4.0: Crap ton of namespace issues

Post by nahshon »

Thanks! I installed these RPMS in Fedora 31 running under VirtualBox. I Could compile and start FreeCAD 0.19 (latest from GitHub).

Since git commit a7d9661b1d FreeCAD failed to compile with OCE on Fedora because Standard_Handle.hxx was missing. Installing OCCT fixed the issue for me.
User avatar
DeepSOIC
Veteran
Posts: 7896
Joined: Fri Aug 29, 2014 12:45 am
Location: used to be Saint-Petersburg, Russia

Re: OCE 0.18 -> OCCT 7.4.0: Crap ton of namespace issues

Post by DeepSOIC »

tanderson69 wrote: Thu Oct 31, 2019 1:35 pm occt had some 'using' declarations in a header file. A 'no no'.
They are using namespace::identifier, not using namespace. I can't seem to find anyone say it's a no-no, they usually say it is actually the only good way of using using.
https://akrzemi1.wordpress.com/2019/03/ ... space-std/ for example.
So, why is it bad?
User avatar
tanderson69
Veteran
Posts: 1626
Joined: Thu Feb 18, 2010 1:07 am

Re: OCE 0.18 -> OCCT 7.4.0: Crap ton of namespace issues

Post by tanderson69 »

DeepSOIC wrote: Thu Nov 07, 2019 10:13 am So, why is it bad?
The blog you linked to is about 'using directives' vs 'using declarations' and kind of glosses over headers vs source files. Stack overflow is a good place for this kind of information.
https://stackoverflow.com/questions/584 ... -c-headers
Post Reply