Hi Alan, someone else recently pointed out the same thing to me; the next release of NLopt will use the stdcall interface on Windows, which seems to be more common on Windows.

MinGW uses the same Makefile and configure script as is used on Unix. I posted a link on the web site to the shell script that I use (under GNU/Linux) to cross-compile the Windows DLL via MinGW in case it is helpful:

        http://ab-initio.mit.edu/nlopt/BUILD-MINGW.sh

To compile with the stdcall convention under Windows, you'll want to change the nlopt.h header file to replace the NLOPT_EXTERN definition with:

/* use stdcall convention under Windows, since this seems to
   be more standard there and is important for calling from .NET */
#if defined(_WIN32) || defined(__WIN32__)
#  if defined(__GNUC__)
#    define NLOPT_STDCALL __attribute__((stdcall))
# elif defined(_MSC_VER) || defined(_ICC) || defined(_STDCALL_SUPPORTED)
#    define NLOPT_STDCALL __stdcall
#  else
#    define NLOPT_STDCALL
#  endif
#else
#  define NLOPT_STDCALL
#endif

/* for Windows compilers, you should add a line
           #define NLOPT_DLL
   when using NLopt from a DLL, in order to do the proper
   Windows importing nonsense. */
#if defined(NLOPT_DLL) && (defined(_WIN32) || defined(__WIN32__))
/* annoying Windows syntax for calling functions in a DLL */
#  define NLOPT_EXTERN extern __declspec(dllimport) NLOPT_STDCALL
#else
#  define NLOPT_EXTERN extern NLOPT_STDCALL
#endif


Steven

_______________________________________________
NLopt-discuss mailing list
[email protected]
http://ab-initio.mit.edu/cgi-bin/mailman/listinfo/nlopt-discuss

Reply via email to