fitsio
fitsio copied to clipboard
Added fixes for compiling with mingw under windows 8
Hey guys,
I had to compile the library for windows and found two problems. First mingw must link to libgcc.a as otherwise the linker can't resolve two symbols. I added this to setup.py:
if platform.system()=='Darwin': extra_compile_args=['-arch','i386','-arch','x86_64'] extra_link_args=['-arch','i386','-arch','x86_64'] else: extra_compile_args=[] extra_link_args=['C:\MinGW\lib\gcc\mingw32\4.8.1\libgcc.a', ''] # HACK TO GET IT COMPILE ON MINGW
Second, in drvrfile.c
ifdef HAVE_FTRUNCATE
if defined(unix) || defined(unix) || defined(__unix)
include unistd.h /* needed for getcwd prototype on unix machines */
endif
endif
won't include _ftruncate under windows. i fixed it by removing all the preprocessor statements so that unistd.h will be included under mingw
hope that helps
Thank you, this is a good start.
To make it more generic, we should add the check for platform.system() explicitly. What does that function give you?
We should also think of a more generic solution to the _ftruncate. I don't have windows to test though. Do you know what should be define should be checked for on your system?
Hi esheldon,
it was my first time building a python library so I just "hacked" the changes into it.
if platform.system()=='Darwin': extra_compile_args=['-arch','i386','-arch','x86_64'] extra_link_args=['-arch','i386','-arch','x86_64'] elif platform.system() == "Windows": extra_compile_args=[] extra_link_args=['C:\MinGW\lib\gcc\mingw32\4.8.1\libgcc.a', ''] else: extra_compile_args=[] extra_link_args=[]
This work for me now. But the problem is that the user MUST have installed MinGW to C:\MinGW. Maybe we should add a command line switch to enable the user to specify where precisely MinGW is located.
Hi Markus -
Any progress on making this more general? I can't test as I'm without windows.
thanks
Still need more eyes on the windows front (I have no windows).
We still have no windows core developers, but are always glad for any help