Jump to content
  • Advertisement
Sign in to follow this  

Runtime error on my first Luabind program [SOLVED]

This topic is 4129 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I just compiled my first Luabind program. I downloaded the compiled ibrary from http://www.nuclex.org/downloads/developers/kits/luabind-binaries-and-demo and wrote the following code:
extern "C"
#include <lua.h>
#include <lualib.h>
#include <lauxlib.h>

#pragma comment(lib, "lua.msvc8.lib")
#pragma comment(lib, "luabind.msvc8.lib")

#include <luabind/luabind.hpp>
#include <iostream>
#include <string>

using namespace std;
using namespace luabind;

// The C++ functions we are going to expose in lua
void HelloWorld()
	cout << "Geia mas" << endl;

int add(int a, int b)
	return a+b;

int main()
	// Create a lua state
	lua_State *pL = lua_open();

	// open luanbind
	// Register C++ functions and classes using luabing HERE 
	// Register them in globalspace
		luabind::def("HelloWorld", HelloWorld) 

	// Load and run the script here
	// Process a file
	if(int error = luaL_dofile(pL, "test.lua") != 0)
		cout << "Error with lua file" << endl;

	// tidy up

	return 0;
Program compiles fine but throws a runtime error when I register the HelloWorld() function. Any idea what might it be wrong? Thanks. [Edited by - mits on June 7, 2007 6:20:41 AM]

Share this post

Link to post
Share on other sites
Nevermind, I solved it by changing the Runtime Library option of the compiler to Multithreaded DLL and the project configuration to Release and it worked perfectly. Thanks.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!