lua-users home
lua-l archive

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


>>As a precis, I add the following to lua.h for the basic library:

>>#ifdef _WIN32
>>#define EXPORT __declspec(dllexport)
>>#else
>>#define EXPORT
>>#endif

> A few weeks ago, I downloaded Lua 3.1. Built a dll project using MSVC++
> 4.2 dll wizard, and included all the *.c files in the offical release,
> defined EXPORT as exactly what you did. No changes on any *.c file.
> Everything just works fine. Lua is great. 

One caveat: when using the DLLs and headers there is a slight modification 
needed to the above otherwise some things just don't quite work.  
(Specifically, some exported variables don't work out.)

The modifications are:

#ifdef _WIN32
 #ifdef DLL
  #define EXPORT __declspec(dllexport)	/* building DLL, exported */ 
 #else  
  #define EXPORT __declspec(dllimport)	/* using DLL, imported */ 
 #endif 
#else 
 #define EXPORT
#endif

If you don't do this, some things won't compile if you include debug 
support.  If you do this, you need to #define DLL (either in source or on 
the command line) when building the DLL(s) and make sure it is undefined 
when using the DLLs.
-- 
Michael T. Richter    <mtr@ottawa.com>    http://www.igs.net/~mtr/
          PGP Key: http://www.igs.net/~mtr/pgp-key.html
PGP Fingerprint: 40D1 33E0 F70B 6BB5 8353 4669 B4CC DD09 04ED 4FE8