私はVS2015をLua5.1のC++アプリケーションで使用しています。私は問題なしで非常に単純なLuaスクリプトを実行しています。raw luaはうまく動作します。しかし、私がluaモジュール "socket.http"をインポートしようとすると、私のアプリケーションはモジュールを見つけることができないと思うので、それは好きではありません。C++から呼び出されたスクリプトでLuaモジュールが必要です
私の質問は、私のluaスクリプト(C++から実行される)がsocket.httpのようなluaモジュールにアクセスすることを許可するにはどうすればよいですか?あなたが持っていた場合
マイproject.cpp
#include "stdafx.h"
#include <iostream>
extern "C"
{
#include <../dependancies/lua51/include/lua.h>
#include <../dependancies/lua51/include/lauxlib.h>
#include <../dependancies/lua51/include/lualib.h>
}
void report_errors(lua_State *L, int status)
{
if (status != 0)
{
printf("-- %s\n", lua_tostring(L, -1));
lua_pop(L, 1); // remove error message
}
}
int main()
{
// create a Lua state
lua_State* L = luaL_newstate();
// load standard libs
luaL_openlibs(L);
int lscript = luaL_dofile(L, "test1.lua");
report_errors(L, lscript);
system("PAUSE");
return 0;
}
test1.lua
local http = require("socket.http")
エラー
モジュールのmodule 'socket.http' not found:
no field package.preload['socket.http']
no file '.\socket\http.lua'
no file 'C:\Users\georg\Desktop\git\ARGO\Game\ATracknophilia\Debug\lua\socket\http.lua'
no file 'C:\Users\georg\Desktop\git\ARGO\Game\ATracknophilia\Debug\lua\socket\http\init.lua'
no file 'C:\Users\georg\Desktop\git\ARGO\Game\ATracknophilia\Debug\socket\http.lua'
no file 'C:\Users\georg\Desktop\git\ARGO\Game\ATracknophilia\Debug\socket\http\init.lua'
no file 'C:\Program Files (x86)\Lua\5.1\lua\socket\http.luac'
no file '.\socket\http.dll'
no file '.\socket\http51.dll'
no file 'C:\Users\georg\Desktop\git\ARGO\Game\ATracknophilia\Debug\socket\http.dll'
no file 'C:\Users\georg\Desktop\git\ARGO\Game\ATracknophilia\Debug\socket\http51.dll'
no file 'C:\Users\georg\Desktop\git\ARGO\Game\ATracknophilia\Debug\clibs\socket\http.dll'
no file 'C:\Users\georg\Desktop\git\ARGO\Game\ATracknophilia\Debug\clibs\socket\http51.dll'
no file 'C:\Users\georg\Desktop\git\ARGO\Game\ATracknophilia\Debug\loadall.dll'
no file 'C:\Users\georg\Desktop\git\ARGO\Game\ATracknophilia\Debug\clibs\loadall.dll'
no file '.\socket.dll'
no file '.\socket51.dll'
no file 'C:\Users\georg\Desktop\git\ARGO\Game\ATracknophilia\Debug\socket.dll'
no file 'C:\Users\georg\Desktop\git\ARGO\Game\ATracknophilia\Debug\socket51.dll'
no file 'C:\Users\georg\Desktop\git\ARGO\Game\ATracknophilia\Debug\clibs\socket.dll'
no file 'C:\Users\georg\Desktop\git\ARGO\Game\ATracknophilia\Debug\clibs\socket51.dll'
no file 'C:\Users\georg\Desktop\git\ARGO\Game\ATracknophilia\Debug\loadall.dll'
no file 'C:\Users\georg\Desktop\git\ARGO\Game\ATracknophilia\Debug\clibs\loadall.dll'
'socket.http'はネイティブのLuaモジュールではありません。 – bew