I am trying to compile a software called MRtrix in windows. It uses a python build script, (I have uploaded it here: http://pastebin.com/XnufSz53)
when I run this script I get the error pasted bellow.
I guess that the GSL libraries are not being found and I need to add a -L pointing to the library but because the compilation is being done by the python script I do not really now how to do this. Currently GnuWin is installed at C:\GnuWin32\
Thank you in advance,
Jesse
============================================================
ERROR: [LD] lib\mrtrix-0_2_11.dll
g++ -shared lib\image\format\base.o lib\math\vector.o lib\file\mmap.o lib\args.o
lib\image\format\dicom.o lib\file\dicom\select_cmdline.o lib\file\key_value.o l
ib\image\axis.o lib\image\format\mrtrix.o lib\image\interp.o lib\data_type.o lib
\point.o lib\image\mapper.o lib\file\dicom\element.o lib\file\dicom\mapper.o lib
\file\dicom\patient.o lib\file\dicom\quick_scan.o lib\image\object.o lib\mrtrix.
o lib\image\format\xds.o lib\file\dicom\dict.o lib\app.o lib\math\matrix.o lib\f
ile\config.o lib\image\format\mri.o lib\file\dicom\image.o lib\math\linalg.o lib
\file\dicom\study.o lib\file\dicom\series.o lib\image\name_parser.o lib\image\fo
rmat\list.o lib\file\dicom\tree.o lib\image\fft.o lib\image\header.o lib\image\f
ormat\analyse.o lib\image\format\nifti1.o -LC:/gtkmm64/lib -lglibmm-2.4 -lgobjec
t-2.0 -lsigc-2.0 -lgthread-2.0 -lglib-2.0 -lintl -lgsl -lgslcblas -lz -o lib\mrt
rix-0_2_11.dll
failed with output:
c:/mingw/bin/../lib/gcc/mingw32/4.7.2/../../../../mingw32/bin/ld.exe: cannot fin
d -lgsl
c:/mingw/bin/../lib/gcc/mingw32/4.7.2/../../../../mingw32/bin/ld.exe: cannot fin
d -lgslcblas
collect2.exe: error: ld returned 1 exit status
============================================================
Related
I converted a Python script to C code via Cython, creating "test.c". I then compile with:
gcc -static test.c -I/home/me/Python-3.9.12/include/python3.9 -o test.exe -L/home/me/Python-3.9.12/lib -lpython3.9 -lpthread -lutil -lrt -lm -ldl
When I run "test.exe" I get this error:
Original error was: /home/me/NEWER/numpy/core/_multiarray_umath.cpython-39-x86_64-linux-gnu.so: undefined symbol: PyObject_SelfIter
What I don't understand is that the symbol PyObject_SelfIter is defined in libpython3.9.a which I link in as seen in the compilation line. Why doesn't this linking take care of the undefined symbol noted above? How can I get around this error?
2 notes:
I am linking statically because I want to run the resulting executable on an Android system
as a test, I tried compiling without the -static flag, and the executable still yields the same error
thanks for any tips.
I am trying to follow an example for Cython builds from here http://blog.perrygeo.net/2008/04/19/a-quick-cython-introduction/, except my c1.pyx is simply helloworld.pyx with "print "Hello World"":
# this will create a c1.c file - the C source code to build a python extension
cython c1.pyx
# Compile the object file
gcc -c -fPIC -I/usr/include/python2.5/ c1.c
# Link it into a shared library
gcc -shared c1.o -o c1.so
The reason I am doing it in the command line is because my setup.py is giving me an error so I am doing it manually to see what is wrong.
The last step (gcc -shared c1.o -o c1.so) is where I hit the following error:
c:/users/MyName/anaconda/mingw/bin/../lib/gcc/x86_64-w64-mingw32/4.7.0/../../../..
/x86_64-w64-mingw32/bin/ld.exe: cannot find -lgcc
c:/users/MyName/anaconda/mingw/bin/../lib/gcc/x86_64-w64-mingw32/4.7.0/../../../..
/x86_64-w64-mingw32/bin/ld.exe: cannot find -lgcc
collect2.exe: error: ld returned 1 exit status
error: command 'C:\\Users\\MyName\\Anaconda\\Scripts\\gcc.bat' failed with exit st
atus 1
Any suggestions?
EDIT1: Thank you #mat for the edit. Also, I was noticing I didn't have Visual C++ 2008 installed on my computer. Not sure if Anaconda requires this for GCC and if this is the solution.
I face a problem when compiling pyxrr (http://carichte.github.io/pyxrr/) on a Windows 7 machine (64bit) when using the latest Version of PythonXY with mingw32.
In the past the Compilation worked without problems on similar machines.
The following error output is given:
run setup.py build -c mingw32
running build
running build_py
running build_ext
building 'pyxrr.xrr' extension
C:\MinGW32-xy\bin\gcc.exe -mdll -O -Wall -IC:\Python27\lib\site-packages\numpy\c
ore\include -IC:\Python27\include -IC:\Python27\PC -c pyxrr/xrr.c -o build\temp.
win32-2.7\Release\pyxrr\xrr.o -fopenmp
In file included from C:\Python27\lib\site-packages\numpy\core\include/numpy/nda
rraytypes.h:1761:0,
from C:\Python27\lib\site-packages\numpy\core\include/numpy/nda
rrayobject.h:17,
from C:\Python27\lib\site-packages\numpy\core\include/numpy/arr
ayobject.h:4,
from pyxrr/xrr.c:26:
C:\Python27\lib\site-packages\numpy\core\include/numpy/npy_1_7_deprecated_api.h:
12:9: note: #pragma message: C:\Python27\lib\site-packages\numpy\core\include/nu
mpy/npy_1_7_deprecated_api.h(12) : Warning Msg: Using deprecated NumPy API, disa
ble it by #defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
#pragma message(_WARN___LOC__"Using deprecated NumPy API, disable it by " \
^
writing build\temp.win32-2.7\Release\pyxrr\xrr.def
C:\MinGW32-xy\bin\gcc.exe -shared -s build\temp.win32-2.7\Release\pyxrr\xrr.o bu
ild\temp.win32-2.7\Release\pyxrr\xrr.def -LC:\Python27\libs -LC:\Python27\PCbuil
d -lpython27 -lmsvcr90 -o build\lib.win32-2.7\pyxrr\xrr.pyd -fopenmp
build\temp.win32-2.7\Release\pyxrr\xrr.o:xrr.c:(.text+0x188): undefined referenc
e to `cexp'
build\temp.win32-2.7\Release\pyxrr\xrr.o:xrr.c:(.text+0x32c): undefined referenc
e to `cexp'
build\temp.win32-2.7\Release\pyxrr\xrr.o:xrr.c:(.text+0x42c): undefined referenc
e to `cexp'
build\temp.win32-2.7\Release\pyxrr\xrr.o:xrr.c:(.text+0xb4a): undefined referenc
e to `cexp'
build\temp.win32-2.7\Release\pyxrr\xrr.o:xrr.c:(.text+0xccf): undefined referenc
e to `cexp'
build\temp.win32-2.7\Release\pyxrr\xrr.o:xrr.c:(.text+0xda5): more undefined ref
erences to `cexp' follow
build\temp.win32-2.7\Release\pyxrr\xrr.o:xrr.c:(.text+0x100e): undefined referen
ce to `csqrt'
build\temp.win32-2.7\Release\pyxrr\xrr.o:xrr.c:(.text+0x1898): undefined referen
ce to `csqrt'
c:/mingw32-xy/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: build
\temp.win32-2.7\Release\pyxrr\xrr.o: bad reloc address 0x0 in section `.data'
collect2.exe: error: ld returned 1 exit status
An exception has occurred, use %tb to see the full traceback.
SystemExit: error: command 'gcc' failed with exit status 1
The same error occures if I do not use the multi processing option and libraries (--single-core flag). I was searching the web and trying different compiler options like -lm, -DKM_WIN32 etc. without effect. But python as well as mingw run as 32bit versions.
Apparently he doesn't find complex.h library functions which are actually standard.
I tried this on 2 different Win7 machines. Also, compiling using Anaconda works for the single-threaded version.
Since I don't really understand the problems, I hope someone can tell me where it lies.
Any hint is appreciated,
Thank you!
I have a little problem with compiling NakedMUD on my Mac. I think, I added all the right directories to the module.mk file now, so it looks like this:
# the top level directory of python.
PYTHONTOP = /Library/Frameworks/Python.framework/Versions/2.7
# the folder where python headers are located
C_FLAGS += -I$(PYTHONTOP)/Headers
# libraries we have to include.
LIBS += -u _PyMac_Error -lm -ldl -lutil -L/lib/python2.7/config -lpython2.7
But when I try to compile with 'make', I get the following errors:
ld: warning: directory not found for option '-L/lib/python2.7/config'
ld: library not found for -lpython2.7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [all] Error 1
I tried googling the problem, but most answers I found were about configuring Xcode...but I am using the terminal.
I am sorry, if this sounds a bit stupid but I really tried everything that I could and am not very experienced. I would be very glad if somebody could tell me what's wrong.
Best wishes,
Aerdureth
I have a fortran program that uses some library files. I am trying to link them along with the module file being created.
The library file I am trying to link is called ulib.a and is located in the directory /home/replace/lib/
The command I am using is:
f2py -L/home/replace/lib/ -lulib.a -c main.f -m progs
I am getting the following error:
/usr/bin/ld: cannot find -lulib.a
collect2: ld returned 1 exit status
/usr/bin/ld: cannot find -lulib.a
collect2: ld returned 1 exit status
I would appreciate any help!
Try leaving off the .a - I am reasonably sure that the linker already knows that libraries are .a so in your example it will be looking for ulib.a.a and failing.
I had to remove the extension from the library name and also provide the full path. For some reason providing the path using the -L argument did not work.
f2py -l/home/replace/lib/ulib -c main.f -m progs
The library should have the full name libxxx.a where xxx is the given name. Then do
f2py -L. -lxxx -c main.f90 -m progs
Note that only xxx comes after -l. If you create the library yourself remember to include -fPIC. For example, it could look like this:
gfortran -c -fPIC source1.f90 source2.f90
ar crs libxxx.a obj1.o obj2.o
f2py -L. -lxxx -c main.f90 -m progs
Found guidance in this example: https://modelingguru.nasa.gov/docs/DOC-2343