lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

Brian Hook wrote:

>> and found the solution of wrapping the headers in extern "C" {...}.
> You need to wrap the headers when included by all the .c files as way.
>  The easiest thing to do is put the extern "C" in lua.h itself.

A still more clean way to do this is to use some kind of home lua header
file, like the following one and link to it through all your application
instead of using lua.h directly :

#ifndef MY_LUA_H
#define MY_LUA_H

extern "C" {
        #include "lua.h"

#endif /* MY_LUA_H */

If it still doesn't work then the brute force solution provided by Brian
Hook above is the only one.

The fact is that the headers you generate or use CANNOT link to lua.h
directly. If you use third party library then this may happen without you
knowing it !

The reason to use the clean way is to be able to update the lua library in
the easiest way possible as we are humans and make mistakes : you will
probably forget to reinsert the guardians in lua.h when updating it
locally. If you project is open source then it is one more reason to do it
in a clean way !

>> unresolved external symbol "struct lua_State * __cdecl
>> lua_open(void)" (?lua_open@@YAPAUlua_State@@XZ)
> This indicates that something is still trying to link against it in
> C++ form.
> Brian