• Advertisement
Sign in to follow this  

Why is Lua messing up my linkage to the CRT libraries

This topic is 4233 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Here is my simple C++ program:
#include "lua.hpp"

int main(int argc, char** argv)
{
    using namespace std;
    
    lua_State* VM = lua_open();
}



Here are my errors:
C:/Dev-Cpp/lib/liblua5.1.a(lauxlib.o)(.text+0x12a4):lauxlib.c: undefined reference to `__errno'

C:/Dev-Cpp/lib/liblua5.1.a(lauxlib.o)(.text+0x13e8):lauxlib.c: undefined reference to `__getreent'
C:/Dev-Cpp/lib/liblua5.1.a(lauxlib.o)(.text+0x14b8):lauxlib.c: undefined reference to `__getreent'
C:/Dev-Cpp/lib/liblua5.1.a(lauxlib.o)(.text+0x151e):lauxlib.c: undefined reference to `__getreent'
C:/Dev-Cpp/lib/liblua5.1.a(lauxlib.o)(.text+0x1654):lauxlib.c: undefined reference to `__getreent'
C:/Dev-Cpp/lib/liblua5.1.a(lobject.o)(.text+0x13a):lobject.c: undefined reference to `_imp___ctype_'
C:/Dev-Cpp/lib/liblua5.1.a(ldo.o)(.text+0xdf):ldo.c: undefined reference to `setjmp'
C:/Dev-Cpp/lib/liblua5.1.a(llex.o)(.text+0x65):llex.c: undefined reference to `_imp___ctype_'
C:/Dev-Cpp/lib/liblua5.1.a(llex.o)(.text+0x4f5):llex.c: undefined reference to `_imp___ctype_'
C:/Dev-Cpp/lib/liblua5.1.a(llex.o)(.text+0x51c):llex.c: undefined reference to `_imp___ctype_'
C:/Dev-Cpp/lib/liblua5.1.a(llex.o)(.text+0x555):llex.c: undefined reference to `_imp___ctype_'
C:/Dev-Cpp/lib/liblua5.1.a(llex.o)(.text+0x961):llex.c: undefined reference to `_imp___ctype_'
C:/Dev-Cpp/lib/liblua5.1.a(llex.o)(.text+0xb5b):llex.c: more undefined references to `_imp___ctype_' follow


It's like the C runtimes aren't being linked or something. Can anyone help? PS: (It works normally, but when I include lua it gives the above errors)

Share this post


Link to post
Share on other sites
Advertisement
I don't know about lua.hpp, but lua.h needs to wrapped in an extern "C" block when you include it in a C++ spurce file, like so:

extern "C" {
#include <lua.h>
}
Are those linker errors? I know nothing about Dev-Cpp...

Share this post


Link to post
Share on other sites
It is wrapped, that's what lua.hpp does. It's just that block of code.

Yes, those are linker errors. Undefined reference ones which means that the library isn't being included at all.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
It looks like you haven't included a library in the linker. You can set that in your project options.

Share this post


Link to post
Share on other sites
I told it to link the standard library. I have no idea why including lua.hpp causes it to not work.

Share this post


Link to post
Share on other sites
Crap. I found the problem, I was using the gcc version of the Lua library instead of the MinGw version. It compiles now. I feel really dumb [grin].

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement