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

Fix missing symbols for Simulink and LAPACK build #1682

Merged
merged 2 commits into from
Jul 13, 2023

Conversation

deslaughter
Copy link
Collaborator

This PR is ready to be merged

Feature or improvement description

When building the Simulink MEX file with CMake on Linux, the resulting shared library had unresolved symbols. This was due to the order in which the static libraries were specified in simulink/CMakeLists.txt. The GCC linker does one pass over the libraries and notes unresolved dependencies which can only be resolved by the succeeding libraries. This means that the most generic libraries (like NWTC-Library) need to appear at the end of the list.

Instead of leaving it up to the user to get the order right, the simulink/CMakeLists.txt file has been updated to link the libraries twice.

The same issue occurred when using USE_LOCAL_STATIC_LAPACK in that the BLAS libraries were linked before LAPACK so there were unresolved symbols. This has been fixed by reversing the order.

Also, the OpenFOAM libraries have been marked as STATIC.

Related issue, if one exists

#1010 and #1681

Impacted areas of the software

  • CMakeLists.txt
  • glue-codes/simulink/CMakeLists.txt
  • modules/openfoam/CMakeLists.txt

Additional supporting information

Changes were tested on NREL's Eagle HPC with GCC 12.1.0, Matlab R2020b, and Intel MKL by running the examples in glue-codes/simulink/examples. The following CMake configuration flag combinations were verified to work:

  • -DBUILD_OPENFAST_SIMULINK_API=ON and -DUSE_LOCAL_STATIC_LAPACK=ON: Note, this combination downloads, builds, and statically links the reference LAPACK from Netlib (MKL is not used)
  • -DBUILD_OPENFAST_SIMULINK_API=ON and -BLA_STATIC=ON and -DBLA_VENDOR=Intel10_64lp_seq: Note, this combination statically links the sequential version of the MKL into the MEX file. Issues were encountered linking the OpenMP version.

The Matlab root directory may need to be specified if CMake cannot find it automatically. This is accomplished by adding -DMatlab_ROOT_DIR=... during the CMake configuration step.

Additional CMake configuration options for BLAS and Matlab can be found at:

When building the Simulink MEX file with CMake on Linux, the resulting
shared library had unresolved symbols. This was due to the order in
which the static libraries were specified in simulink/CMakeLists.txt.
The GCC linker does one pass over the libraries and notes unresolved
dependencies which can only be resolved by the succeeding libraries.
This means that the most generic libs (like NWTC-Library) need to
appear at the end of the list.

Instead of leaving it up to the user to get the order right, the
simulink/CMakeLists.txt file has been updated to link the libraries
twice.

The same issue occured when using USE_LOCAL_STATIC_LAPACK
in that the BLAS libraries were linked before LAPACK so there
were unresolved symbols. This has been fixed by reversing the order.

Also, the OpenFOAM libraries have been marked as STATIC.
@deslaughter deslaughter merged commit 6bab2fd into OpenFAST:rc-3.5.1 Jul 13, 2023
@deslaughter deslaughter deleted the b/missing-symbols branch July 13, 2023 15:34
@andrew-platt andrew-platt mentioned this pull request Dec 24, 2024
38 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants