Re: [Numpy-discussion] npymath on Windows
Hi, without further testing; this approach may help: (1) create a shared library with all symbols from libnpymath.a: $ gcc -shared -o libnpymath.dll -Wl,--whole-archive libnpymath.a -Wl,--no-whole-archive -lm (2) create a def file: gendef libnpymath.dll There are now two files created by mings-w64 tools: libnpymath.dll, libnpymath.def (3) create import libs for MSVC: first open a new command Window with the VC command prompt: lib /machine:i386 /def:libnpymath.def (for 64bit use: /machine:X64) Microsoft (R) Library Manager Version 9.00.30729.01 Copyright (C) Microsoft Corporation. All rights reserved. Creating library libnpymath.lib and object libnpymath.exp libnpymath.dll, libnpymath.lib and libnpymath.exp should be sufficient for MSVC. libnpymath.dll has to be deployed. -- carlkl 2015-01-01 21:34 GMT+01:00 Sturla Molden sturla.mol...@gmail.com: On 28/12/14 17:17, David Cournapeau wrote: This is not really supported. You should avoid mixing compilers when building C extensions using numpy C API. Either all mingw, or all MSVC. That is not really good enough. Even if we build binary wheels with MinGW (see link) the binary npymath library should be useable from MSVC. https://github.com/numpy/numpy/pull/5328 Sturla ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] npymath on Windows
On 28/12/14 17:17, David Cournapeau wrote: This is not really supported. You should avoid mixing compilers when building C extensions using numpy C API. Either all mingw, or all MSVC. That is not really good enough. Even if we build binary wheels with MinGW (see link) the binary npymath library should be useable from MSVC. https://github.com/numpy/numpy/pull/5328 Sturla ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] npymath on Windows
On 28/12/14 01:59, Matthew Brett wrote: As far as I can see, 'acosf' is defined in the msvc runtime library. I guess that '_acosf' is defined in some mingw runtime library? AFAIK it is a GCC built-in function. When the GCC compiler or linker sees it the binary code will be inlined. https://gcc.gnu.org/onlinedocs/gcc-4.9.0/gcc/Other-Builtins.html Sturla ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] npymath on Windows
Hi, On Sun, Dec 28, 2014 at 4:17 PM, David Cournapeau courn...@gmail.com wrote: On Sun, Dec 28, 2014 at 1:59 AM, Matthew Brett matthew.br...@gmail.com wrote: Hi, Sorry for this ignorant email, but we got confused trying to use 'libnpymath.a' from the mingw builds of numpy: We were trying to link against the mingw numpy 'libnpymath.a' using Visual Studio C, but this give undefined symbols from 'libnpymath.a' like this: This is not really supported. You should avoid mixing compilers when building C extensions using numpy C API. Either all mingw, or all MSVC. It would be very useful to support MSVC compilation from our standard binaries. We (nipy / dipy) have had to remove our dependence on the npymath library because - at the moment - the naive user may find themselves trying to compile the package with visual C when they have the standard numpy windows package, and this will fail for them. How about shipping an MSVC-compiled npymath.lib with the mingw compiled package? Cheers, Matthew ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] npymath on Windows
Hi, according to http://sourceforge.net/p/mingw-w64/discussion/723798/thread/7da101da : *Sorry, sharing static libraries with MSVC is not supported right now, the contributor who was supposed to work on this went MIA.The only sane way to do it right now is to use a DLL.* this problem seems to be a name mangling problem between mingw32 (or mingw-w64) and MSVC that cannot be solved easily other than using a shared lib instead. There is a objconv tool http://www.agner.org/optimize/#objconv that is able to change the names of symbols in existing object code that may help to create a MSVC compatible static lib in this special case. Cheers, Carl 2014-12-28 1:59 GMT+01:00 Matthew Brett matthew.br...@gmail.com: Hi, Sorry for this ignorant email, but we got confused trying to use 'libnpymath.a' from the mingw builds of numpy: We were trying to link against the mingw numpy 'libnpymath.a' using Visual Studio C, but this give undefined symbols from 'libnpymath.a' like this: npymath.lib(npy_math.o) : error LNK2019: unresolved external symbol _atanf referenced in function _npy_atanf npymath.lib(npy_math.o) : error LNK2019: unresolved external symbol _acosf referenced in function _npy_acosf npymath.lib(npy_math.o) : error LNK2019: unresolved external symbol _asinf referenced in function _npy_asinf (see : http://nipy.bic.berkeley.edu/builders/dipy-bdist32-33/builds/73/steps/shell_6/logs/stdio ) npymath.lib from Christophe Gohlke's (MSVC compiled) numpies does not give such an error. Sure enough, 'npymath.lib' shows these lines from `dumpbin /all npymath.lib`: 0281 REL32 4F asinf 0291 REL32 51 acosf 02A1 REL32 53 atanf whereas `dumpbin /all libnpymath.a` shows these kinds of lines: 08E5 REL32 86 _asinf 08F5 REL32 85 _acosf 0905 REL32 84 _atanf As far as I can see, 'acosf' is defined in the msvc runtime library. I guess that '_acosf' is defined in some mingw runtime library? Is there any way of making a npymath library that will pick up the msvc math and so may work with both msvc and mingw? Sorry again if that's a dumb question, Matthew ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] npymath on Windows
On Sun, Dec 28, 2014 at 1:59 AM, Matthew Brett matthew.br...@gmail.com wrote: Hi, Sorry for this ignorant email, but we got confused trying to use 'libnpymath.a' from the mingw builds of numpy: We were trying to link against the mingw numpy 'libnpymath.a' using Visual Studio C, but this give undefined symbols from 'libnpymath.a' like this: This is not really supported. You should avoid mixing compilers when building C extensions using numpy C API. Either all mingw, or all MSVC. David npymath.lib(npy_math.o) : error LNK2019: unresolved external symbol _atanf referenced in function _npy_atanf npymath.lib(npy_math.o) : error LNK2019: unresolved external symbol _acosf referenced in function _npy_acosf npymath.lib(npy_math.o) : error LNK2019: unresolved external symbol _asinf referenced in function _npy_asinf (see : http://nipy.bic.berkeley.edu/builders/dipy-bdist32-33/builds/73/steps/shell_6/logs/stdio ) npymath.lib from Christophe Gohlke's (MSVC compiled) numpies does not give such an error. Sure enough, 'npymath.lib' shows these lines from `dumpbin /all npymath.lib`: 0281 REL32 4F asinf 0291 REL32 51 acosf 02A1 REL32 53 atanf whereas `dumpbin /all libnpymath.a` shows these kinds of lines: 08E5 REL32 86 _asinf 08F5 REL32 85 _acosf 0905 REL32 84 _atanf As far as I can see, 'acosf' is defined in the msvc runtime library. I guess that '_acosf' is defined in some mingw runtime library? Is there any way of making a npymath library that will pick up the msvc math and so may work with both msvc and mingw? Sorry again if that's a dumb question, Matthew ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] npymath on Windows
Hi, 2014-12-28 17:17 GMT+01:00 David Cournapeau courn...@gmail.com: On Sun, Dec 28, 2014 at 1:59 AM, Matthew Brett matthew.br...@gmail.com wrote: Hi, Sorry for this ignorant email, but we got confused trying to use 'libnpymath.a' from the mingw builds of numpy: We were trying to link against the mingw numpy 'libnpymath.a' using Visual Studio C, but this give undefined symbols from 'libnpymath.a' like this: This is not really supported. You should avoid mixing compilers when building C extensions using numpy C API. Either all mingw, or all MSVC. This is correct and the usual recommendation. In the case of libnpymath.a a mingw-w64 build static library may work, if all external symbol names are corrected to the MSVC standard. This could be accomplished with the help of objconv and should be tested IMHO. Carl David npymath.lib(npy_math.o) : error LNK2019: unresolved external symbol _atanf referenced in function _npy_atanf npymath.lib(npy_math.o) : error LNK2019: unresolved external symbol _acosf referenced in function _npy_acosf npymath.lib(npy_math.o) : error LNK2019: unresolved external symbol _asinf referenced in function _npy_asinf (see : http://nipy.bic.berkeley.edu/builders/dipy-bdist32-33/builds/73/steps/shell_6/logs/stdio ) npymath.lib from Christophe Gohlke's (MSVC compiled) numpies does not give such an error. Sure enough, 'npymath.lib' shows these lines from `dumpbin /all npymath.lib`: 0281 REL32 4F asinf 0291 REL32 51 acosf 02A1 REL32 53 atanf whereas `dumpbin /all libnpymath.a` shows these kinds of lines: 08E5 REL32 86 _asinf 08F5 REL32 85 _acosf 0905 REL32 84 _atanf As far as I can see, 'acosf' is defined in the msvc runtime library. I guess that '_acosf' is defined in some mingw runtime library? Is there any way of making a npymath library that will pick up the msvc math and so may work with both msvc and mingw? Sorry again if that's a dumb question, Matthew ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
[Numpy-discussion] npymath on Windows
Hi, Sorry for this ignorant email, but we got confused trying to use 'libnpymath.a' from the mingw builds of numpy: We were trying to link against the mingw numpy 'libnpymath.a' using Visual Studio C, but this give undefined symbols from 'libnpymath.a' like this: npymath.lib(npy_math.o) : error LNK2019: unresolved external symbol _atanf referenced in function _npy_atanf npymath.lib(npy_math.o) : error LNK2019: unresolved external symbol _acosf referenced in function _npy_acosf npymath.lib(npy_math.o) : error LNK2019: unresolved external symbol _asinf referenced in function _npy_asinf (see : http://nipy.bic.berkeley.edu/builders/dipy-bdist32-33/builds/73/steps/shell_6/logs/stdio) npymath.lib from Christophe Gohlke's (MSVC compiled) numpies does not give such an error. Sure enough, 'npymath.lib' shows these lines from `dumpbin /all npymath.lib`: 0281 REL32 4F asinf 0291 REL32 51 acosf 02A1 REL32 53 atanf whereas `dumpbin /all libnpymath.a` shows these kinds of lines: 08E5 REL32 86 _asinf 08F5 REL32 85 _acosf 0905 REL32 84 _atanf As far as I can see, 'acosf' is defined in the msvc runtime library. I guess that '_acosf' is defined in some mingw runtime library? Is there any way of making a npymath library that will pick up the msvc math and so may work with both msvc and mingw? Sorry again if that's a dumb question, Matthew ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion