View Issue Details

IDProjectCategoryView StatusLast Update
0033319CommunityOCCT:Codingpublic2024-05-21 15:38
Reporterreciprocal Assigned Todpasukhi  
PrioritynormalSeveritymajor 
Status resolvedResolutionopen 
PlatformLinuxOSDebian 8.0 
Product Version7.8.1 
Target VersionUnscheduled 
Summary0033319: Coding - Static linking fails with unresolved symbols due to linking order and missing transitive dependencies
DescriptionThe absence of target_link_libraries calls for static libraries caused CMake to fail
in modeling the link dependencies correctly.
This fix ensures that CMake correctly exports the dependencies in OpenCASCADEConfig.cmake and
resolves downstream linking errors for projects that link against static OpenCASCADE libraries.
Steps To ReproducePerform a static cmake build of opencascade on linux:
cmake -DCMAKE_INSTALL_PREFIX=/opencascade-install -DBUILD_LIBRARY_TYPE Static ${OCCT_SOURCE_DIR} && make -j install


Build a downstream cmake project which links against OpenCASCADE, e.g.:

cmake_minimum_required(VERSION 3.10)
project(DownstreamProject)

# Find the OpenCASCADE package
find_package(OpenCASCADE REQUIRED)

# Add the executable for the downstream project
add_executable(downstream_project main.cpp)

# Link the OpenCASCADE libraries
target_link_libraries(downstream_project PRIVATE ${OpenCASCADE_LIBRARIES})


cd downstream_project
mkdir build
cd build
cmake -DCMAKE_PREFIX_PATH=/opencascade-install ..
make
TagsNo tags attached.
Test case number

Activities

git

2023-01-19 18:29

administrator   ~0112888

Branch CR33319 has been created by reciprocal.

SHA-1: 988ca7b1c18ca3237953352755e53ed0af9c4910


Detailed log of new commits:

Author: Manuel Massing
Date: Thu Jan 19 15:17:22 2023 +0100

    0033319: Build System - fix static cmake build on linux

dpasukhi

2023-01-19 22:47

administrator   ~0112890

Last edited: 2023-01-19 22:55

Dear @reciprocal
Can you update "src/ExpToCasExe/EXTERNLIB" with newline in the end of the file?
And can you share more information about compiler(version)?
And if it is possible, update commiter's name with you profile name - reciprocal?

As for a commit message, please use the next template

<summary>
[ // recommended to add
<empty line>
<description>
]
So, the result is:
0033319: Coding - Static linking fails with unresolved symbols due to linking order

Updated external libs of ExpToCas with threads dependensies
Reorder ExpToCas external libs to fix problem with searching symbols

reciprocal

2023-01-20 12:27

developer   ~0112893

Hi dpasukhi,
thanks for your input.

Is OCCT:Coding in fact the right category? I couldn't find any category related to the build
system.

The real issue for the static linking problems under cmake was that link dependencies
for static libraries were not being added at all in the cmake build. To correctly export OpenCascadeTargets.cmake
and allow for downstream projects to correctly link the static version of OpenCascade, it is crucial to model
these dependencies. Many of the libraries listed in MODULES become redundant if the dependencies are
modeled correctly, as they are actually transitive dependencies. Do you know how WOK / genproj handles
transitive dependencies? Should I leave my modifications in for the genproj case? It is unclear if genproj can model transitive dependencies,
but it it can, that raises the question of why they were added to MODULES in the first place.

reciprocal

2023-01-20 12:47

developer   ~0112894

