Installing OCCT libraries as Static Libraries fails on Ubuntu 22.04 (ExpToCasExe undefined reference to OSD_Process)

I am trying to build OCCT version 7.7.1 from this link https://git.dev.opencascade.org/gitweb/?p=occt.git;a=snapshot;h=ffce0d66bbaafe3a95984d0e61804c201b9995d2;sf=zip which was given in a comment from this page https://dev.opencascade.org/content/open-cascade-technology-771-maintenance-release#comments.

I am building static libraries with all USE variables (in cmake-gui) disabled and building all the modules except Visualization and Draw.

The build fails because of undefined reference errors when building the ExpToCasExe target (running make after having configured and generated with cmake-gui):

[100%] Linking CXX executable ../../lin64/gcc/bin/ExpToCasExe
/usr/bin/ld: ../../lin64/gcc/lib/libTKExpress.a(Express.cxx.o): in function `Express::WriteFileStamp(std::ostream&)':
Express.cxx:(.text+0xb4): undefined reference to `OSD_Process::OSD_Process()'
/usr/bin/ld: Express.cxx:(.text+0xbc): undefined reference to `OSD_Process::SystemDate()'
/usr/bin/ld: Express.cxx:(.text+0xe5): undefined reference to `OSD_Environment::OSD_Environment(TCollection_AsciiString const&)'
/usr/bin/ld: Express.cxx:(.text+0xfd): undefined reference to `OSD_Environment::Value()'
/usr/bin/ld: Express.cxx:(.text+0x19f): undefined reference to `OSD_Process::UserName()'
/usr/bin/ld: ../../lin64/gcc/lib/libTKExpress.a(Express_Entity.cxx.o): in function `Express_Entity::writeIncludes(std::ostream&) const':   
Express_Entity.cxx:(.text+0x1ebd): undefined reference to `OSD_Directory::OSD_Directory(OSD_Path const&)'
/usr/bin/ld: Express_Entity.cxx:(.text+0x1ec8): undefined reference to `OSD_Directory::Build(OSD_Protection const&)'
/usr/bin/ld: ../../lin64/gcc/lib/libTKExpress.a(Express_Entity.cxx.o): in function `Express_Entity::GenerateClass() const':
Express_Entity.cxx:(.text+0x9b67): undefined reference to `OSD_Directory::OSD_Directory(OSD_Path const&)'
/usr/bin/ld: Express_Entity.cxx:(.text+0x9b72): undefined reference to `OSD_Directory::Build(OSD_Protection const&)'
/usr/bin/ld: Express_Entity.cxx:(.text+0xb62e): undefined reference to `OSD_Directory::OSD_Directory(OSD_Path const&)'
/usr/bin/ld: Express_Entity.cxx:(.text+0xb63e): undefined reference to `OSD_Directory::Build(OSD_Protection const&)'
/usr/bin/ld: Express_Entity.cxx:(.text+0xc3b6): undefined reference to `OSD_Directory::OSD_Directory(OSD_Path const&)'
/usr/bin/ld: Express_Entity.cxx:(.text+0xc3d3): undefined reference to `OSD_Directory::Build(OSD_Protection const&)'
/usr/bin/ld: ../../lin64/gcc/lib/libTKExpress.a(Express_Enum.cxx.o): in function `Express_Enum::GenerateClass() const':
Express_Enum.cxx:(.text+0x4f4): undefined reference to `OSD_Directory::OSD_Directory(OSD_Path const&)'
/usr/bin/ld: Express_Enum.cxx:(.text+0x4ff): undefined reference to `OSD_Directory::Build(OSD_Protection const&)'
/usr/bin/ld: ../../lin64/gcc/lib/libTKExpress.a(Express_Select.cxx.o): in function `Express_Select::generateSelectMember(opencascade::handle<TColStd_HSequenceOfInteger> const&) const':
Express_Select.cxx:(.text+0x33c): undefined reference to `OSD_Directory::OSD_Directory(OSD_Path const&)'
/usr/bin/ld: Express_Select.cxx:(.text+0x347): undefined reference to `OSD_Directory::Build(OSD_Protection const&)'
/usr/bin/ld: ../../lin64/gcc/lib/libTKExpress.a(Express_Select.cxx.o): in function `Express_Select::GenerateClass() const':
Express_Select.cxx:(.text+0x193e): undefined reference to `OSD_Directory::OSD_Directory(OSD_Path const&)'
/usr/bin/ld: Express_Select.cxx:(.text+0x1949): undefined reference to `OSD_Directory::Build(OSD_Protection const&)'
collect2: error: ld returned 1 exit status
make[2]: *** [src/ExpToCasExe/CMakeFiles/ExpToCasExe.dir/build.make:132: lin64/gcc/bin/ExpToCasExe-7.7.1] Error 1
make[1]: *** [CMakeFiles/Makefile2:2299: src/ExpToCasExe/CMakeFiles/ExpToCasExe.dir/all] Error 2
make: *** [Makefile:136: all] Error 2

I specifically downloaded this version because here: https://dev.opencascade.org/content/open-cascade-technology-771-maintenance-release it is stated this problem was fixed: 33235: Configuration - Solving the problem with static building of ExpToCasExe

Any tips or help is appreciated.

PS: I can see some symbols like OSD_Process are defined in libTKernel.a but maybe for some reason ExpToCasExe target does not link to it? Anyway I do NOT need this executable. Just all the .a files.

Dmitrii Pasukhin's picture

Hello,

I am very sorry for your negative experience. I recommend you to change the file "occt/adm/MODULES" by removing the projects "TKExpress" and "ExpToCasExe" from "DataExchange".
In the 7.7.2 release we will fix this problem and put these projects in a separate module. This is in case you don't need these modules. They are external and our other projects do not depend on them. Otherwise, let me know and I'll fix the problem shortly. 

But can you share a your gcc version for accurate reproduction.

Best regards, Dmitrii.

lucmobz's picture

Thanks, I appreciate the swift answer.

gcc (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0
g++ (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0

I am testing it on this simple Dockerfile (ubuntu:latest gives me an lsb_release -a output of 22.04)

FROM ubuntu:latest

ENV DEBIAN_FRONTEND=noninteractive
ENV DISPLAY=host.docker.internal:0.0

RUN apt-get update && apt-get upgrade -y
RUN apt-get install -y build-essential gdb valgrind git cmake cmake-gui

Edit: your suggestion worked. Thanks.

benj5378's picture

Hi, I am just noting that this is still an issue on 7.8.0 - I removed TKExpress from occt/adm/MODULES, but I cannot find DataExchange from where ExpToCasExehas to be removed. Could you specify further? Thanks.

Ubuntu 22.10
g++ (Ubuntu 12.2.0-3ubuntu1) 12.2.0
g++ (Ubuntu 12.2.0-3ubuntu1) 12.2.0
Dmitrii Pasukhin's picture

Hello, on 7.8.0 dev you need to disable "BUILD_MODULE_DETools"

Best regards, Dmitrii.