Compilation failure with CMake due to missing libpython
from instant import inline
func = inline("double add(double a, double b){ return a+b; }",
cache_dir = "test_cache",
generate_setup = False)
fails.
This because the library is not linked against libpython
.
In DOLFIN the problem doesn't show up because libpython
is already included by DOLFINConfig.cmake
.
A reasonable fix should be to add
find_package(PythonLibs)
include_directories(${PYTHON_INCLUDE_PATH})
swig_link_libraries(${SWIG_MODULE_NAME} ${PYTHON_LIBRARIES})
in CMakeLists.txt
file, but this doesn't guarantee the consistency with the working python environment (sometimes PythonLibs picks up a different library when python is a non-standard location). A better solution could mimic what DOLFIN's CMakeLists.txt
does to workaround this problem.
Comments (8)
-
-
reporter from instant import inline from distutils.sysconfig import get_config_var from os.path import splitext add_func = inline("double add(double a, double b){ return a+b; }", cache_dir = "test_cache", generate_setup = False, library_dirs = [ get_config_var('LIBDIR') ], include_dirs = [ get_config_var('INCLUDEPY') ], libraries = [ splitext(get_config_var('LIBRARY'))[0][3:] ])
still doesn't work since apparently
library_dirs
is ignored bywrite_cmakefile
ininstant/codegeneration.py
.Anyhow, I see your point, but I think that python libraries and headers should be always included automatically and not by the user. A minimal working example of CMake+SWIG must include PythonLibs to work, otherwise it won't compile. On the other hand, in this case all the files are generated by instant, so a plain PythonLibs doesn't seems the optimum because it can pick up the wrong library, usually ending up with a segmentation fault when the module is loaded (see also [1]).
-
@peppu - Yes, I agree that python libraries and headers should be included automatically.
-
-
assigned issue to
-
assigned issue to
-
I think this was fixed in 68914c in DOLFIN. Can you check if you still have the same issue @peppu?
-
- changed status to resolved
I am marking this as fixed. Please reopen if you think this is not fixed.
-
reporter Sorry for the late answer ... actually it still doesn't work the pure instant example. But on DOLFIN the problem is fixed because of the commit you pointed out (the trick in that case is to keep track of the python libs/includes found during DOLFIN config).
One possible fix for the instant counterpart is to copy&paste the ``find PythonLibs'' section in dolfin/CMakeLists.txt inside the instant-generated CMakeLists.txt.
I fear you could face the same issue with Hashdist installation, with a user-compiled version of python ...
-
- removed milestone
Removing milestone: 1.4 (automated comment)
- Log in to comment
You should supply the libraries you need to link against when calling
inline
. Something like this should work:See also the documentation of
instant.build
.