Fix missing symbols for Simulink and LAPACK build #1682
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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: