Compile me crazy

Posted by ThomasWatts on Wed 26 Dec 2007 01:52 AM — 4 posts, 18,239 views.

USA #0
My problem is the following:
I compile Lua with g++ and I must compile SMAUG with g++ as well.
If I compile Lua with gcc, then I have to use gcc with SMAUG.
Zlib on the other hand can only compile with gcc, but links fine either way.
If I try to compile Lua with g++ and SMAUG with gcc I get undefined reference errors to lua functions, ie. lua_pushnil.

Does anyone else have this problem? Is this just a very minor concern and I'm being obsessive?

Also, Merry Christmas those in the USA
Amended on Wed 26 Dec 2007 01:53 AM by ThomasWatts
Australia Forum Administrator #1
When you include the Lua .h files you have to put extern around them like this:


extern "C" {
  #include "lua.h"
// and any other Lua files
  }
USA #2
Just to reply to this, I was originally perplexed as to why C++ code could call external(dll) C code, but not the other way around.
C++ mangles function names to allow for templates which C code does not understand.
I just decided to compile both in C++ which works fine.
Australia Forum Administrator #3
Yes, exactly, and when you use ' extern "c" ' it tells the linker that this particular DLL does not have mangled names.