Linking Octave to Windows DLLs
- Sample DLL source to link to octave
// FILE: d_vcc.cpp
#include <windows.h>
extern "C" {
BOOL WINAPI DllMain( HINSTANCE, DWORD, LPVOID ) { return 1;}
int __declspec(dllexport)
msgbox_plus_one( const char * text ){
return MessageBox( NULL, text, "TITLE",
MB_ABORTRETRYIGNORE | MB_SETFOREGROUND) + 1;
}
}
- Compile with MSVC++ (or using your IDE) cl -nologo -LD d_vcc.cpp user32.lib
- Now, create a file d_gcc.cc which links to this function
// FILE: d_gcc.cc
#include <octave/oct.h>
extern "C" {
int msgbox_plus_one( const char * text );
}
DEFUN_DLD (d_gcc,args, , "usage d_gcc('string')" ) {
octave_value_list retval;
retval(0) = (double) msgbox_plus_one( args(0).string_value().c_str() );
return retval;
}
- Compile this file to an *oct file using LFLAGS="`mkoctfile -p LFLAGS` d_vcc.dll" mkoctfile -v d_gcc.cc
- Voila, now call d_gcc("string") from octave
CategoryExternal