btw, compiler was gcc (Debian 10.2.1-6) 10.2.1 20210110, but static linking behaviour has not changed since ... i don't know ... decades, so I am pretty sure it is not limited to a
specific version or even compiler (I'm guessing the clang linker shows the same behaviour).

git

2023-01-20 12:49

administrator   ~0112895

Branch CR33319 has been updated forcibly by reciprocal.

SHA-1: 6d6f364d19ea90bf90cf4fe46b67113c9088f4ea

git

2023-01-20 12:50

administrator   ~0112896

Branch CR33319 has been updated forcibly by reciprocal.

SHA-1: efe38d0ee77c37707c98ac3c65cb969a0691e32a

reciprocal

2023-01-20 13:05

developer   ~0112898

@ski, I saw that you removed the static library dependencies originally, so you may want to comment/review this.

dpasukhi

2023-01-20 13:15

administrator   ~0112899

Dear @reciprocal. Thank you for your investigation.
The transitive dependencies are not linking.
Thank you for compiler info. It is necessary to reproducing.
The problem look very strange. The removing linking is a bug. We need to analyze it.

As for a commit, please update first line of the commit message with the equal name with summary of the ticket. And it would be nice to update the name of the commiter to the same with your nickname (reciprocal).

Updating occt_toolkit.cmake is very responsible thing. We need to check from our side all conditions of the changing.

dpasukhi

2023-01-20 13:20

administrator   ~0112900

As for a ExpToCasExe it will be removed from the XDE package and moved to the own module the same with tool module.
And it will be not build by default.

dpasukhi

2023-02-03 19:15

administrator   ~0113068

Dear @reciprocal.
What plan with current ticket?
You plan to do it by yourself? Or awaiting for review from our side?
Or you assign current ticket to us?

git

2024-05-21 13:14

administrator   ~0115864

Branch CR33319 has been updated forcibly by reciprocal.

SHA-1: 01e9df69fe176b57b68f81cf56fbcd8c595187c1

reciprocal

2024-05-21 13:18

developer   ~0115865

Hi @dpasukhi,
sorry, this got lost by the wayside. As this issue is still present in current OpenCascade (7.8.1), I have rebased the PR on V7_8_1,
and would appreciate if the PR could be reviewed/merged.

dpasukhi

2024-05-21 13:26

administrator   ~0115866

@reciprocal
Thank you. I lost this ticket too :(
Yes, for sure I will try to process this ticket. Currently we updating CMake, but you changes useful)
As for a rebasing, better to use master.
We have 2 way of versioning: dev and no dev.
Master - dev version, tag that have no _0 at the end are just maintained and created on maintained release time as a cherry picks from master only safety changes.

git

2024-05-21 13:33

administrator   ~0115867

Branch CR33319 has been updated forcibly by reciprocal.

SHA-1: 0533be1c65c52b1d1a641ea21a90f01e0a255311

reciprocal

2024-05-21 13:34

developer   ~0115868

Thanks, Understood - I've rebased the patch on master.

Issue History

Date Modified Username Field Change
2023-01-19 18:26 reciprocal New Issue
2023-01-19 18:26 reciprocal Assigned To => kgv
2023-01-19 18:29 git Note Added: 0112888
2023-01-19 22:47 dpasukhi Note Added: 0112890
2023-01-19 22:48 dpasukhi Note Edited: 0112890
2023-01-19 22:52 dpasukhi Summary Static linking fails with unresolved symbols due to linking order => Coding - Static linking fails with unresolved symbols due to linking order
2023-01-19 22:52 dpasukhi Steps to Reproduce Updated
2023-01-19 22:55 dpasukhi Note Edited: 0112890
2023-01-20 12:27 reciprocal Note Added: 0112893
2023-01-20 12:47 reciprocal Note Added: 0112894
2023-01-20 12:49 git Note Added: 0112895
2023-01-20 12:50 git Note Added: 0112896
2023-01-20 13:05 reciprocal Note Added: 0112898
2023-01-20 13:15 dpasukhi Note Added: 0112899
2023-01-20 13:20 dpasukhi Note Added: 0112900
2023-01-20 16:38 reciprocal Summary Coding - Static linking fails with unresolved symbols due to linking order => Coding - Static linking fails with unresolved symbols due to linking order and missing transitive dependencies
2023-02-03 19:15 dpasukhi Note Added: 0113068
2023-03-06 19:21 ebelouso Target Version 7.7.1 => Unscheduled
2024-05-21 13:14 git Note Added: 0115864
2024-05-21 13:18 reciprocal Note Added: 0115865
2024-05-21 13:25 reciprocal Assigned To kgv => dpasukhi
2024-05-21 13:25 reciprocal Status new => resolved
2024-05-21 13:25 reciprocal Steps to Reproduce Updated
2024-05-21 13:25 reciprocal Steps to Reproduce Updated
2024-05-21 13:26 dpasukhi Note Added: 0115866
2024-05-21 13:27 reciprocal Severity minor => major
2024-05-21 13:27 reciprocal Product Version 7.7.0 => 7.8.1
2024-05-21 13:30 reciprocal Description Updated
2024-05-21 13:33 git Note Added: 0115867
2024-05-21 13:34 reciprocal Note Added: 0115868