1

I use Anaconda for Python 2.7.10 in Windows 7, 64 bit. I also use Visual Studio 2010. I installed Microsoft Visual Studio for Python.

When I try to compile a C code in python (inside cmd):

C:\Anaconda\sms-tools-master\software\transformations_interface>python compileModule.py build_ext --inplace

I get a lot of warnings and some errors that the final part of it are as follows:

C:\Program Files (x86)\Microsoft Visual Studio

10.0\VC\BIN\amd64\link.exe /DLL / nologo /INCREMENTAL:NO /LIBPATH:C:\Anaconda\libs /LIBPATH:C:\Anaconda\PCbuild\am d64 m.lib

/EXPORT:initutilFunctions_C build\temp.win-amd64-2.7\Release\utilFunct
ions.obj build\temp.win-amd64-2.7\Release\cutilFunctions.obj

/OUT:C:\Anaconda\sm
s-tools-master\software\models\utilFunctions_C\utilFunctions_C.pyd

/IMPLIB:build \temp.win-amd64-2.7\Release\utilFunctions_C.lib

/MANIFESTFILE:build\temp.win-amd
64-2.7\Release\utilFunctions_C.pyd.manifest LINK : fatal error

LNK1181: cannot open input file 'm.lib' error: command 'C:\\Program
Files (x86)\\Microsoft Visual Studio 10.0\\VC\\BIN\\ amd64\\link.exe'

failed with exit status 1181

Please let me see how this problem can be fixed.

3 Answers 3

1

And if I only comment

libraries=['m']

and use

ext_modules = [Extension("utilFunctions_C",sourcefiles, include_dirs=py_inc + np_inc)]    

then I get lots of warning (not errors hopefully) whose final part is:

C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\BIN\amd64\link.exe /DLL / nologo /INCREMENTAL:NO /LIBPATH:C:\Anaconda\libs /LIBPATH:C:\Anaconda\PCbuild\am d64 /EXPORT:initutilFunctions_C build\temp.win-amd64-2.7\Release\utilFunctions.o bj build\temp.win-amd64-2.7\Release\cutilFunctions.obj /OUT:C:\Anaconda\sms-tool s-master\software\models\utilFunctions_C\utilFunctions_C.pyd /IMPLIB:build\temp. win-amd64-2.7\Release\utilFunctions_C.lib /MANIFESTFILE:build\temp.win-amd64-2.7 \Release\utilFunctions_C.pyd.manifest cutilFunctions.obj : warning LNK4197: export 'initutilFunctions_C' specified mul tiple times; using first specification Creating library build\temp.win-amd64-2.7\Release\utilFunctions_C.lib and obj ect build\temp.win-amd64-2.7\Release\utilFunctions_C.exp

I think the problem is now resolved. Thank you LPs!!

Sign up to request clarification or add additional context in comments.

Comments

0

Comment the line in setup.py that say libraries=['m'], and run again.

The need to link to m might be a GCC thing to link Math library, that is managed by MSVCR in Windows environment.

Comments

0

Just removing .. libraries=['m'] .. from ext_modules helped me compile on windows 2010 too. No errors or warnings. This is how it looks finally,

ext_modules = [Extension("utilFunctions_C",sourcefiles , include_dirs=py_inc + np_inc)]

Thanks a bunch

Edit .....

Here is entire code for compileModule.py Please refer to comments for details.

from distutils.core import setup, Extension
from distutils.sysconfig import *
from distutils.util import *
from Cython.Distutils import build_ext
import numpy
import os
import os.path

#defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION

try:
   from distutils.command.build_py import build_py_2to3 \
   as build_py
except ImportError:
   from distutils.command.build_py import build_py

try:
   from Cython.Distutils import build_ext
except ImportError:
   use_cython = False
else:
   use_cython = True


py_inc = [get_python_inc()]

np_lib = os.path.dirname(numpy.__file__)
np_inc = [os.path.join(np_lib, 'core/include')]
ext_inc = os

sourcefiles = ["utilFunctions.c", "cutilFunctions.pyx"]

setup(
    cmdclass = {'build_ext': build_ext},
    #ext_modules = [Extension("utilFunctions_C",sourcefiles, libraries=['m'], include_dirs=py_inc + np_inc)]
    ext_modules = [Extension("utilFunctions_C",sourcefiles , include_dirs=py_inc + np_inc)]

  )

2 Comments

Can you format this a little better for clarity and provide some links to relevant documentation?
Yes, Certainly. I've windows 2010 laptop and I am researching audio processing algorithms using python as its easier to prototype and test and there is huge support available. I downloaded sms-tools for this purpose from here: https://github.com/MTG/sms-tools1 and was running python compileModule.py build_ext --inplace If you refer to wiki @( github.com/MTG/sms-tools/wiki/sms-tools-in-Windows) , it clearly states that in order to compile on windows, we need to remove libraries=['m'], from compileModule.py as this option is for gcc, so we don't need on windows.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.