473,499 Members | 1,624 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem with building extension in Python

Hi,

I have already install Microsoft visual studio .NET 2003 and MinGw,
when I try to build a extension:

python my_extension_setup.py build ( or install ) , I get an error:

LINK : fatal error LNK1141: failure during build of exports file
error: command '"C:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\bin\link.exe"' failed with exit status 1141.What shoud I
do???

If you now anything useful,
please contact me!!


Thanks!!!!!!!!!!

Jul 5 '07 #1
4 2508
ve***********@v-programs.com wrote:
I have already install Microsoft visual studio .NET 2003 and MinGw,
when I try to build a extension:

python my_extension_setup.py build ( or install ) , I get an error:

LINK : fatal error LNK1141: failure during build of exports file
error: command '"C:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\bin\link.exe"' failed with exit status 1141.

What shoud I do???
Tell us what the actual error message is? What you provide here is only the
last line, the real error is most likely before that. Please provide a bit
more of the output, anything that might be helpful to understand the problem.

Stefan
Jul 5 '07 #2
En Thu, 05 Jul 2007 05:08:58 -0300, <ve***********@v-programs.com>
escribió:
I have already install Microsoft visual studio .NET 2003 and MinGw,
when I try to build a extension:
Is this for Python 2.4? I think you can't compile Python 2.5 with VS2003.
python my_extension_setup.py build ( or install ) , I get an error:

LINK : fatal error LNK1141: failure during build of exports file
error: command '"C:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\bin\link.exe"' failed with exit status 1141.What shoud I
do???
Almost surely you got a previous error, making link to fail. Try to
correct *that* error.

--
Gabriel Genellina

Jul 5 '07 #3
On Jul 5, 4:33 am, "Gabriel Genellina" <gagsl-...@yahoo.com.arwrote:
En Thu, 05 Jul 2007 05:08:58 -0300, <vedrandeko...@v-programs.com>
escribió:
I have already install Microsoft visual studio .NET 2003 and MinGw,
when I try to build a extension:

Is this for Python 2.4? I think you can't compile Python 2.5 with VS2003.
python my_extension_setup.py build ( or install ) , I get an error:
LINK : fatal error LNK1141: failure during build of exports file
error: command '"C:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\bin\link.exe"' failed with exit status 1141.What shoud I
do???

Almost surely you got a previous error, making link to fail. Try to
correct *that* error.

--
Gabriel Genellina
Microsoft Visual Studio .NET 2003 Version 7.1 is the correct
version to build extensions for Python 2.5. There is also a Microsoft
Visual Studio .NET 2003 Version 7.0 as well, which is not acceptable
for building extensions. The first release (version 7.0) was purchased
by many, and is relatively easy to find. The following release
(version 7.1) was a minor revision and is very hard to find, but it is
what's necessary for building Python extensions. I hope future Python
releases are built using a more standard compiler.

I'm posting in this thread because I am running into the same
problem as the original poster, linker error 1141. Here's a summary of
what I've gotten to work properly so far:

Python 2.5, Pyrex, and Microsoft Visual Studio 2003 .NET (version 7.1)
are successfully installed
I have successfully built Pyrex extensions using Distutils
I have successfully imported and ran Pyrex extensions in my Python
code

The problems occur when I try to include C libraries in my Pyrex
code. Specifically, I need some trig functions found in C's math.h
header files. My .pyx file is as follows:

#
# Use C math functions
#

def cFunctionTester(float theta):

import sys

# Import the native C functions we need
cdef extern from "math.h":
double cos(double theta)
double sin(double theta)

result[0] = cos(theta)
result[1] = sin(theta)

return 5

I try to build the extension by running my setup.py file from the
command prompt. My setup.py file is presented below:

from distutils.core import setup
from distutils.extension import Extension
from Pyrex.Distutils import build_ext
setup(
name = "PyrexGuide",
ext_modules=[
Extension("cTest", ["cTest.pyx"], libraries = [])
],
cmdclass = {'build_ext': build_ext}
)

I run this code through the command prompt by entering "setup.py
install" The following error appears:

