lua-users home
lua-l archive

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

I did a try with Visual C++ (express edition, the one you get for free on microsoft website)

Here is my compilation on command line:

set incpath=%vcinstalldir%\include
set libpath=%vcinstalldir%\lib
cl foo.cpp -c /I%incpath%\lua
link -dll foo.obj lua51.lib

And i get "foo.dll", of course.
When i try require "foo" in lua, i still get :

> require "foo"
error loading module 'foo' from file '.\foo.dll':
        La procÚdure spécifiée est introuvable.

(same as my previous try with g++)

Here is the source-file.
Are there any windows user who could help me, and explain how to compile it, whatever toolchain you use (Visual C, mingw ...).
Thank you!

I rewrite the source file, now it's very simple. It still works without problems in Linux.

extern "C" {
#include <stdio.h>
#include <lua.h>
#include <lualib.h>
#include <lauxlib.h>

static int lua_print(lua_State*);
int luaopen_libfoo(lua_State*);

static int lua_print(lua_State *L)
   printf ("called: lua_print\n");
   return 0;

static const struct luaL_Reg foo_fx [] = {
  { "print", lua_print },
  { NULL, NULL } //dernier element obligatoire

int luaopen_libfoo(lua_State *L)
  luaL_register (L, "foo", foo_fx);
  return 1;