Reply to this subject
Start a new subject
 
Refresh page
| Posted by |
ThomasWatts
USA (66 posts) bio
|
| Date |
Wed 26 Dec 2007 01:52 AM (UTC) [ quote
] Amended on Wed 26 Dec 2007 01:53 AM (UTC) by ThomasWatts
|
| Message |
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 | top |
|
| Posted by |
Nick Gammon
Australia (18,797 posts) bio
Forum Administrator |
| Date |
Reply #1 on Wed 26 Dec 2007 02:34 AM (UTC) [ quote
] |
| Message |
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
}
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | top |
|
| Posted by |
ThomasWatts
USA (66 posts) bio
|
| Date |
Reply #2 on Thu 27 Dec 2007 04:10 AM (UTC) [ quote
] |
| Message |
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. | top |
|
| Posted by |
Nick Gammon
Australia (18,797 posts) bio
Forum Administrator |
| Date |
Reply #3 on Thu 27 Dec 2007 05:27 AM (UTC) [ quote
] |
| Message |
| Yes, exactly, and when you use ' extern "c" ' it tells the linker that this particular DLL does not have mangled names. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
2,441 views.
Reply to this subject
Start a new subject
 
Refresh page
top
Comments to:
Gammon Software support
Forum RSS feed ( http://www.gammon.com.au/rss/forum.xml )