C:\Python25\Lib\site-packages\Pyrex\Distutils>setup.py install
running install
running build
running build_ext
building 'cTest' extension
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\bin\cl.exe /c /
nologo /Ox
/MD /W3 /GX /DNDEBUG -IC:\Python25\include -IC:\Python25\PC /
TccTest.c /Fobuild
\temp.win32-2.5\Release\cTest.obj
cTest.c
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\bin\link.exe /
DLL /nologo
/INCREMENTAL:NO /LIBPATH:C:\Python25\libs /LIBPATH:C:
\Python25\PCBuild /EXPORT:
initcTest build\temp.win32-2.5\Release\cTest.obj /OUT:build
\lib.win32-2.5\cTest.
pyd /IMPLIB:build\temp.win32-2.5\Release\cTest.lib
LINK : error LNK2001: unresolved external symbol initcTest
build\temp.win32-2.5\Release\cTest.lib : fatal error LNK1120: 1
unresolved exter
nals
LINK : fatal error LNK1141: failure during build of exports file
error: command '"c:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\bin\link
..exe"' failed with exit status 1141

C:\Python25\Lib\site-packages\Pyrex\Distutils>

I do not know what the problem is -- perhaps the linker cannot locate
math.h? I've tried copying the math.h file to a whole bunch of other
directories, but there's still no luck. Any help anyone can provide
would be greatly appreciated.

Joe Stoffa
Co********@gmail.com

Jul 12 '07 #4
I solved my problem.

I had the math.h import step in the wrong location. The import step
needed to be outside of the function -- I'm so embarrassed.

Code: [Download]

1.
2. #
3. # Use C math functions
4. #
5.
6. # Import the native C functions we need
7. cdef extern from "math.h":
8. double cos(double theta)
9. double sin(double theta)
10.
11.
12. def cTest(double theta):
13.
14. cdef double result[2]
15.
16. import sys
17.
18. result[0] = cos(theta)
19. result[1] = sin(theta)
20.
21. pyResult = (result[0], result[1])
22.
23. return pyResult
24.
25.

Now it works

If I type the following into the python shell

import cTest
cTest.cTest(.775)

The function returns

(0.71442103405593138, 0.69971607534660352)
Jul 18 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1743
by: Jose Vicente Nunez Z | last post by:
Greetings, I wrote a couple of custom dummy extensions in Python (one a pure Python and the other a C) and i managed to compile and install them without a problem: $ make python2 setup.py...
7
7148
by: Carl Waldbieser | last post by:
I tried to adapt the instructions for building the M2Crypto module (http://sandbox.rulemaker.net/ngps/m2/INSTALL.html) to build a version compatible with Python2.3, but I've had some mixed results....
2
3731
by: Russell E. Owen | last post by:
I'm trying to build Python 2.3.4 from source on a RedHat Enterprise machine for installation in a net-wide accessible directory /net/python. I tried all of the following variants of ./configure...
1
4394
by: Jian Qiu | last post by:
Hi, I tried to install python2.4.2. Unfortunately building 'readline' extension failed. Here is what I got: (It is a bit long. If you are impatient, please look at the end where it reports the...
6
2330
by: ajikoe | last post by:
Hello I tried to combine c++ and python together. So I follow from this website: http://kortis.to/radix/python_ext/ I have this code: # prmodule.c static PyObject *pr_isprime(PyObject *self,...
4
2043
by: Lars | last post by:
Hi, I have problems building a simple handcoded C-extension (hello.c) with Cygwin and gcc3.4.4. I hope somebody has encountered the same problem before, and has some advice. The extension...
0
1352
by: John Ling | last post by:
Hello, I have been trying to install an application which requires Python: http://chip.dfci.harvard.edu/~wli/MAT/ My environment is AIX 5.2. Below is the section of the setup that has failed,...
11
2540
by: ZMY | last post by:
Dear all, I am a real newbie for both python and QNX, but I am still trying to compile Numeric-24.2 under QNX4.25 with python 2.2. I got following error message: $ sudo python setup.py...
4
3124
by: Arnaud Delobelle | last post by:
Hi fellow python enthusiasts. Having recently acquired a MacBook Pro (Intel Core 2 Duo) which comes with python2.5, I have been installing some modules that I need (PIL, psycopg2, PyXML ...). ...
0
7134
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7012
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7180
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7225
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6901
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7392
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5479
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3101
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
307
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.