Discussion:
[Numpy-discussion] compiling c extension
Danny Chan
2008-01-21 16:26:03 UTC
Permalink
Hi!
I am trying to compile a c extension that uses numpy arrays on windows. I can compile the extension file, but once I get to the linking stage I get unresolved references to PyArray_API and import_array. Can anyone help me with the correct linker flags?

Thanks, Danny



running build
running build_py
file libaid.py (for module libaid) not found
file libaid.py (for module libaid) not found
running build_ext
building '_libaid' extension
writing build\temp.win32-2.5\Release\.\python\_libaid.def
x:\eda\mingw\5.1.3\bin\gcc.exe -mno-cygwin -shared -s build\temp.win32-2.5\Release\.\python\libaid_wrap.o build\temp.win32-2.5\Release\.\python\_libaid.def -L../../build/win32/bin -Lx:\eda\python\windows\libs -Lx:\eda\python\windows\PCBuild -laid -lpython25 -lmsvcr71 -o build\lib.win32-2.5\_libaid.pyd
build\temp.win32-2.5\Release\.\python\libaid_wrap.o:libaid_wrap.c:(.text+0x2602): undefined reference to `PyArray_API'
build\temp.win32-2.5\Release\.\python\libaid_wrap.o:libaid_wrap.c:(.text+0x2635): undefined reference to `PyArray_API'
build\temp.win32-2.5\Release\.\python\libaid_wrap.o:libaid_wrap.c:(.text+0x264f): undefined reference to `PyArray_API'
build\temp.win32-2.5\Release\.\python\libaid_wrap.o:libaid_wrap.c:(.text+0x2709): undefined reference to `PyArray_API'
build\temp.win32-2.5\Release\.\python\libaid_wrap.o:libaid_wrap.c:(.text+0x2752): undefined reference to `PyArray_API'
build\temp.win32-2.5\Release\.\python\libaid_wrap.o:libaid_wrap.c:(.text+0x2784): more undefined references to `PyArray_API' follow
build\temp.win32-2.5\Release\.\python\libaid_wrap.o:libaid_wrap.c:(.text+0xc216): undefined reference to `import_array'
collect2: ld returned 1 exit status
error: command 'gcc' failed with exit status 1


---------------------------------
Beginnen Sie den Tag mit den neuesten Nachrichten. Machen Sie Yahoo! zu Ihrer Startseite!
Lou Pecora
2008-01-21 17:03:29 UTC
Permalink
Did you include arrayobject.h and call import_array()
in the initialization function, after the call to
Py_InitModule() ?
Post by Danny Chan
Hi!
I am trying to compile a c extension that uses numpy
arrays on windows. I can compile the extension file,
but once I get to the linking stage I get unresolved
references to PyArray_API and import_array. Can
anyone help me with the correct linker flags?
Thanks, Danny
[cut]
Post by Danny Chan
more undefined references to `PyArray_API' follow
undefined reference to `import_array'
collect2: ld returned 1 exit status
error: command 'gcc' failed with exit status 1
-- Lou Pecora, my views are my own.


____________________________________________________________________________________
Looking for last minute shopping deals?
Find them fast with Yahoo! Search. http://tools.search.yahoo.com/newsearch/category.php?category=shopping
Danny Chan
2008-01-22 08:46:41 UTC
Permalink
Yes, that is not the problem. The compiling of the source file works fine, it is when the linker tries to create the shared library file that something blows up.

Lou Pecora <***@yahoo.com> schrieb: Did you include arrayobject.h and call import_array()
in the initialization function, after the call to
Py_InitModule() ?
Post by Danny Chan
Hi!
I am trying to compile a c extension that uses numpy
arrays on windows. I can compile the extension file,
but once I get to the linking stage I get unresolved
references to PyArray_API and import_array. Can
anyone help me with the correct linker flags?
Thanks, Danny
[cut]
Post by Danny Chan
more undefined references to `PyArray_API' follow
undefined reference to `import_array'
collect2: ld returned 1 exit status
error: command 'gcc' failed with exit status 1
-- Lou Pecora, my views are my own.


____________________________________________________________________________________
Looking for last minute shopping deals?
Find them fast with Yahoo! Search. http://tools.search.yahoo.com/newsearch/category.php?category=shopping
_______________________________________________
Numpy-discussion mailing list
Numpy-***@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion



---------------------------------
Heute schon einen Blick in die Zukunft von E-Mails wagen? Versuchen SieŽs mit dem neuen Yahoo! Mail.
Danny Chan
2008-01-22 09:18:09 UTC
Permalink
Ha, found the problem! I thought I had included arrayobject.h and import_array correctly, but due to the preprocessor it wasn't defined correctly!

Danny Chan <***@yahoo.de> schrieb: Yes, that is not the problem. The compiling of the source file works fine, it is when the linker tries to create the shared library file that something blows up.

Lou Pecora <***@yahoo.com> schrieb: Did you include arrayobject.h and call import_array()
in the initialization function, after the call to
Py_InitModule() ?
Post by Danny Chan
Hi!
I am trying to compile a c extension that uses numpy
arrays on windows. I can compile the extension file,
but once I get to the linking stage I get unresolved
references to PyArray_API and import_array. Can
anyone help me with the correct linker flags?
Thanks, Danny
[cut]
Post by Danny Chan
more undefined references to `PyArray_API' follow
undefined reference to `import_array'
collect2: ld returned 1 exit status
error: command 'gcc' failed with exit status 1
-- Lou Pecora, my views are my own.


____________________________________________________________________________________
Looking for last minute shopping deals?
Find them fast with Yahoo! Search. http://tools.search.yahoo.com/newsearch/category.php?category=shopping
_______________________________________________
Numpy-discussion mailing list
Numpy-***@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion



---------------------------------
Heute schon einen Blick in die Zukunft von E-Mails wagen? Versuchen SieŽs mit dem neuen Yahoo! Mail. _______________________________________________
Numpy-discussion mailing list
Numpy-***@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion



---------------------------------
Heute schon einen Blick in die Zukunft von E-Mails wagen? Versuchen SieŽs mit dem neuen Yahoo! Mail.
Continue reading on narkive:
Loading...