Hi I am Sunghwan Choi Now, I am interested on weave. First of all, I have c code to be wrapped by python. tmp.c file #include<xc.h> #include<stdio.h> int main(){ int np =3; int return_val; xc_func_type func; xc_func_init(&func, XC_GGA_X_B88, XC_UNPOLARIZED); xc_func_end(&func); return_val=np+131; printf("%d", return_val); } gcc -o exe tmp.c -L/home/shchoi/git/LagChem/LagChem/Basic/XCs/libxc-1.2.0/src/.libs/ -lxc -lm ./exe above code is my target code and now, from scipy.weave import inline np=3 code=\ """ xc_func_type func; xc_func_init(&func, XC_GGA_X_B88, XC_UNPOLARIZED); xc_func_end(&func); return_val=np+131; """ print inline(code,['np'],include_dirs = ["/home/shchoi/git/LagChem/LagChem/Basic/XCs/libxc-1.2.0/src/"],library_dirs=["/home/shchoi/git/LagChem/LagChem/Basic/XCs/libxc-1.2.0/src/.libs"],libraries=["m","xc"],headers=["<xc.h>","<stdio.h>"],compiler='gcc') print np This is my solution but it give me a error In file included from /usr/lib64/python2.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1975:0, from /usr/lib64/python2.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:17, from /usr/lib64/python2.7/site-packages/numpy/core/include/numpy/arrayobject.h:15, from /home/shchoi/.python27_compiled/sc_a383cf366f9347f9b6ff017e9aab78882.cpp:22: /usr/lib64/python2.7/site-packages/numpy/core/include/numpy/npy_deprecated_api.h:11:2: warning: #warning "Using deprecated NumPy API, disable it by #defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" /usr/bin/ld: /home/shchoi/git/LagChem/LagChem/Basic/XCs/libxc-1.2.0/src/.libs/libxc.a(libxc_la-functionals.o): relocation R_X86_64_32 against `xc_functional_keys' can not be used when making a shared object; recompile with -fPIC /home/shchoi/git/LagChem/LagChem/Basic/XCs/libxc-1.2.0/src/.libs/libxc.a: could not read symbols: Bad value collect2: ld returned 1 exit status /usr/bin/ld: /home/shchoi/git/LagChem/LagChem/Basic/XCs/libxc-1.2.0/src/.libs/libxc.a(libxc_la-functionals.o): relocation R_X86_64_32 against `xc_functional_keys' can not be used when making a shared object; recompile with -fPIC /home/shchoi/git/LagChem/LagChem/Basic/XCs/libxc-1.2.0/src/.libs/libxc.a: could not read symbols: Bad value collect2: ld returned 1 exit status Traceback (most recent call last): File "tmp.py", line 12, in <module> print inline(code,['np'],include_dirs = ["/home/shchoi/git/LagChem/LagChem/Basic/XCs/libxc-1.2.0/src/"],library_dirs=["/home/shchoi/git/LagChem/LagChem/Basic/XCs/libxc-1.2.0/src/.libs"],libraries=["m","xc"],headers=["<xc.h>","<stdio.h>"],compiler='gcc') File "/usr/lib64/python2.7/site-packages/scipy/weave/inline_tools.py", line 355, in inline **kw) File "/usr/lib64/python2.7/site-packages/scipy/weave/inline_tools.py", line 482, in compile_function verbose=verbose, **kw) File "/usr/lib64/python2.7/site-packages/scipy/weave/ext_tools.py", line 367, in compile verbose = verbose, **kw) File "/usr/lib64/python2.7/site-packages/scipy/weave/build_tools.py", line 272, in build_extension setup(name = module_name, ext_modules = [ext],verbose=verb) File "/usr/lib64/python2.7/site-packages/numpy/distutils/core.py", line 186, in setup return old_setup(**new_attr) File "/usr/lib64/python2.7/distutils/core.py", line 169, in setup raise SystemExit, "error: " + str(msg) scipy.weave.build_tools.CompileError: error: Command "g++ -pthread -shared /tmp/shchoi/python27_intermediate/compiler_81874d258832299909898bc232bd652b/home/shchoi/.python27_compiled/sc_a383cf366f9347f9b6ff017e9aab78882.o /tmp/shchoi/python27_intermediate/compiler_81874d258832299909898bc232bd652b/usr/lib64/python2.7/site-packages/scipy/weave/scxx/weave_imp.o -L/home/shchoi/git/LagChem/LagChem/Basic/XCs/libxc-1.2.0/src/.libs -L/usr/lib64 -lm -lxc -lpython2.7 -o /home/shchoi/.python27_compiled/sc_a383cf366f9347f9b6ff017e9aab78882.so" failed with exit status 1 I have tried to solve for a while but now I give up. please help me anyone~
participants (1)
-
SungHwan Choi