Skip to content

Fix lapack linker path + slycot directory case #85

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

Closed

Conversation

murrayrm
Copy link
Member

The python-control package has been having build problems and I traced these back to slycot. The problem traced down to the CMake installation not correctly linking in the lapack library, which resulted in the following error during the build process for slycot:

python -c "import slycot"; fi
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/travis/miniconda/envs/test-environment/lib/python3.7/site-packages/slycot-0.3.5.8-py3.7-linux-x86_64.egg/slycot/__init__.py", line 16, in <module>
    from .analysis import ab01nd,ab05md,ab05nd,ab07nd,ab08nd, \
  File "/home/travis/miniconda/envs/test-environment/lib/python3.7/site-packages/slycot-0.3.5.8-py3.7-linux-x86_64.egg/slycot/analysis.py", line 20, in <module>
    from . import _wrapper
ImportError: /home/travis/miniconda/envs/test-environment/lib/python3.7/site-packages/slycot-0.3.5.8-py3.7-linux-x86_64.egg/slycot/_wrapper.so: undefined symbol: dgebal_

In chasing this down, I found out that CMake was not setting the variable LAPACK_LIBRARIES in the CMakeLists.txt file. Specifically, the following code

find_package(PythonLibs REQUIRED)
find_package(NumPy REQUIRED)
# set(BLA_VENDOR "OpenBLAS")
find_package(LAPACK REQUIRED)
message(STATUS "LAPACK: ${LAPACK_LIBRARIES}")
message(STATUS "Slycot version: ${SLYCOT_VERSION}")

generate the output

-- A library with LAPACK API found.
-- LAPACK: 
-- Slycot version: 0.3.5.8

It appears that the blank LAPACK_LIBRARIES variable meant that slycot was not actually being linked against lapack. To fix this, I removed the commented out line set(BLA_VENDOR "OpenBLAS"), which changes the output (on linux) to read:

-- A library with LAPACK API found.
-- LAPACK: /home/travis/miniconda/envs/test-environment/lib/libopenblas.so;/home/travis/miniconda/envs/test-environment/lib/libopenblas.so

This PR uncomments that line and fixes the problem. I am not quite sure what changed that made this problem crop up...

@repagh Do you know/remember why that line was commented out.

@bnavigator
Copy link
Collaborator

As far as I remember this is only valid when using OpenBLAS, not BLAS/LAPACK.

I use the following code in the OpenSUSE package recipe for slycot:

%if %{with openblas}
sed -i 's/#set(BLA_VENDOR "OpenBLAS")/set(BLA_VENDOR "OpenBLAS")/' CMakeLists.txt
%endif
sed -i 's/LAPACK REQUIRED/LAPACK REQUIRED MODULE/' CMakeLists.txt

I am not sure if the MODULE argument is required or not. I must have put it there for a reason though.

@bnavigator
Copy link
Collaborator

This one is obsolete with the recent merge of #91

@murrayrm murrayrm closed this Feb 4, 2020
@murrayrm murrayrm deleted the fix_lapack_linker_path branch February 4, 2020 06:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants