Error with linking flag when using the cmake build for cppyy

253 Views Asked by At

I am trying to build the example for a make build for cppyy in the cppyy-knearestneighbors example (https://github.com/jclay/cppyy-knearestneighbors-example). From what I understand it used the more modern cppyy cmake.

However when it comes to the linking I find this error,

ld: unknown option: --no-as-needed
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [knn_example/libknn_exampleCppyy.dylib] Error 1
make[1]: *** [CMakeFiles/knn_exampleCppyy.dir/all] Error 2
make: *** [all] Error 2

I couldn't find away to remove this flag as it seems to be something internal to cppyy cmake. Is there any work around to fix the compilation?

1

There are 1 best solutions below

0
On

I cannot talk about cppyy since I have never used it, but since it internally uses CMake, the issue that you have could control by the value of the LINK_WHAT_YOU_USE property.

I would first try to disable the default value of LINK_WHAT_YOU_USE with:

# When running cmake configure:
cmake -GNinja -DCMAKE_LINK_WHAT_YOU_USE=OFF

If it does not work, a more evolve approach which means iterating all of the targets and unsetting their LINK_WHAT_YOU_USE property. Let me know if you need help for this

https://cmake.org/cmake/help/latest/variable/CMAKE_LINK_WHAT_YOU_USE.html#variable:CMAKE_LINK_WHAT_YOU_USE