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

fails to link external OpenMP library #917

Closed
hmoffatt opened this issue Jun 18, 2021 · 6 comments · Fixed by #919
Closed

fails to link external OpenMP library #917

hmoffatt opened this issue Jun 18, 2021 · 6 comments · Fixed by #919

Comments

@hmoffatt
Copy link

On macOS, the clang/LLVM compiler does not include OpenMP support but it is available as an external library via brew:

brew install libomp

When this library is installed, it is correctly detected by the cmake scripts, but then the compile fails because src/CMakeLists.txt fails to include the include directory and fails to link the library.

I was able to get this to work by adding

if ( HAVE_OPENMP )
  include_directories ( ${OpenMP_C_INCLUDE_DIR} )
endif ( HAVE_OPENMP )

and to target_link_libraries

    ${OpenMP_libomp_LIBRARY}

This last one doesn't look 100% correct although it does work; the cmake script has not calculated a nice linker flag (-lomp).

@derselbst
Copy link
Member

This last one doesn't look 100% correct although it does work; the cmake script has not calculated a nice linker flag (-lomp).

Could you please uncomment those two lines and try again?

fluidsynth/CMakeLists.txt

Lines 709 to 710 in 15bd824

# set ( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}" )
# set ( LIBFLUID_LIBS "${OpenMP_C_LIBRARIES};${LIBFLUID_LIBS}" )

@derselbst
Copy link
Member

Also, which version of clang are you using? Because I tried to reproduce this in our Mac CI Build, but it keeps reporting that only openMP 201107 is supported, which in insufficient. No matter if libomp is installed or not.

@hmoffatt
Copy link
Author

Uncommenting those lines fixes the linking, but it doesn't find the include file (/usr/local/include/omp.h) without also adding ${OpenMP_C_INCLUDE_DIR} to the include directories.

My clang is 12.0.5 as provided by Xcode 12.5 (currently the latest):

$ clang --version
Apple clang version 12.0.5 (clang-1205.0.22.9)
Target: x86_64-apple-darwin20.5.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

The parallel sound font loading does work nicely on macOS with these changes.

@hmoffatt
Copy link
Author

By the way, the latest MSVC does support OpenMP 4.0 for 64-bit Windows applications. I haven't tested it yet as 32-bit support (which I need) is coming later.

@derselbst
Copy link
Member

A PR is ready for this, feel free to test. Unfortunately, Mac11 is still not publicly available for Github Actions and AzureDevOps (actions/runner-images#2486), so I cannot see whether it actually works.

@hmoffatt
Copy link
Author

That's working perfectly for me. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants