Question

I am neck-deep in errors coming from multiple compilers I have tried, when attempting to build lunatic-python. Mingw is the compiler I have gotten the farthest in, and currently I am getting a block of spam containing

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

Sorry, I couldn't find a way to make that smaller.

Anyway, I have also installed make, tried running the python file like it was supposed to be done, and have gotten the same error with both:

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

I know I am being a bit vague, it's because I'm new to this, so I don't know what information to supply. Please let me know what you need to know.

Thanks in advance.

~Junior

Was it helpful?

Solution

I assume, that you are using bastibe/lunatic-python and Python 2.

commands package used in setup.py is unix-only. Error that you see is caused by following code: http://hg.python.org/cpython/file/3a1db0d2747e/Lib/commands.py#l59

It is necessary to replace following part in 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))
# ..

.. with equivalent subprocess code:

# ..
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
    )
# ..

Now error messages should become clearer.


(Added #1)

The code above tries to run pkg-config command and it turns out that for some reason it fails. If you open MSYS shell (usually located at C:\MinGW\msys\1.0\msys.bat and run pkg-config command, then the expected output is following:

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

Articles "gcc -L / -l option flags" and "Using pkg-config files" may help to decipher command above.


(Added #2)

To have msys shell available, MinGW has to installed with msys-base package selected. Good tutorial on how to install MinGW: Installing Minimum GNU for Windows (MinGW)

pkg-config has to installed separately. Take look at MinGW FAQ and Ctrl+F for "How do I get pkg-config installed?".

In short you have to download pkg-config-lite and extract zip file contents to C:\MinGW\msys\1.0.

From 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

And then create pkgconfig directory:

mkdir /usr/lib/pkgconfig

To verify that pkg-config is working (and to see where is tries to find config files):

pkg-config --debug

And to verify that you have all necessary dependencies installed:

$ 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

Most likely lua has to be build from source:

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

Now you'll have to manually create /usr/lib/pkgconfig/lua.pc. Or use one found on Linux From Scratch page: http://www.linuxfromscratch.org/blfs/view/svn/general/lua.html


Now pkg-config should work as described above.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top