C++与lua

main.cpp 

#include 
#include "lua.hpp"
#include 
#include 
#include 

using namespace std;

int main()
{
	
	lua_State* pLua = luaL_newstate();

	luaL_openlibs(pLua);

	char szTmp[512];
	snprintf(szTmp, sizeof(szTmp), "package.path=package.path..';./?.lua;./?.luac'\0");
	if (luaL_dostring(pLua, szTmp) != 0)
	{
		
	}

	if (luaL_dostring(pLua, "require 'init'") != 0)
	{
		
	}

	lua_close(pLua);

	return 0;
}

init.lua

print ("Hello World!");

 

你可能感兴趣的:(C/C++,基础,lua)