编译疯狂蟒蛇的错误

时间:2014-01-21 20:42:52

标签: python c++ lua python-module mingw32

在尝试构建疯狂蟒蛇时,我尝试过多次编译器的错误。 Mingw是我得到的最远的编译器,目前我正在收到包含

的垃圾邮件
luainpython.o:luainpython.c:(.text+0x1b): undefined reference to `lua_type'
luainpython.o:luainpython.c:(.text+0x32): undefined reference to `_imp___Py_None
Struct'
luainpython.o:luainpython.c:(.text+0x3c): undefined reference to `_imp___Py_None
Struct'
luainpython.o:luainpython.c:(.text+0x43): undefined reference to `_imp___Py_None
Struct'
luainpython.o:luainpython.c:(.text+0x65): undefined reference to `lua_tolstring'

luainpython.o:luainpython.c:(.text+0x7a): undefined reference to `lua_objlen'
luainpython.o:luainpython.c:(.text+0x8f): undefined reference to `_imp__PyUnicod
eUCS2_FromStringAndSize'
luainpython.o:luainpython.c:(.text+0xab): undefined reference to `lua_tonumber'
luainpython.o:luainpython.c:(.text+0xf3): undefined reference to `_imp__PyFloat_
FromDouble'
luainpython.o:luainpython.c:(.text+0x114): undefined reference to `_imp__PyLong_
FromLong'
luainpython.o:luainpython.c:(.text+0x12d): undefined reference to `lua_toboolean
'
luainpython.o:luainpython.c:(.text+0x136): undefined reference to `_imp___Py_Tru
eStruct'
luainpython.o:luainpython.c:(.text+0x140): undefined reference to `_imp___Py_Tru
eStruct'
luainpython.o:luainpython.c:(.text+0x14a): undefined reference to `_imp___Py_Zer
oStruct'
luainpython.o:luainpython.c:(.text+0x154): undefined reference to `_imp___Py_Zer
oStruct'
luainpython.o:luainpython.c:(.text+0x16b): undefined reference to `luaPy_to_pobj
ect'
luainpython.o:luainpython.c:(.text+0x1c0): undefined reference to `_imp__PyExc_T
ypeError'
luainpython.o:luainpython.c:(.text+0x1d2): undefined reference to `_imp__PyErr_S
etString'
luainpython.o:luainpython.c:(.text+0x1e7): undefined reference to `lua_settop'
luainpython.o:luainpython.c:(.text+0x1fc): undefined reference to `_imp__PyTuple
_Size'
luainpython.o:luainpython.c:(.text+0x21f): undefined reference to `_imp__PyTuple
_GetItem'
luainpython.o:luainpython.c:(.text+0x22f): undefined reference to `_imp__PyExc_T
ypeError'
luainpython.o:luainpython.c:(.text+0x248): undefined reference to `_imp__PyErr_F
ormat'
luainpython.o:luainpython.c:(.text+0x25d): undefined reference to `lua_settop'
luainpython.o:luainpython.c:(.text+0x281): undefined reference to `py_convert'
luainpython.o:luainpython.c:(.text+0x28f): undefined reference to `_imp__PyExc_T
ypeError'
luainpython.o:luainpython.c:(.text+0x2a8): undefined reference to `_imp__PyErr_F
ormat'
luainpython.o:luainpython.c:(.text+0x2bd): undefined reference to `lua_settop'
luainpython.o:luainpython.c:(.text+0x2f8): undefined reference to `lua_pcall'
luainpython.o:luainpython.c:(.text+0x317): undefined reference to `lua_tolstring
'
luainpython.o:luainpython.c:(.text+0x31d): undefined reference to `_imp__PyExc_E
xception'
luainpython.o:luainpython.c:(.text+0x333): undefined reference to `_imp__PyErr_F
ormat'
luainpython.o:luainpython.c:(.text+0x34a): undefined reference to `lua_gettop'
luainpython.o:luainpython.c:(.text+0x378): undefined reference to `_imp__PyExc_T
ypeError'
luainpython.o:luainpython.c:(.text+0x38a): undefined reference to `_imp__PyErr_S
etString'
luainpython.o:luainpython.c:(.text+0x39f): undefined reference to `lua_settop'
luainpython.o:luainpython.c:(.text+0x3e5): undefined reference to `_imp__PyTuple
_New'
luainpython.o:luainpython.c:(.text+0x3f5): undefined reference to `_imp__PyExc_R
untimeError'
luainpython.o:luainpython.c:(.text+0x407): undefined reference to `_imp__PyErr_S
etString'
luainpython.o:luainpython.c:(.text+0x41c): undefined reference to `lua_settop'
luainpython.o:luainpython.c:(.text+0x453): undefined reference to `_imp__PyExc_T
ypeError'
luainpython.o:luainpython.c:(.text+0x46c): undefined reference to `_imp__PyErr_F
ormat'
luainpython.o:luainpython.c:(.text+0x481): undefined reference to `lua_settop'
luainpython.o:luainpython.c:(.text+0x4c8): undefined reference to `_imp__PyTuple
_SetItem'
luainpython.o:luainpython.c:(.text+0x4e0): undefined reference to `_imp___Py_Non
eStruct'
luainpython.o:luainpython.c:(.text+0x4ea): undefined reference to `_imp___Py_Non
eStruct'
luainpython.o:luainpython.c:(.text+0x4f1): undefined reference to `_imp___Py_Non
eStruct'
luainpython.o:luainpython.c:(.text+0x507): undefined reference to `lua_settop'
luainpython.o:luainpython.c:(.text+0x51e): undefined reference to `_imp___PyObje
ct_New'
luainpython.o:luainpython.c:(.text+0x53d): undefined reference to `lua_pushvalue
'
luainpython.o:luainpython.c:(.text+0x552): undefined reference to `luaL_ref'
luainpython.o:luainpython.c:(.text+0x58c): undefined reference to `luaL_unref'
luainpython.o:luainpython.c:(.text+0x5b5): undefined reference to `luaL_unref'
luainpython.o:luainpython.c:(.text+0x5f0): undefined reference to `lua_rawgeti'
luainpython.o:luainpython.c:(.text+0x605): undefined reference to `lua_type'
luainpython.o:luainpython.c:(.text+0x61e): undefined reference to `lua_settop'
luainpython.o:luainpython.c:(.text+0x623): undefined reference to `_imp__PyExc_R
untimeError'
luainpython.o:luainpython.c:(.text+0x635): undefined reference to `_imp__PyErr_S
etString'
luainpython.o:luainpython.c:(.text+0x656): undefined reference to `lua_isstring'

luainpython.o:luainpython.c:(.text+0x66f): undefined reference to `lua_type'
luainpython.o:luainpython.c:(.text+0x689): undefined reference to `lua_isuserdat
a'
luainpython.o:luainpython.c:(.text+0x6a2): undefined reference to `lua_settop'
luainpython.o:luainpython.c:(.text+0x6a7): undefined reference to `_imp__PyExc_R
untimeError'
luainpython.o:luainpython.c:(.text+0x6b9): undefined reference to `_imp__PyErr_S
etString'
luainpython.o:luainpython.c:(.text+0x6e8): undefined reference to `py_convert'
luainpython.o:luainpython.c:(.text+0x706): undefined reference to `lua_gettable'

luainpython.o:luainpython.c:(.text+0x725): undefined reference to `_imp__PyExc_V
alueError'
luainpython.o:luainpython.c:(.text+0x737): undefined reference to `_imp__PyErr_S
etString'
luainpython.o:luainpython.c:(.text+0x74e): undefined reference to `lua_settop'
luainpython.o:luainpython.c:(.text+0x77f): undefined reference to `lua_rawgeti'
luainpython.o:luainpython.c:(.text+0x794): undefined reference to `lua_type'
luainpython.o:luainpython.c:(.text+0x7ad): undefined reference to `lua_settop'
luainpython.o:luainpython.c:(.text+0x7b2): undefined reference to `_imp__PyExc_R
untimeError'
luainpython.o:luainpython.c:(.text+0x7c4): undefined reference to `_imp__PyErr_S
etString'
luainpython.o:luainpython.c:(.text+0x7e5): undefined reference to `lua_type'
luainpython.o:luainpython.c:(.text+0x7ff): undefined reference to `lua_settop'
luainpython.o:luainpython.c:(.text+0x804): undefined reference to `_imp__PyExc_T
ypeError'
luainpython.o:luainpython.c:(.text+0x816): undefined reference to `_imp__PyErr_S
etString'
luainpython.o:luainpython.c:(.text+0x83e): undefined reference to `py_convert'
luainpython.o:luainpython.c:(.text+0x85a): undefined reference to `lua_pushnil'
luainpython.o:luainpython.c:(.text+0x87f): undefined reference to `py_convert'
luainpython.o:luainpython.c:(.text+0x89d): undefined reference to `lua_settable'

luainpython.o:luainpython.c:(.text+0x8ab): undefined reference to `_imp__PyExc_V
alueError'
luainpython.o:luainpython.c:(.text+0x8bd): undefined reference to `_imp__PyErr_S
etString'
luainpython.o:luainpython.c:(.text+0x8c6): undefined reference to `_imp__PyExc_V
alueError'
luainpython.o:luainpython.c:(.text+0x8d8): undefined reference to `_imp__PyErr_S
etString'
luainpython.o:luainpython.c:(.text+0x8ef): undefined reference to `lua_settop'
luainpython.o:luainpython.c:(.text+0x921): undefined reference to `lua_rawgeti'
luainpython.o:luainpython.c:(.text+0x93e): undefined reference to `luaL_callmeta
'
luainpython.o:luainpython.c:(.text+0x95f): undefined reference to `lua_tolstring
'
luainpython.o:luainpython.c:(.text+0x977): undefined reference to `lua_settop'
luainpython.o:luainpython.c:(.text+0x988): undefined reference to `_imp__PyUnico
deUCS2_FromString'
luainpython.o:luainpython.c:(.text+0x9ac): undefined reference to `lua_type'
luainpython.o:luainpython.c:(.text+0x9dd): undefined reference to `lua_topointer
'
luainpython.o:luainpython.c:(.text+0x9f3): undefined reference to `lua_typename'

luainpython.o:luainpython.c:(.text+0xa07): undefined reference to `_imp__PyUnico
deUCS2_FromFormat'
luainpython.o:luainpython.c:(.text+0xa26): undefined reference to `lua_touserdat
a'
luainpython.o:luainpython.c:(.text+0xa3c): undefined reference to `lua_typename'

luainpython.o:luainpython.c:(.text+0xa50): undefined reference to `_imp__PyUnico
deUCS2_FromFormat'
luainpython.o:luainpython.c:(.text+0xa6c): undefined reference to `lua_tothread'

luainpython.o:luainpython.c:(.text+0xa82): undefined reference to `lua_typename'

luainpython.o:luainpython.c:(.text+0xa96): undefined reference to `_imp__PyUnico
deUCS2_FromFormat'
luainpython.o:luainpython.c:(.text+0xab1): undefined reference to `lua_typename'

luainpython.o:luainpython.c:(.text+0xac1): undefined reference to `_imp__PyUnico
deUCS2_FromFormat'
luainpython.o:luainpython.c:(.text+0xadc): undefined reference to `lua_settop'
luainpython.o:luainpython.c:(.text+0xb00): undefined reference to `lua_settop'
luainpython.o:luainpython.c:(.text+0xb1f): undefined reference to `lua_rawgeti'
luainpython.o:luainpython.c:(.text+0xb61): undefined reference to `lua_rawgeti'
luainpython.o:luainpython.c:(.text+0xb78): undefined reference to `lua_pushnil'
luainpython.o:luainpython.c:(.text+0xb99): undefined reference to `lua_rawgeti'
luainpython.o:luainpython.c:(.text+0xbae): undefined reference to `lua_next'
luainpython.o:luainpython.c:(.text+0xbc7): undefined reference to `lua_settop'
luainpython.o:luainpython.c:(.text+0xbfe): undefined reference to `luaL_ref'
luainpython.o:luainpython.c:(.text+0xc25): undefined reference to `lua_rawseti'
luainpython.o:luainpython.c:(.text+0xc50): undefined reference to `luaL_unref'
luainpython.o:luainpython.c:(.text+0xc84): undefined reference to `lua_rawgeti'
luainpython.o:luainpython.c:(.text+0xc99): undefined reference to `lua_objlen'
luainpython.o:luainpython.c:(.text+0xcb1): undefined reference to `lua_settop'
luainpython.o:luainpython.c:(.text+0xd1f): undefined reference to `_imp__PyArg_P
arseTuple'
luainpython.o:luainpython.c:(.text+0xda5): undefined reference to `luaL_loadbuff
er'
luainpython.o:luainpython.c:(.text+0xdc6): undefined reference to `lua_tolstring
'
luainpython.o:luainpython.c:(.text+0xdcc): undefined reference to `_imp__PyExc_R
untimeError'
luainpython.o:luainpython.c:(.text+0xde2): undefined reference to `_imp__PyErr_F
ormat'
luainpython.o:luainpython.c:(.text+0xe1e): undefined reference to `lua_pcall'
luainpython.o:luainpython.c:(.text+0xe3f): undefined reference to `lua_tolstring
'
luainpython.o:luainpython.c:(.text+0xe45): undefined reference to `_imp__PyExc_R
untimeError'
luainpython.o:luainpython.c:(.text+0xe5b): undefined reference to `_imp__PyErr_F
ormat'
luainpython.o:luainpython.c:(.text+0xe91): undefined reference to `lua_settop'
luainpython.o:luainpython.c:(.text+0xef6): undefined reference to `lua_getfield'

luainpython.o:luainpython.c:(.text+0xf0b): undefined reference to `lua_type'
luainpython.o:luainpython.c:(.text+0xf14): undefined reference to `_imp__PyExc_R
untimeError'
luainpython.o:luainpython.c:(.text+0xf26): undefined reference to `_imp__PyErr_S
etString'
luainpython.o:luainpython.c:(.text+0xf3d): undefined reference to `lua_settop'
luainpython.o:luainpython.c:(.text+0xf67): undefined reference to `_imp__PyExc_T
ypeError'
luainpython.o:luainpython.c:(.text+0xf79): undefined reference to `_imp__PyErr_F
ormat'
luainpython.o:luainpython.c:(.text+0xf90): undefined reference to `lua_settop'
luainpython.o:luainpython.c:(.text+0xfb8): undefined reference to `lua_getfield'

luainpython.o:luainpython.c:(.text+0xfcd): undefined reference to `lua_type'
luainpython.o:luainpython.c:(.text+0xfe6): undefined reference to `lua_settop'
luainpython.o:luainpython.c:(.text+0xfeb): undefined reference to `_imp__PyExc_R
untimeError'
luainpython.o:luainpython.c:(.text+0xffd): undefined reference to `_imp__PyErr_S
etString'
luainpython.o:luainpython.c:(.text+0x102e): undefined reference to `_imp__PyType
_Ready'
luainpython.o:luainpython.c:(.text+0x1064): undefined reference to `_imp__Py_Ini
tModule4'
luainpython.o:luainpython.c:(.text+0x1087): undefined reference to `luaL_newstat
e'
luainpython.o:luainpython.c:(.text+0x1099): undefined reference to `luaL_openlib
s'
luainpython.o:luainpython.c:(.text+0x10a6): undefined reference to `luaopen_pyth
on'
luainpython.o:luainpython.c:(.text+0x10bb): undefined reference to `lua_settop'
luainpython.o:luainpython.c:(.data+0x8c): undefined reference to `PyObject_SelfI
ter'
luainpython.o:luainpython.c:(.data+0xb8): undefined reference to `PyType_Generic
Alloc'
luainpython.o:luainpython.c:(.data+0xbc): undefined reference to `PyType_Generic
New'
luainpython.o:luainpython.c:(.data+0xc0): undefined reference to `PyObject_Free'

c:/mingw/bin/../lib/gcc/mingw32/4.6.2/../../../libmingw32.a(main.o): In function
 `main':
C:\MinGW\msys\1.0\src\mingwrt/../mingw/main.c:73: undefined reference to `WinMai
n@16'
collect2: ld returned 1 exit status

抱歉,我找不到办法让它变小。

无论如何,我还安装了make,尝试运行python文件,就像它应该完成的那样,并且两者都有同样的错误:

python setup.py build
Traceback (most recent call last):
  File "setup.py", line 47, in <module>
    lua_pkgconfig = pkgconfig('lua', 'lua' + LUAVERSION)
  File "setup.py", line 32, in pkgconfig
    "pkg-config --libs --cflags %s" % package
  File "C:\Python27\lib\subprocess.py", line 537, in check_output
    process = Popen(stdout=PIPE, *popenargs, **kwargs)
  File "C:\Python27\lib\subprocess.py", line 679, in __init__
    errread, errwrite)
  File "C:\Python27\lib\subprocess.py", line 893, in _execute_child
    startupinfo)
WindowsError: [Error 2] The system cannot find the file specified

我知道我有点模糊,这是因为我是新手,所以我不知道要提供什么信息。请告诉我你需要知道的事情。

提前致谢。

〜小型

1 个答案:

答案 0 :(得分:1)

我假设你正在使用bastibe/lunatic-python和Python 2。

commands中使用的

setup.py包仅限unix。您看到的错误是由以下代码引起的:http://hg.python.org/cpython/file/3a1db0d2747e/Lib/commands.py#l59

有必要在setup.py ..:

中替换以下部分
# ..
for package in packages:
    (pcstatus, pcoutput) = commands.getstatusoutput(
        "pkg-config --libs --cflags %s" % package)
    if pcstatus == 0:
        break
else:
    sys.exit("pkg-config failed for %s; "
             "most recent output was:\n%s" %
             (", ".join(packages), pcoutput))
# ..

..使用等效的subprocess代码:

# ..
import subprocess
pcoutput = ""
for package in packages:
    # raises exception if:
    # - pkg-config is not found 
    # - pkg-config returns some error
    pcoutput += subprocess.check_output(
        "pkg-config --libs --cflags %s" % package
    )
# ..

现在错误消息应该变得更加清晰。


(已添加#1)

上面的代码尝试运行pkg-config命令,结果发现由于某种原因它失败了。如果打开MSYS shell(通常位于C:\MinGW\msys\1.0\msys.bat并运行pkg-config命令,则预期输出如下:

$ pkg-config --libs --cflags lua
-IC:/MinGW/msys/1.0/include -LC:/MinGW/msys/1.0/lib -llua -lm

文章"gcc -L / -l option flags""Using pkg-config files"可能有助于解读上述命令。


(已添加#2)

要使msys shell可用,必须安装MinGW并选择msys-base个包。关于如何安装MinGW的好教程:Installing Minimum GNU for Windows (MinGW)

pkg-config必须单独安装。请查看MinGW FAQ和Ctrl + F,了解“如何安装pkg-config?”。

简而言之,您必须下载pkg-config-lite并将zip文件内容解压缩到C:\MinGW\msys\1.0

来自msys shell:

wget http://garr.dl.sourceforge.net/project/pkgconfiglite/0.28-1/pkg-config-lite-0.28-1_bin-win32.zip
unzip pkg-config-lite-0.28-1_bin-win32.zip
cp -R pkg-config-lite-0.28-1/* /usr

然后创建pkgconfig目录:

mkdir /usr/lib/pkgconfig

验证pkg-config是否正常工作(以及查看尝试查找配置文件的位置)

pkg-config --debug

并验证您是否已安装所有必需的依赖项:

$ which gcc g++ wget tar make unzip
/usr/bin/gcc.exe
/usr/bin/g++.exe
/usr/bin/wget.exe
/usr/bin/tar.exe
/usr/bin/make.exe
/usr/bin/unzip.exe

最有可能的是lua必须从源代码构建:

wget http://www.lua.org/ftp/lua-5.2.3.tar.gz
tar -xf lua-5.2.3.tar.gz
cd lua-5.2.3
make mingw
make INSTALL_TOP=/usr install

现在您必须手动创建/usr/lib/pkgconfig/lua.pc。或者使用Linux From Scratch页面上的一个:http://www.linuxfromscratch.org/blfs/view/svn/general/lua.html


现在pkg-config应该如上所述。