2007年11月08日 星期四 18:07
根据swig教程,很简单的例子程序 example.c(后面付有),就差最后一步,请指点: 方法一、MingW / DEV C++ 中的错误: >swig -python example.i (ok,得到example_wrap.c) >gcc -c example.c example_wrap.c -I d:\python24\ (ok,得到两个.o文件) >ld -shared example.o example_wrap.o -o _example.so (没通过,报错如下): ...... example_wrap.o(.text+0x2b34):example_wrap.c: undefined reference to `_imp__PyOS_snprintf' example_wrap.o(.text+0x2bac):example_wrap.c: undefined reference to `_imp__PyObject_Str' example_wrap.o(.text+0x2bc2):example_wrap.c: undefined reference to `_imp__PyString_AsString' ...... 在DEV C++中加入了\python\libs, \python\include\, 编译错误通上: ...... [Linker error] undefined reference to `_imp__PyExc_MemoryError' [Linker error] undefined reference to `_imp__PyExc_IOError' ...... python24为sf上下载的执行版,非本人编译,libs目录中不仅有python24.dll , 还有libpython24.a 方法二、Visual C++ 2005 python的include, libs都加入目录 编译错误: Linking... Creating library d:\Ctest\t2\\test2.lib and object d:\GF7\DigitalFilm\Ctest\t2\\test2.exp example_wrap.obj : error LNK2001: unresolved external symbol "int __cdecl fact(int)" (?fact@@YAHH在Z) example_wrap.obj : error LNK2001: unresolved external symbol "int __cdecl my_mod(int,int)" (?my_mod@@YAHHH在Z) d:\Ctest\t2\\test2.dll : fatal error LNK1120: 2 unresolved externals 源文件附件: ----------------------------------------------- /* File : example.c */ #includedouble My_variable = 3.0; int fact(int n) { if (n <= 1) return 1; else return n*fact(n-1); } int my_mod(int x, int y) { return (x%y); } char *get_time() { time_t ltime; time(<ime;); return ctime(<ime;); } ------------------------------------- /* example.i */ %module example %{ /* Put header files here or function declarations like below */ extern double My_variable; extern int fact(int n); extern int my_mod(int x, int y); extern char *get_time(); %} extern double My_variable; extern int fact(int n); extern int my_mod(int x, int y); extern char *get_time();
2007年11月08日 星期四 18:14
link error通常都是环境没有设置好啦 On Nov 8, 2007 8:07 PM, Jacky Ford <witmud at gmail.com> wrote: > 根据swig教程,很简单的例子程序 example.c(后面付有),就差最后一步,请指点: > > 方法一、MingW / DEV C++ 中的错误: > >swig -python example.i (ok,得到example_wrap.c) > >gcc -c example.c example_wrap.c -I d:\python24\ (ok,得到两个.o文件) > >ld -shared example.o example_wrap.o -o _example.so (没通过,报错如下): > ...... > example_wrap.o(.text+0x2b34):example_wrap.c: undefined reference to > `_imp__PyOS_snprintf' > example_wrap.o(.text+0x2bac):example_wrap.c: undefined reference to > `_imp__PyObject_Str' > example_wrap.o(.text+0x2bc2):example_wrap.c: undefined reference to > `_imp__PyString_AsString' > ...... > > 在DEV C++中加入了\python\libs, \python\include\, 编译错误通上: > ...... > [Linker error] undefined reference to `_imp__PyExc_MemoryError' > [Linker error] undefined reference to `_imp__PyExc_IOError' > ...... > > python24为sf上下载的执行版,非本人编译,libs目录中不仅有python24.dll , 还有libpython24.a > > 方法二、Visual C++ 2005 > python的include, libs都加入目录 > > 编译错误: > Linking... > Creating library d:\Ctest\t2\\test2.lib and object > d:\GF7\DigitalFilm\Ctest\t2\\test2.exp > example_wrap.obj : error LNK2001: unresolved external symbol "int > __cdecl fact(int)" (?fact@@YAHH at Z) > example_wrap.obj : error LNK2001: unresolved external symbol "int > __cdecl my_mod(int,int)" (?my_mod@@YAHHH at Z) > d:\Ctest\t2\\test2.dll : fatal error LNK1120: 2 unresolved externals > > > > 源文件附件: > ----------------------------------------------- > > /* File : example.c */ > > #include> double My_variable = 3.0; > > int fact(int n) { > if (n <= 1) return 1; > else return n*fact(n-1); > } > > int my_mod(int x, int y) { > return (x%y); > } > > char *get_time() > { > time_t ltime; > time(<ime;); > return ctime(<ime;); > } > > ------------------------------------- > > /* example.i */ > %module example > %{ > /* Put header files here or function declarations like below */ > extern double My_variable; > extern int fact(int n); > extern int my_mod(int x, int y); > extern char *get_time(); > %} > > extern double My_variable; > extern int fact(int n); > extern int my_mod(int x, int y); > extern char *get_time(); > _______________________________________________ > python-chinese > Post: send python-chinese at lists.python.cn > Subscribe: send subscribe to python-chinese-request at lists.python.cn > Unsubscribe: send unsubscribe to python-chinese-request at lists.python.cn > Detail Info: http://python.cn/mailman/listinfo/python-chinese -- Any complex technology which doesn't come with documentation must be the best available.
2007年11月08日 星期四 19:35
看了一个文章,把example.c 改成 .cpp就没有那个错误了(VC) 但是只有example.cpp生成的那个.dll,加入example_wrap.cpp后似乎没有生成新的.dll文件 project有example.cpp,example_wrap.cpp, 编译的信息是: Linking... Creating library d:\GF7\DigitalFilm\Ctest\t2\\example.lib and object d:\GF7\DigitalFilm\Ctest\t2\\example.exp On Nov 8, 2007 6:14 PM, xxmplus <xxmplus在gmail.com> wrote: > link error通常都是环境没有设置好啦 > > > On Nov 8, 2007 8:07 PM, Jacky Ford <witmud在gmail.com> wrote: > > 根据swig教程,很简单的例子程序 example.c(后面付有),就差最后一步,请指点: > > > > 方法一、MingW / DEV C++ 中的错误: > > >swig -python example.i (ok,得到example_wrap.c) > > >gcc -c example.c example_wrap.c -I d:\python24\ (ok,得到两个.o文件) > > >ld -shared example.o example_wrap.o -o _example.so (没通过,报错如下): > > ...... > > example_wrap.o(.text+0x2b34):example_wrap.c: undefined reference to > > `_imp__PyOS_snprintf' > > example_wrap.o(.text+0x2bac):example_wrap.c: undefined reference to > > `_imp__PyObject_Str' > > example_wrap.o(.text+0x2bc2):example_wrap.c: undefined reference to > > `_imp__PyString_AsString' > > ...... > > > > 在DEV C++中加入了\python\libs, \python\include\, 编译错误通上: > > ...... > > [Linker error] undefined reference to `_imp__PyExc_MemoryError' > > [Linker error] undefined reference to `_imp__PyExc_IOError' > > ...... > > > > python24为sf上下载的执行版,非本人编译,libs目录中不仅有python24.dll , 还有libpython24.a > > > > 方法二、Visual C++ 2005 > > python的include, libs都加入目录 > > > > 编译错误: > > Linking... > > Creating library d:\Ctest\t2\\test2.lib and object > > d:\GF7\DigitalFilm\Ctest\t2\\test2.exp > > example_wrap.obj : error LNK2001: unresolved external symbol "int > > __cdecl fact(int)" (?fact@@YAHH在Z) > > example_wrap.obj : error LNK2001: unresolved external symbol "int > > __cdecl my_mod(int,int)" (?my_mod@@YAHHH在Z) > > d:\Ctest\t2\\test2.dll : fatal error LNK1120: 2 unresolved externals > > > > > > > > 源文件附件: > > ----------------------------------------------- > > > > /* File : example.c */ > > > > #include> > double My_variable = 3.0; > > > > int fact(int n) { > > if (n <= 1) return 1; > > else return n*fact(n-1); > > } > > > > int my_mod(int x, int y) { > > return (x%y); > > } > > > > char *get_time() > > { > > time_t ltime; > > time(<ime;); > > return ctime(<ime;); > > } > > > > ------------------------------------- > > > > /* example.i */ > > %module example > > %{ > > /* Put header files here or function declarations like below */ > > extern double My_variable; > > extern int fact(int n); > > extern int my_mod(int x, int y); > > extern char *get_time(); > > %} > > > > extern double My_variable; > > extern int fact(int n); > > extern int my_mod(int x, int y); > > extern char *get_time(); > > _______________________________________________ > > python-chinese > > Post: send python-chinese在lists.python.cn > > Subscribe: send subscribe to python-chinese-request在lists.python.cn > > Unsubscribe: send unsubscribe to python-chinese-request在lists.python.cn > > Detail Info: http://python.cn/mailman/listinfo/python-chinese > > > > -- > Any complex technology which doesn't come with documentation must be the best > available. > _______________________________________________ > python-chinese > Post: send python-chinese在lists.python.cn > Subscribe: send subscribe to python-chinese-request在lists.python.cn > Unsubscribe: send unsubscribe to python-chinese-request在lists.python.cn > Detail Info: http://python.cn/mailman/listinfo/python-chinese
2007年11月09日 星期五 14:28
GCCµÄÄǸöÎÒ±àÒë³É¹¦ÁË£¬linkµÄʱºòÒª¼ÓÉÏ-lpython25 -L/i/Python25/libs/Ö¸ Ã÷Á´½Ólibpython25.aºÍÕâ¸ö¿âµÄĿ¼£¬Äã¿ÉÄÜÊÇûÓÐÖ¸Ã÷Á´½Ó¿â(-lpython25) ÁíÎÒÊÇPython2.5°æ¡£ÄãºÃÏñÊÇ2.4£¬µÃÐÞ¸ÄÏ ÔÚ07-11-8£¬Jacky Ford <witmud在gmail.com> дµÀ£º > > ¿´ÁËÒ»¸öÎÄÕ£¬°Ñexample.c ¸Ä³É .cpp¾ÍûÓÐÄǸö´íÎóÁË£¨VC£© > µ«ÊÇÖ»ÓÐexample.cppÉú³ÉµÄÄǸö.dll£¬¼ÓÈëexample_wrap.cppºóËƺõûÓÐÉú³ÉеÄ.dllÎļþ > projectÓÐexample.cpp,example_wrap.cpp, ±àÒëµÄÐÅÏ¢ÊÇ£º > Linking... > Creating library d:\GF7\DigitalFilm\Ctest\t2\\example.lib and > object d:\GF7\DigitalFilm\Ctest\t2\\example.exp > > > On Nov 8, 2007 6:14 PM, xxmplus <xxmplus在gmail.com> wrote: > > link errorͨ³£¶¼ÊÇ»·¾³Ã»ÓÐÉèÖúÃÀ² > > > > > > On Nov 8, 2007 8:07 PM, Jacky Ford <witmud在gmail.com> wrote: > > > ¸ù¾Ýswig½Ì³Ì£¬ºÜ¼òµ¥µÄÀý×Ó³ÌÐò example.c£¨ºóÃ渶ÓУ©£¬¾Í²î×îºóÒ»²½£¬ÇëÖ¸µã£º > > > > > > ·½·¨Ò»¡¢MingW / DEV C++ ÖеĴíÎó£º > > > >swig -python example.i (ok£¬µÃµ½example_wrap.c) > > > >gcc -c example.c example_wrap.c -I d:\python24\ (ok£¬µÃµ½Á½¸ö.oÎļþ£© > > > >ld -shared example.o example_wrap.o -o _example.so (ûͨ¹ý£¬±¨´íÈçÏ£©£º > > > ...... > > > example_wrap.o(.text+0x2b34):example_wrap.c: undefined reference to > > > `_imp__PyOS_snprintf' > > > example_wrap.o(.text+0x2bac):example_wrap.c: undefined reference to > > > `_imp__PyObject_Str' > > > example_wrap.o(.text+0x2bc2):example_wrap.c: undefined reference to > > > `_imp__PyString_AsString' > > > ...... > > > > > > ÔÚDEV C++ÖмÓÈëÁË\python\libs, \python\include\, ±àÒë´íÎóͨÉÏ£º > > > ...... > > > [Linker error] undefined reference to `_imp__PyExc_MemoryError' > > > [Linker error] undefined reference to `_imp__PyExc_IOError' > > > ...... > > > > > > python24ΪsfÉÏÏÂÔصÄÖ´Ðа棬·Ç±¾È˱àÒ룬libsĿ¼Öв»½öÓÐpython24.dll , »¹ÓÐlibpython24.a > > > > > > ·½·¨¶þ¡¢Visual C++ 2005 > > > pythonµÄinclude, libs¶¼¼ÓÈëĿ¼ > > > > > > ±àÒë´íÎó£º > > > Linking... > > > Creating library d:\Ctest\t2\\test2.lib and object > > > d:\GF7\DigitalFilm\Ctest\t2\\test2.exp > > > example_wrap.obj : error LNK2001: unresolved external symbol "int > > > __cdecl fact(int)" (?fact@@YAHH在Z) > > > example_wrap.obj : error LNK2001: unresolved external symbol "int > > > __cdecl my_mod(int,int)" (?my_mod@@YAHHH在Z) > > > d:\Ctest\t2\\test2.dll : fatal error LNK1120: 2 unresolved externals > > > > > > > > > > > > Ô´Îļþ¸½¼þ£º > > > ----------------------------------------------- > > > > > > /* File : example.c */ > > > > > > #include> > > double My_variable = 3.0; > > > > > > int fact(int n) { > > > if (n <= 1) return 1; > > > else return n*fact(n-1); > > > } > > > > > > int my_mod(int x, int y) { > > > return (x%y); > > > } > > > > > > char *get_time() > > > { > > > time_t ltime; > > > time(<ime;); > > > return ctime(<ime;); > > > } > > > > > > ------------------------------------- > > > > > > /* example.i */ > > > %module example > > > %{ > > > /* Put header files here or function declarations like below */ > > > extern double My_variable; > > > extern int fact(int n); > > > extern int my_mod(int x, int y); > > > extern char *get_time(); > > > %} > > > > > > extern double My_variable; > > > extern int fact(int n); > > > extern int my_mod(int x, int y); > > > extern char *get_time(); > > > _______________________________________________ > > > python-chinese > > > Post: send python-chinese在lists.python.cn > > > Subscribe: send subscribe to python-chinese-request在lists.python.cn > > > Unsubscribe: send unsubscribe to > python-chinese-request在lists.python.cn > > > Detail Info: http://python.cn/mailman/listinfo/python-chinese > > > > > > > > -- > > Any complex technology which doesn't come with documentation must be the > best > > available. > > _______________________________________________ > > python-chinese > > Post: send python-chinese在lists.python.cn > > Subscribe: send subscribe to python-chinese-request在lists.python.cn > > Unsubscribe: send unsubscribe to python-chinese-request在lists.python.cn > > Detail Info: http://python.cn/mailman/listinfo/python-chinese > _______________________________________________ > python-chinese > Post: send python-chinese在lists.python.cn > Subscribe: send subscribe to python-chinese-request在lists.python.cn > Unsubscribe: send unsubscribe to python-chinese-request在lists.python.cn > Detail Info: http://python.cn/mailman/listinfo/python-chinese -------------- 下一部分 -------------- Ò»¸öHTML¸½¼þ±»ÒƳý... URL: http://python.cn/pipermail/python-chinese/attachments/20071109/5c0af297/attachment.html
2007年11月09日 星期五 17:56
兄弟,我觉得你说得很对,我试了如下的方式还是报错。 >ld -shared example_wrap.o -o _example.dll -Ld:\python24\libs -Ipython24 d:\python24\libs中有python24.lib, libpython24.a这两个文件。平台是windows xp, dev c++/mingw, python24是从sf下载的,官方windows版本是vs2003编译的,会不会是因为我用gcc编译器不同的原因?目前VC编译已经搞定了,但是我不太喜欢big fat VC,所以希望最好用gcc搞定,以后都用gcc,到linux平台也是通用的。谢谢。 错误信息如下: example_wrap.o(.text+0xae):example_wrap.cxx: undefined reference to `strlen' example_wrap.o(.text+0x13e):example_wrap.cxx: undefined reference to `strlen' example_wrap.o(.text+0x1ef):example_wrap.cxx: undefined reference to `strcmp' example_wrap.o(.text+0x4e3):example_wrap.cxx: undefined reference to `strcmp' example_wrap.o(.text+0x798):example_wrap.cxx: undefined reference to `strlen' example_wrap.o(.text+0x7c9):example_wrap.cxx: undefined reference to `strcpy' example_wrap.o(.text+0x7f5):example_wrap.cxx: undefined reference to `strcmp' example_wrap.o(.text+0x855):example_wrap.cxx: undefined reference to `strlen' example_wrap.o(.text+0x8c7):example_wrap.cxx: undefined reference to `strncpy' example_wrap.o(.text+0x8fb):example_wrap.cxx: undefined reference to `strcmp' example_wrap.o(.text+0x919):example_wrap.cxx: undefined reference to `memset' example_wrap.o(.text+0x97f):example_wrap.cxx: undefined reference to `_imp__PyEx c_MemoryError' example_wrap.o(.text+0x98e):example_wrap.cxx: undefined reference to `_imp__PyEx c_IOError' example_wrap.o(.text+0x99a):example_wrap.cxx: undefined reference to `_imp__PyEx c_RuntimeError' example_wrap.o(.text+0x9a6):example_wrap.cxx: undefined reference to `_imp__PyEx c_IndexError' example_wrap.o(.text+0x9b2):example_wrap.cxx: undefined reference to `_imp__PyEx c_TypeError' example_wrap.o(.text+0x9be):example_wrap.cxx: undefined reference to `_imp__PyEx c_ZeroDivisionError' example_wrap.o(.text+0x9ca):example_wrap.cxx: undefined reference to `_imp__PyEx c_OverflowError' On Nov 9, 2007 2:28 PM, 曹虎 <aerisnju在gmail.com> wrote: > GCC的那个我编译成功了,link的时候要加上-lpython25 > -L/i/Python25/libs/指明链接libpython25.a和这个库的目录,你可能是没有指明链接库(-lpython25) > 另我是Python2.5版。你好像是2.4,得修改下 > > 在07-11-8,Jacky Ford < witmud在gmail.com> 写道: > > > 看了一个文章,把example.c 改成 .cpp就没有那个错误了(VC) > > 但是只有example.cpp生成的那个.dll,加入example_wrap.cpp后似乎没有生成新的.dll文件 > > project有example.cpp,example_wrap.cpp, 编译的信息是: > > Linking... > > Creating library d:\GF7\DigitalFilm\Ctest\t2\\example.lib and > > object d:\GF7\DigitalFilm\Ctest\t2\\example.exp > > > > > > On Nov 8, 2007 6:14 PM, xxmplus <xxmplus在gmail.com> wrote: > > > link error通常都是环境没有设置好啦 > > > > > > > > > On Nov 8, 2007 8:07 PM, Jacky Ford < witmud在gmail.com> wrote: > > > > 根据swig教程,很简单的例子程序 example.c(后面付有),就差最后一步,请指点: > > > > > > > > 方法一、MingW / DEV C++ 中的错误: > > > > >swig -python example.i (ok,得到example_wrap.c) > > > > >gcc -c example.c example_wrap.c -I d:\python24\ (ok,得到两个.o文件) > > > > >ld -shared example.o example_wrap.o -o _example.so (没通过,报错如下): > > > > ...... > > > > example_wrap.o(.text+0x2b34):example_wrap.c: undefined reference to > > > > `_imp__PyOS_snprintf' > > > > example_wrap.o(.text+0x2bac):example_wrap.c: undefined reference to > > > > `_imp__PyObject_Str' > > > > example_wrap.o(.text+0x2bc2):example_wrap.c: undefined reference to > > > > `_imp__PyString_AsString' > > > > ...... > > > > > > > > 在DEV C++中加入了\python\libs, \python\include\, 编译错误通上: > > > > ...... > > > > [Linker error] undefined reference to `_imp__PyExc_MemoryError' > > > > [Linker error] undefined reference to `_imp__PyExc_IOError' > > > > ...... > > > > > > > > python24为sf上下载的执行版,非本人编译,libs目录中不仅有python24.dll , 还有libpython24.a > > > > > > > > 方法二、Visual C++ 2005 > > > > python的include, libs都加入目录 > > > > > > > > 编译错误: > > > > Linking... > > > > Creating library d:\Ctest\t2\\test2.lib and object > > > > d:\GF7\DigitalFilm\Ctest\t2\\test2.exp > > > > example_wrap.obj : error LNK2001: unresolved external symbol "int > > > > __cdecl fact(int)" (?fact@@YAHH在Z) > > > > example_wrap.obj : error LNK2001: unresolved external symbol "int > > > > __cdecl my_mod(int,int)" (?my_mod@@YAHHH在Z) > > > > d:\Ctest\t2\\test2.dll : fatal error LNK1120: 2 unresolved externals > > > > > > > > > > > > > > > > 源文件附件: > > > > ----------------------------------------------- > > > > > > > > /* File : example.c */ > > > > > > > > #include> > > > double My_variable = 3.0; > > > > > > > > int fact(int n) { > > > > if (n <= 1) return 1; > > > > else return n*fact(n-1); > > > > } > > > > > > > > int my_mod(int x, int y) { > > > > return (x%y); > > > > } > > > > > > > > char *get_time() > > > > { > > > > time_t ltime; > > > > time(<ime;); > > > > return ctime(<ime;); > > > > } > > > > > > > > ------------------------------------- > > > > > > > > /* example.i */ > > > > %module example > > > > %{ > > > > /* Put header files here or function declarations like below */ > > > > extern double My_variable; > > > > extern int fact(int n); > > > > extern int my_mod(int x, int y); > > > > extern char *get_time(); > > > > %} > > > > > > > > extern double My_variable; > > > > extern int fact(int n); > > > > extern int my_mod(int x, int y); > > > > extern char *get_time(); > > > > _______________________________________________ > > > > python-chinese > > > > Post: send python-chinese在lists.python.cn > > > > Subscribe: send subscribe to python-chinese-request在lists.python.cn > > > > Unsubscribe: send unsubscribe to > python-chinese-request在lists.python.cn > > > > Detail Info: http://python.cn/mailman/listinfo/python-chinese > > > > > > > > > > > > -- > > > Any complex technology which doesn't come with documentation must be the > best > > > available. > > > _______________________________________________ > > > python-chinese > > > Post: send python-chinese在lists.python.cn > > > Subscribe: send subscribe to python-chinese-request在lists.python.cn > > > Unsubscribe: send unsubscribe to python-chinese-request在lists.python.cn > > > Detail Info: http://python.cn/mailman/listinfo/python-chinese > > _______________________________________________ > > python-chinese > > Post: send python-chinese在lists.python.cn > > Subscribe: send subscribe to python-chinese-request在lists.python.cn > > Unsubscribe: send unsubscribe to python-chinese-request在lists.python.cn > > Detail Info: http://python.cn/mailman/listinfo/python-chinese > > > _______________________________________________ > python-chinese > Post: send python-chinese在lists.python.cn > Subscribe: send subscribe to python-chinese-request在lists.python.cn > Unsubscribe: send unsubscribe to python-chinese-request在lists.python.cn > Detail Info: http://python.cn/mailman/listinfo/python-chinese >
2007年11月09日 星期五 20:16
gccºÍvcµÄ±àÒëÆ÷¿Ï¶¨ÊDz»Ò»ÑùµÄ¡£²»È»¾Í²»»áÓÐÒÆÖ²µÄÎÊÌâ´æÔÚÁË¡£ ÔÚ07-11-9£¬Jacky Ford <witmud在gmail.com> дµÀ£º > > Ðֵܣ¬ÎÒ¾õµÃÄã˵µÃºÜ¶Ô£¬ÎÒÊÔÁËÈçϵķ½Ê½»¹ÊDZ¨´í¡£ > >ld -shared example_wrap.o -o _example.dll -Ld:\python24\libs -Ipython24 > > d:\python24\libsÖÐÓÐpython24.lib, libpython24.aÕâÁ½¸öÎļþ¡£Æ½Ì¨ÊÇwindows xp, dev > c++/mingw, > python24ÊÇ´ÓsfÏÂÔصģ¬¹Ù·½windows°æ±¾ÊÇvs2003±àÒëµÄ£¬»á²»»áÊÇÒòΪÎÒÓÃgcc±àÒëÆ÷²»Í¬µÄÔÒò£¿Ä¿Ç°VC±àÒëÒѾ¸ã¶¨ÁË£¬µ«ÊÇÎÒ²»Ì«Ï²»¶big > fat VC,ËùÒÔÏ£Íû×îºÃÓÃgcc¸ã¶¨£¬ÒÔºó¶¼ÓÃgcc£¬µ½linuxƽ̨ҲÊÇͨÓõġ£Ð»Ð»¡£ > > ´íÎóÐÅÏ¢ÈçÏ£º > > example_wrap.o(.text+0xae):example_wrap.cxx: undefined reference to > `strlen' > example_wrap.o(.text+0x13e):example_wrap.cxx: undefined reference to > `strlen' > example_wrap.o(.text+0x1ef):example_wrap.cxx: undefined reference to > `strcmp' > example_wrap.o(.text+0x4e3):example_wrap.cxx: undefined reference to > `strcmp' > example_wrap.o(.text+0x798):example_wrap.cxx: undefined reference to > `strlen' > example_wrap.o(.text+0x7c9):example_wrap.cxx: undefined reference to > `strcpy' > example_wrap.o(.text+0x7f5):example_wrap.cxx: undefined reference to > `strcmp' > example_wrap.o(.text+0x855):example_wrap.cxx: undefined reference to > `strlen' > example_wrap.o(.text+0x8c7):example_wrap.cxx: undefined reference to > `strncpy' > example_wrap.o(.text+0x8fb):example_wrap.cxx: undefined reference to > `strcmp' > example_wrap.o(.text+0x919):example_wrap.cxx: undefined reference to > `memset' > example_wrap.o(.text+0x97f):example_wrap.cxx: undefined reference to > `_imp__PyEx > c_MemoryError' > example_wrap.o(.text+0x98e):example_wrap.cxx: undefined reference to > `_imp__PyEx > c_IOError' > example_wrap.o(.text+0x99a):example_wrap.cxx: undefined reference to > `_imp__PyEx > c_RuntimeError' > example_wrap.o(.text+0x9a6):example_wrap.cxx: undefined reference to > `_imp__PyEx > c_IndexError' > example_wrap.o(.text+0x9b2):example_wrap.cxx: undefined reference to > `_imp__PyEx > c_TypeError' > example_wrap.o(.text+0x9be):example_wrap.cxx: undefined reference to > `_imp__PyEx > c_ZeroDivisionError' > example_wrap.o(.text+0x9ca):example_wrap.cxx: undefined reference to > `_imp__PyEx > c_OverflowError' > > > > On Nov 9, 2007 2:28 PM, ²Ü»¢ <aerisnju在gmail.com> wrote: > > GCCµÄÄǸöÎÒ±àÒë³É¹¦ÁË£¬linkµÄʱºòÒª¼ÓÉÏ-lpython25 > > -L/i/Python25/libs/Ö¸Ã÷Á´½Ólibpython25.aºÍÕâ¸ö¿âµÄĿ¼£¬Äã¿ÉÄÜÊÇûÓÐÖ¸Ã÷Á´½Ó¿â(-lpython25) > > ÁíÎÒÊÇPython2.5°æ¡£ÄãºÃÏñÊÇ2.4£¬µÃÐÞ¸ÄÏ > > > > ÔÚ07-11-8£¬Jacky Ford < witmud在gmail.com> дµÀ£º > > > > > ¿´ÁËÒ»¸öÎÄÕ£¬°Ñexample.c ¸Ä³É .cpp¾ÍûÓÐÄǸö´íÎóÁË£¨VC£© > > > µ«ÊÇÖ»ÓÐexample.cppÉú³ÉµÄÄǸö.dll£¬¼ÓÈëexample_wrap.cppºóËƺõûÓÐÉú³ÉеÄ.dllÎļþ > > > projectÓÐexample.cpp,example_wrap.cpp, ±àÒëµÄÐÅÏ¢ÊÇ£º > > > Linking... > > > Creating library d:\GF7\DigitalFilm\Ctest\t2\\example.lib and > > > object d:\GF7\DigitalFilm\Ctest\t2\\example.exp > > > > > > > > > On Nov 8, 2007 6:14 PM, xxmplus <xxmplus在gmail.com> wrote: > > > > link errorͨ³£¶¼ÊÇ»·¾³Ã»ÓÐÉèÖúÃÀ² > > > > > > > > > > > > On Nov 8, 2007 8:07 PM, Jacky Ford < witmud在gmail.com> wrote: > > > > > ¸ù¾Ýswig½Ì³Ì£¬ºÜ¼òµ¥µÄÀý×Ó³ÌÐò example.c£¨ºóÃ渶ÓУ©£¬¾Í²î×îºóÒ»²½£¬ÇëÖ¸µã£º > > > > > > > > > > ·½·¨Ò»¡¢MingW / DEV C++ ÖеĴíÎó£º > > > > > >swig -python example.i (ok£¬µÃµ½example_wrap.c) > > > > > >gcc -c example.c example_wrap.c -I d:\python24\ (ok£¬µÃµ½Á½¸ö.oÎļþ£© > > > > > >ld -shared example.o example_wrap.o -o _example.so (ûͨ¹ý£¬±¨´íÈçÏ£©£º > > > > > ...... > > > > > example_wrap.o(.text+0x2b34):example_wrap.c: undefined reference > to > > > > > `_imp__PyOS_snprintf' > > > > > example_wrap.o(.text+0x2bac):example_wrap.c: undefined reference > to > > > > > `_imp__PyObject_Str' > > > > > example_wrap.o(.text+0x2bc2):example_wrap.c: undefined reference > to > > > > > `_imp__PyString_AsString' > > > > > ...... > > > > > > > > > > ÔÚDEV C++ÖмÓÈëÁË\python\libs, \python\include\, ±àÒë´íÎóͨÉÏ£º > > > > > ...... > > > > > [Linker error] undefined reference to `_imp__PyExc_MemoryError' > > > > > [Linker error] undefined reference to `_imp__PyExc_IOError' > > > > > ...... > > > > > > > > > > python24ΪsfÉÏÏÂÔصÄÖ´Ðа棬·Ç±¾È˱àÒ룬libsĿ¼Öв»½öÓÐpython24.dll , »¹ÓÐlibpython24.a > > > > > > > > > > ·½·¨¶þ¡¢Visual C++ 2005 > > > > > pythonµÄinclude, libs¶¼¼ÓÈëĿ¼ > > > > > > > > > > ±àÒë´íÎó£º > > > > > Linking... > > > > > Creating library d:\Ctest\t2\\test2.lib and object > > > > > d:\GF7\DigitalFilm\Ctest\t2\\test2.exp > > > > > example_wrap.obj : error LNK2001: unresolved external symbol "int > > > > > __cdecl fact(int)" (?fact@@YAHH在Z) > > > > > example_wrap.obj : error LNK2001: unresolved external symbol "int > > > > > __cdecl my_mod(int,int)" (?my_mod@@YAHHH在Z) > > > > > d:\Ctest\t2\\test2.dll : fatal error LNK1120: 2 unresolved > externals > > > > > > > > > > > > > > > > > > > > Ô´Îļþ¸½¼þ£º > > > > > ----------------------------------------------- > > > > > > > > > > /* File : example.c */ > > > > > > > > > > #include> > > > > double My_variable = 3.0; > > > > > > > > > > int fact(int n) { > > > > > if (n <= 1) return 1; > > > > > else return n*fact(n-1); > > > > > } > > > > > > > > > > int my_mod(int x, int y) { > > > > > return (x%y); > > > > > } > > > > > > > > > > char *get_time() > > > > > { > > > > > time_t ltime; > > > > > time(<ime;); > > > > > return ctime(<ime;); > > > > > } > > > > > > > > > > ------------------------------------- > > > > > > > > > > /* example.i */ > > > > > %module example > > > > > %{ > > > > > /* Put header files here or function declarations like below */ > > > > > extern double My_variable; > > > > > extern int fact(int n); > > > > > extern int my_mod(int x, int y); > > > > > extern char *get_time(); > > > > > %} > > > > > > > > > > extern double My_variable; > > > > > extern int fact(int n); > > > > > extern int my_mod(int x, int y); > > > > > extern char *get_time(); > > > > > _______________________________________________ > > > > > python-chinese > > > > > Post: send python-chinese在lists.python.cn > > > > > Subscribe: send subscribe to > python-chinese-request在lists.python.cn > > > > > Unsubscribe: send unsubscribe to > > python-chinese-request在lists.python.cn > > > > > Detail Info: http://python.cn/mailman/listinfo/python-chinese > > > > > > > > > > > > > > > > -- > > > > Any complex technology which doesn't come with documentation must be > the > > best > > > > available. > > > > _______________________________________________ > > > > python-chinese > > > > Post: send python-chinese在lists.python.cn > > > > Subscribe: send subscribe to python-chinese-request在lists.python.cn > > > > Unsubscribe: send unsubscribe to > python-chinese-request在lists.python.cn > > > > Detail Info: http://python.cn/mailman/listinfo/python-chinese > > > _______________________________________________ > > > python-chinese > > > Post: send python-chinese在lists.python.cn > > > Subscribe: send subscribe to python-chinese-request在lists.python.cn > > > Unsubscribe: send unsubscribe to > python-chinese-request在lists.python.cn > > > Detail Info: http://python.cn/mailman/listinfo/python-chinese > > > > > > _______________________________________________ > > python-chinese > > Post: send python-chinese在lists.python.cn > > Subscribe: send subscribe to python-chinese-request在lists.python.cn > > Unsubscribe: send unsubscribe to python-chinese-request在lists.python.cn > > Detail Info: http://python.cn/mailman/listinfo/python-chinese > > > _______________________________________________ > python-chinese > Post: send python-chinese在lists.python.cn > Subscribe: send subscribe to python-chinese-request在lists.python.cn > Unsubscribe: send unsubscribe to python-chinese-request在lists.python.cn > Detail Info: http://python.cn/mailman/listinfo/python-chinese -------------- 下一部分 -------------- Ò»¸öHTML¸½¼þ±»ÒƳý... URL: http://python.cn/pipermail/python-chinese/attachments/20071109/2541c10c/attachment.html
2007年11月09日 星期五 20:21
ÎÒÕâÀïMSYS+MinGW£¬¹Ù·½Windows°æPython25£¬ Ö±½Ó $ gcc example.c example_wrap.c -shared -o_example.pyd -IC:/Python25/include -LC:/Python25/libs -lpython25 ¾Í¿ÉÒÔÁË¡¡ ÊÂʵÉÏÎÒ¾õµÃ»¹ÊÇVC±àÒë³öÀ´µÄÎļþ±È½ÏСå On Nov 9, 2007 5:56 PM, Jacky Ford <witmud在gmail.com> wrote: > Ðֵܣ¬ÎÒ¾õµÃÄã˵µÃºÜ¶Ô£¬ÎÒÊÔÁËÈçϵķ½Ê½»¹ÊDZ¨´í¡£ > >ld -shared example_wrap.o -o _example.dll -Ld:\python24\libs -Ipython24 > > d:\python24\libsÖÐÓÐpython24.lib, libpython24.aÕâÁ½¸öÎļþ¡£Æ½Ì¨ÊÇwindows xp, dev > c++/mingw, > python24ÊÇ´ÓsfÏÂÔصģ¬¹Ù·½windows°æ±¾ÊÇvs2003±àÒëµÄ£¬»á²»»áÊÇÒòΪÎÒÓÃgcc±àÒëÆ÷²»Í¬µÄÔÒò£¿Ä¿Ç°VC±àÒëÒѾ¸ã¶¨ÁË£¬µ«ÊÇÎÒ²»Ì«Ï²»¶big > fat VC,ËùÒÔÏ£Íû×îºÃÓÃgcc¸ã¶¨£¬ÒÔºó¶¼ÓÃgcc£¬µ½linuxƽ̨ҲÊÇͨÓõġ£Ð»Ð»¡£ > > ´íÎóÐÅÏ¢ÈçÏ£º > > example_wrap.o(.text+0xae):example_wrap.cxx: undefined reference to > `strlen' > example_wrap.o(.text+0x13e):example_wrap.cxx: undefined reference to > `strlen' > example_wrap.o(.text+0x1ef):example_wrap.cxx: undefined reference to > `strcmp' > example_wrap.o(.text+0x4e3):example_wrap.cxx: undefined reference to > `strcmp' > example_wrap.o(.text+0x798):example_wrap.cxx: undefined reference to > `strlen' > example_wrap.o(.text+0x7c9):example_wrap.cxx: undefined reference to > `strcpy' > example_wrap.o(.text+0x7f5):example_wrap.cxx: undefined reference to > `strcmp' > example_wrap.o(.text+0x855):example_wrap.cxx: undefined reference to > `strlen' > example_wrap.o(.text+0x8c7):example_wrap.cxx: undefined reference to > `strncpy' > example_wrap.o(.text+0x8fb):example_wrap.cxx: undefined reference to > `strcmp' > example_wrap.o(.text+0x919):example_wrap.cxx: undefined reference to > `memset' > example_wrap.o(.text+0x97f):example_wrap.cxx: undefined reference to > `_imp__PyEx > c_MemoryError' > example_wrap.o(.text+0x98e):example_wrap.cxx: undefined reference to > `_imp__PyEx > c_IOError' > example_wrap.o(.text+0x99a):example_wrap.cxx: undefined reference to > `_imp__PyEx > c_RuntimeError' > example_wrap.o(.text+0x9a6):example_wrap.cxx: undefined reference to > `_imp__PyEx > c_IndexError' > example_wrap.o(.text+0x9b2):example_wrap.cxx: undefined reference to > `_imp__PyEx > c_TypeError' > example_wrap.o(.text+0x9be):example_wrap.cxx: undefined reference to > `_imp__PyEx > c_ZeroDivisionError' > example_wrap.o(.text+0x9ca):example_wrap.cxx: undefined reference to > `_imp__PyEx > c_OverflowError' > > > > On Nov 9, 2007 2:28 PM, ²Ü»¢ <aerisnju在gmail.com> wrote: > > GCCµÄÄǸöÎÒ±àÒë³É¹¦ÁË£¬linkµÄʱºòÒª¼ÓÉÏ-lpython25 > > -L/i/Python25/libs/Ö¸Ã÷Á´½Ólibpython25.aºÍÕâ¸ö¿âµÄĿ¼£¬Äã¿ÉÄÜÊÇûÓÐÖ¸Ã÷Á´½Ó¿â(-lpython25) > > ÁíÎÒÊÇPython2.5°æ¡£ÄãºÃÏñÊÇ2.4£¬µÃÐÞ¸ÄÏ > > > > ÔÚ07-11-8£¬Jacky Ford < witmud在gmail.com> дµÀ£º > > > > > ¿´ÁËÒ»¸öÎÄÕ£¬°Ñexample.c ¸Ä³É .cpp¾ÍûÓÐÄǸö´íÎóÁË£¨VC£© > > > µ«ÊÇÖ»ÓÐexample.cppÉú³ÉµÄÄǸö.dll£¬¼ÓÈëexample_wrap.cppºóËƺõûÓÐÉú³ÉеÄ.dllÎļþ > > > projectÓÐexample.cpp,example_wrap.cpp, ±àÒëµÄÐÅÏ¢ÊÇ£º > > > Linking... > > > Creating library d:\GF7\DigitalFilm\Ctest\t2\\example.lib and > > > object d:\GF7\DigitalFilm\Ctest\t2\\example.exp > > > > > > > > > On Nov 8, 2007 6:14 PM, xxmplus <xxmplus在gmail.com> wrote: > > > > link errorͨ³£¶¼ÊÇ»·¾³Ã»ÓÐÉèÖúÃÀ² > > > > > > > > > > > > On Nov 8, 2007 8:07 PM, Jacky Ford < witmud在gmail.com> wrote: > > > > > ¸ù¾Ýswig½Ì³Ì£¬ºÜ¼òµ¥µÄÀý×Ó³ÌÐò example.c£¨ºóÃ渶ÓУ©£¬¾Í²î×îºóÒ»²½£¬ÇëÖ¸µã£º > > > > > > > > > > ·½·¨Ò»¡¢MingW / DEV C++ ÖеĴíÎó£º > > > > > >swig -python example.i (ok£¬µÃµ½example_wrap.c) > > > > > >gcc -c example.c example_wrap.c -I d:\python24\ (ok£¬µÃµ½Á½¸ö.oÎļþ£© > > > > > >ld -shared example.o example_wrap.o -o _example.so (ûͨ¹ý£¬±¨´íÈçÏ£©£º > > > > > ...... > > > > > example_wrap.o(.text+0x2b34):example_wrap.c: undefined reference > to > > > > > `_imp__PyOS_snprintf' > > > > > example_wrap.o(.text+0x2bac):example_wrap.c: undefined reference > to > > > > > `_imp__PyObject_Str' > > > > > example_wrap.o(.text+0x2bc2):example_wrap.c: undefined reference > to > > > > > `_imp__PyString_AsString' > > > > > ...... > > > > > > > > > > ÔÚDEV C++ÖмÓÈëÁË\python\libs, \python\include\, ±àÒë´íÎóͨÉÏ£º > > > > > ...... > > > > > [Linker error] undefined reference to `_imp__PyExc_MemoryError' > > > > > [Linker error] undefined reference to `_imp__PyExc_IOError' > > > > > ...... > > > > > > > > > > python24ΪsfÉÏÏÂÔصÄÖ´Ðа棬·Ç±¾È˱àÒ룬libsĿ¼Öв»½öÓÐpython24.dll , »¹ÓÐlibpython24.a > > > > > > > > > > ·½·¨¶þ¡¢Visual C++ 2005 > > > > > pythonµÄinclude, libs¶¼¼ÓÈëĿ¼ > > > > > > > > > > ±àÒë´íÎó£º > > > > > Linking... > > > > > Creating library d:\Ctest\t2\\test2.lib and object > > > > > d:\GF7\DigitalFilm\Ctest\t2\\test2.exp > > > > > example_wrap.obj : error LNK2001: unresolved external symbol "int > > > > > __cdecl fact(int)" (?fact@@YAHH在Z) > > > > > example_wrap.obj : error LNK2001: unresolved external symbol "int > > > > > __cdecl my_mod(int,int)" (?my_mod@@YAHHH在Z) > > > > > d:\Ctest\t2\\test2.dll : fatal error LNK1120: 2 unresolved > externals > > > > > > > > > > > > > > > > > > > > Ô´Îļþ¸½¼þ£º > > > > > ----------------------------------------------- > > > > > > > > > > /* File : example.c */ > > > > > > > > > > #include> > > > > double My_variable = 3.0; > > > > > > > > > > int fact(int n) { > > > > > if (n <= 1) return 1; > > > > > else return n*fact(n-1); > > > > > } > > > > > > > > > > int my_mod(int x, int y) { > > > > > return (x%y); > > > > > } > > > > > > > > > > char *get_time() > > > > > { > > > > > time_t ltime; > > > > > time(<ime;); > > > > > return ctime(<ime;); > > > > > } > > > > > > > > > > ------------------------------------- > > > > > > > > > > /* example.i */ > > > > > %module example > > > > > %{ > > > > > /* Put header files here or function declarations like below */ > > > > > extern double My_variable; > > > > > extern int fact(int n); > > > > > extern int my_mod(int x, int y); > > > > > extern char *get_time(); > > > > > %} > > > > > > > > > > extern double My_variable; > > > > > extern int fact(int n); > > > > > extern int my_mod(int x, int y); > > > > > extern char *get_time(); > > > > > _______________________________________________ > > > > > python-chinese > > > > > Post: send python-chinese在lists.python.cn > > > > > Subscribe: send subscribe to > python-chinese-request在lists.python.cn > > > > > Unsubscribe: send unsubscribe to > > python-chinese-request在lists.python.cn > > > > > Detail Info: http://python.cn/mailman/listinfo/python-chinese > > > > > > > > > > > > > > > > -- > > > > Any complex technology which doesn't come with documentation must be > the > > best > > > > available. > > > > _______________________________________________ > > > > python-chinese > > > > Post: send python-chinese在lists.python.cn > > > > Subscribe: send subscribe to python-chinese-request在lists.python.cn > > > > Unsubscribe: send unsubscribe to > python-chinese-request在lists.python.cn > > > > Detail Info: http://python.cn/mailman/listinfo/python-chinese > > > _______________________________________________ > > > python-chinese > > > Post: send python-chinese在lists.python.cn > > > Subscribe: send subscribe to python-chinese-request在lists.python.cn > > > Unsubscribe: send unsubscribe to > python-chinese-request在lists.python.cn > > > Detail Info: http://python.cn/mailman/listinfo/python-chinese > > > > > > _______________________________________________ > > python-chinese > > Post: send python-chinese在lists.python.cn > > Subscribe: send subscribe to python-chinese-request在lists.python.cn > > Unsubscribe: send unsubscribe to python-chinese-request在lists.python.cn > > Detail Info: http://python.cn/mailman/listinfo/python-chinese > > > _______________________________________________ > python-chinese > Post: send python-chinese在lists.python.cn > Subscribe: send subscribe to python-chinese-request在lists.python.cn > Unsubscribe: send unsubscribe to python-chinese-request在lists.python.cn > Detail Info: http://python.cn/mailman/listinfo/python-chinese > -------------- 下一部分 -------------- Ò»¸öHTML¸½¼þ±»ÒƳý... URL: http://python.cn/pipermail/python-chinese/attachments/20071109/8cf10a05/attachment.html
2007年11月10日 星期六 10:38
û¿´µ½ÏÖÔÚVC±àÒë³öÀ´µÄ³ÌÐòÐèÒª´ø2¸ömsvc*.dllÂð£¬800¶àKÄØ:) ÔÚ 07-11-9£¬Zhou Honglin<zhou.honglin在gmail.com> дµÀ£º > ÎÒÕâÀïMSYS+MinGW£¬¹Ù·½Windows°æPython25£¬ Ö±½Ó > > $ gcc example.c example_wrap.c -shared -o_example.pyd -IC:/Python25/include > -LC:/Python25/libs -lpython25 > ¾Í¿ÉÒÔÁË¡¡ > > ÊÂʵÉÏÎÒ¾õµÃ»¹ÊÇVC±àÒë³öÀ´µÄÎļþ±È½ÏСå > > > On Nov 9, 2007 5:56 PM, Jacky Ford < witmud在gmail.com> wrote: > > Ðֵܣ¬ÎÒ¾õµÃÄã˵µÃºÜ¶Ô£¬ÎÒÊÔÁËÈçϵķ½Ê½»¹ÊDZ¨´í¡£ > > >ld -shared example_wrap.o -o _example.dll -Ld:\python24\libs -Ipython24 > > > > d:\python24\libsÖÐÓÐpython24.lib, libpython24.aÕâÁ½¸öÎļþ¡£Æ½Ì¨ÊÇwindows xp, dev > > c++/mingw, > python24ÊÇ´ÓsfÏÂÔصģ¬¹Ù·½windows°æ±¾ÊÇvs2003±àÒëµÄ£¬»á²»»áÊÇÒòΪÎÒÓÃgcc±àÒëÆ÷²»Í¬µÄÔÒò£¿Ä¿Ç°VC±àÒëÒѾ¸ã¶¨ÁË£¬µ«ÊÇÎÒ²»Ì«Ï²»¶big > > fat VC,ËùÒÔÏ£Íû×îºÃÓÃgcc¸ã¶¨£¬ÒÔºó¶¼ÓÃgcc£¬µ½linuxƽ̨ҲÊÇͨÓõġ£Ð»Ð»¡£ > > > > ´íÎóÐÅÏ¢ÈçÏ£º > > > > example_wrap.o(.text+0xae):example_wrap.cxx: undefined > reference to `strlen' > > example_wrap.o(.text+0x13e):example_wrap.cxx: undefined > reference to `strlen' > > example_wrap.o(.text+0x1ef):example_wrap.cxx: undefined > reference to `strcmp' > > example_wrap.o(.text+0x4e3):example_wrap.cxx: undefined > reference to `strcmp' > > example_wrap.o(.text+0x798):example_wrap.cxx: undefined > reference to `strlen' > > example_wrap.o(.text+0x7c9):example_wrap.cxx: undefined > reference to `strcpy' > > example_wrap.o(.text+0x7f5):example_wrap.cxx: undefined > reference to `strcmp' > > example_wrap.o(.text+0x855):example_wrap.cxx: undefined > reference to `strlen' > > example_wrap.o(.text+0x8c7):example_wrap.cxx: undefined > reference to `strncpy' > > example_wrap.o(.text+0x8fb):example_wrap.cxx: undefined > reference to `strcmp' > > example_wrap.o(.text+0x919):example_wrap.cxx: undefined > reference to `memset' > > example_wrap.o(.text+0x97f):example_wrap.cxx: undefined > reference to `_imp__PyEx > > c_MemoryError' > > example_wrap.o(.text+0x98e):example_wrap.cxx: undefined > reference to `_imp__PyEx > > c_IOError' > > example_wrap.o(.text+0x99a):example_wrap.cxx: undefined > reference to `_imp__PyEx > > c_RuntimeError' > > example_wrap.o(.text+0x9a6):example_wrap.cxx: undefined > reference to `_imp__PyEx > > c_IndexError' > > example_wrap.o(.text+0x9b2):example_wrap.cxx: undefined > reference to `_imp__PyEx > > c_TypeError' > > example_wrap.o(.text+0x9be):example_wrap.cxx: undefined > reference to `_imp__PyEx > > c_ZeroDivisionError' > > example_wrap.o(.text+0x9ca):example_wrap.cxx: undefined > reference to `_imp__PyEx > > c_OverflowError' > > > > > > > > > > > > > > On Nov 9, 2007 2:28 PM, ²Ü»¢ <aerisnju在gmail.com> wrote: > > > GCCµÄÄǸöÎÒ±àÒë³É¹¦ÁË£¬linkµÄʱºòÒª¼ÓÉÏ-lpython25 > > > -L/i/Python25/libs/Ö¸Ã÷Á´½Ólibpython25.aºÍÕâ¸ö¿âµÄĿ¼£¬ Äã¿ÉÄÜÊÇûÓÐÖ¸Ã÷Á´½Ó¿â(-lpython25) > > > ÁíÎÒÊÇPython2.5°æ¡£ÄãºÃÏñÊÇ2.4£¬µÃÐÞ¸ÄÏ > > > > > > ÔÚ07-11-8£¬Jacky Ford < witmud在gmail.com> дµÀ£º > > > > > > > ¿´ÁËÒ»¸öÎÄÕ£¬°Ñexample.c ¸Ä³É .cpp¾ÍûÓÐÄǸö´íÎóÁË£¨VC£© > > > > µ«ÊÇÖ»ÓÐexample.cppÉú³ÉµÄÄǸö.dll£¬¼ÓÈëexample_wrap.cppºóËƺõûÓÐÉú³ÉеÄ.dllÎļþ > > > > projectÓÐexample.cpp,example_wrap.cpp, ±àÒëµÄÐÅÏ¢ÊÇ£º > > > > Linking... > > > > Creating library > d:\GF7\DigitalFilm\Ctest\t2\\example.lib and > > > > object d:\GF7\DigitalFilm\Ctest\t2\\example.exp > > > > > > > > > > > > On Nov 8, 2007 6:14 PM, xxmplus <xxmplus在gmail.com> wrote: > > > > > link errorͨ³£¶¼ÊÇ»·¾³Ã»ÓÐÉèÖúÃÀ² > > > > > > > > > > > > > > > On Nov 8, 2007 8:07 PM, Jacky Ford < witmud在gmail.com> wrote: > > > > > > ¸ù¾Ýswig½Ì³Ì£¬ºÜ¼òµ¥µÄÀý×Ó³ÌÐò example.c£¨ºóÃ渶ÓУ©£¬¾Í²î×îºóÒ»²½£¬ÇëÖ¸µã£º > > > > > > > > > > > > ·½·¨Ò»¡¢MingW / DEV C++ ÖеĴíÎó£º > > > > > > >swig -python example.i (ok£¬µÃµ½example_wrap.c) > > > > > > >gcc -c example.c example_wrap.c -I d:\python24\ (ok£¬ µÃµ½Á½¸ö.oÎļþ£© > > > > > > >ld -shared example.o example_wrap.o -o _example.so (ûͨ¹ý£¬±¨´íÈçÏ£©£º > > > > > > ...... > > > > > > example_wrap.o(.text+0x2b34):example_wrap.c: > undefined reference to > > > > > > `_imp__PyOS_snprintf' > > > > > > example_wrap.o(.text+0x2bac):example_wrap.c: > undefined reference to > > > > > > `_imp__PyObject_Str' > > > > > > example_wrap.o(.text+0x2bc2):example_wrap.c: > undefined reference to > > > > > > `_imp__PyString_AsString' > > > > > > ...... > > > > > > > > > > > > ÔÚDEV C++ÖмÓÈëÁË\python\libs, \python\include\, ±àÒë´íÎóͨÉÏ£º > > > > > > ...... > > > > > > [Linker error] undefined reference to `_imp__PyExc_MemoryError' > > > > > > [Linker error] undefined reference to `_imp__PyExc_IOError' > > > > > > ...... > > > > > > > > > > > > python24ΪsfÉÏÏÂÔصÄÖ´Ðа棬·Ç±¾È˱àÒ룬libsĿ¼Öв»½öÓÐpython24.dll , »¹ÓÐlibpython24.a > > > > > > > > > > > > ·½·¨¶þ¡¢Visual C++ 2005 > > > > > > pythonµÄinclude, libs¶¼¼ÓÈëĿ¼ > > > > > > > > > > > > ±àÒë´íÎó£º > > > > > > Linking... > > > > > > Creating library d:\Ctest\t2\\test2.lib and object > > > > > > d:\GF7\DigitalFilm\Ctest\t2\\test2.exp > > > > > > example_wrap.obj : error LNK2001: unresolved external symbol "int > > > > > > __cdecl fact(int)" (?fact@@YAHH在Z) > > > > > > example_wrap.obj : error LNK2001: unresolved external symbol "int > > > > > > __cdecl my_mod(int,int)" (?my_mod@@YAHHH在Z) > > > > > > d:\Ctest\t2\\test2.dll : fatal error LNK1120: 2 unresolved > externals > > > > > > > > > > > > > > > > > > > > > > > > Ô´Îļþ¸½¼þ£º > > > > > > ----------------------------------------------- > > > > > > > > > > > > /* File : example.c */ > > > > > > > > > > > > #include> > > > > > double My_variable = 3.0; > > > > > > > > > > > > int fact(int n) { > > > > > > if (n <= 1) return 1; > > > > > > else return n*fact(n-1); > > > > > > } > > > > > > > > > > > > int my_mod(int x, int y) { > > > > > > return (x%y); > > > > > > } > > > > > > > > > > > > char *get_time() > > > > > > { > > > > > > time_t ltime; > > > > > > time(<ime;); > > > > > > return ctime(<ime;); > > > > > > } > > > > > > > > > > > > ------------------------------------- > > > > > > > > > > > > /* example.i */ > > > > > > %module example > > > > > > %{ > > > > > > /* Put header files here or function declarations like below */ > > > > > > extern double My_variable; > > > > > > extern int fact(int n); > > > > > > extern int my_mod(int x, int y); > > > > > > extern char *get_time(); > > > > > > %} > > > > > > > > > > > > extern double My_variable; > > > > > > extern int fact(int n); > > > > > > extern int my_mod(int x, int y); > > > > > > extern char *get_time(); > > > > > > _______________________________________________ > > > > > > python-chinese > > > > > > Post: send python-chinese在lists.python.cn > > > > > > Subscribe: send subscribe to > python-chinese-request在lists.python.cn > > > > > > Unsubscribe: send unsubscribe to > > > python-chinese-request在lists.python.cn > > > > > > Detail Info: > http://python.cn/mailman/listinfo/python-chinese > > > > > > > > > > > > > > > > > > > > -- > > > > > Any complex technology which doesn't come with documentation must be > the > > > best > > > > > available. > > > > > _______________________________________________ > > > > > python-chinese > > > > > Post: send python-chinese在lists.python.cn > > > > > Subscribe: send subscribe to > python-chinese-request在lists.python.cn > > > > > Unsubscribe: send unsubscribe to > python-chinese-request在lists.python.cn > > > > > Detail Info: > http://python.cn/mailman/listinfo/python-chinese > > > > _______________________________________________ > > > > python-chinese > > > > Post: send python-chinese在lists.python.cn > > > > Subscribe: send subscribe to > python-chinese-request在lists.python.cn > > > > Unsubscribe: send unsubscribe to > python-chinese-request在lists.python.cn > > > > Detail Info: > http://python.cn/mailman/listinfo/python-chinese > > > > > > > > > _______________________________________________ > > > > > > > > > python-chinese > > > Post: send python-chinese在lists.python.cn > > > Subscribe: send subscribe to > python-chinese-request在lists.python.cn > > > Unsubscribe: send unsubscribe to > python-chinese-request在lists.python.cn > > > Detail Info: > http://python.cn/mailman/listinfo/python-chinese > > > > > _______________________________________________ > > python-chinese > > Post: send python-chinese在lists.python.cn > > Subscribe: send subscribe to > python-chinese-request在lists.python.cn > > Unsubscribe: send unsubscribe to > python-chinese-request在lists.python.cn > > Detail Info: > http://python.cn/mailman/listinfo/python-chinese > > > _______________________________________________ > python-chinese > Post: send python-chinese在lists.python.cn > Subscribe: send subscribe to > python-chinese-request在lists.python.cn > Unsubscribe: send unsubscribe to > python-chinese-request在lists.python.cn > Detail Info: > http://python.cn/mailman/listinfo/python-chinese >
Zeuux © 2025
京ICP备05028076号