OCCT 7.8 - Static Build Failure

Hi, I'm trying to build OCCT 7.8.0 statically (via spack) and am running into errors. Here is some system information:

linux-centos7-zen2
gcc/9.3.0
cmake/3.23.1

I edited the spack package configuration for opencascade (spack/var/spack/repos/builtin/packages/opencascade/package.py) by adding this:

args.append("-DBUILD_LIBRARY_TYPE=STATIC")
args.append(self.define("BUILD_MODULE_DETools", False))

Finally, I build the package using this command:

>> spack install -j 32 opencascade@7.8.0 % gcc@9.3.0

Before adding the BUILD_MODULE_DETools flag it gave this error:

6718 ../../lin64/gcc/lib/libTKExpress.a(Express.cxx.o): In function `Express::WriteFileStamp(std::ostream&)':
>> 6719 Express.cxx:(.text+0x9d): undefined reference to `OSD_Process::OSD_Process()'
>> 6720 Express.cxx:(.text+0xa5): undefined reference to `OSD_Process::SystemDate()'

Now, it gives this error:

../../lin64/gcc/lib/libTKDESTEP.a(STEPControl_ActorRead.cxx.o): In function `STEPControl_ActorRead::STEPControl_ActorRead(opencascade::handle<Interface_InterfaceModel> const&)':
STEPControl_ActorRead.cxx:(.text+0x58d): undefined reference to `Transfer_ActorOfTransientProcess::Transfer_ActorOfTransientProcess()'
../../lin64/gcc/lib/libTKDESTEP.a(STEPControl_ActorRead.cxx.o): In function `opencascade::type_instance<Transfer_ActorOfTransientProcess>::get()':

I'm out of ideas.

Thank you,
Travis

Dmitrii Pasukhin's picture

Hello, the issue with ExpToCas fixed in latest master.

Well, the build looks strange. Could you please remove the build cache. Looks like internal complier issue if some build processes was stopped. Could you just 'make clean' then make rebuild?

I'm not familiar with spack. If it not clears the build cache, please do it manually.

Best regards, Dmitrii.

Scott McNab's picture

Hello

FYI I am having the exact same error trying to build the 7.8.1 release on Ubuntu-22.04, using cmake 3.22.1 and gcc 11.4.0.

From a clean archive extraction and build directory, the command I'm using to build is:

$ mkdir BUILD
$ cd BUILD
$ cmake -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_INSTALL_PREFIX:PATH=/home/scott/dev/thirdparty-linux/OCCT-7_8_1 -DBUILD_SHARED_LIBS=OFF -DBUILD_CPP_STANDARD="C++17" -DCMAKE_CXX_FLAGS="-Wno-array-bounds" -DBUILD_LIBRARY_TYPE="Static" -DBUILD_MODULE_DETools=OFF -DBUILD_MODULE_DataExchange=OFF ..
$ make -j8

I have attached a log of the build output and errors.

Do you know how I can fix / workaround these errors with static build?

Thanks!

Attachments: 
Dmitrii Pasukhin's picture

Hello, I assume the issue on DCMAKE_POSITION_INDEPENDENT_CODE=ON. Could you remove that setting and check?

It is totally not related with the original issue.

Best regards, Dmitrii.

Scott McNab's picture

FYI I tried removing -DCMAKE_POSITION_INDEPENDENT_CODE=ON from the cmake command, but still get the same build errors.

$ cmake -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_INSTALL_PREFIX:PATH=/home/scott/dev/thirdparty-linux/OCCT-7_8_1/ -DBUILD_SHARED_LIBS=OFF -DBUILD_LIBRARY_TYPE="Static" -DBUILD_MODULE_DETools=OFF -DBUILD_MODULE_DataExchange=OFF ..

I won't attach a new build log file as it is essentially the same, but the errors all occur attempting to link DRAWEXE. If I remove DRAWEXE from adm/MODULES then the build completes successfully.

Edit: With DRAWEXE excluded it also builds successfully with -DCMAKE_POSITION_INDEPENDENT_CODE=ON enabled.

Dmitrii Pasukhin's picture

Thank you. I will tes it more careful. It is first time when I hear about problem with DRAW build.

Best regards, Dmitrii.

Travis D's picture

Hi,

I modified the spack recipe to this (near line 196) to get it to build correctly:

spack/var/spack/repos/builtin/packages/opencascade/package.py

args = []

args.append("-DBUILD_LIBRARY_TYPE=Static")
args.append("-DBUILD_MODULE_DETools=OFF")
args.append("-DBUILD_MODULE_Draw=OFF")

So, disable DETools and Draw and enable Static is the trick. This also worked using cmake to build statically on MacOS.

Dmitrii Pasukhin's picture

Please be careful, using static version of OCCT is limited under LGPL 2.1 license. Please be aware of the license point.

Best regards, Dmitrii.