Advertisement

Unresolved external....

Started by December 29, 2005 04:47 PM
2 comments, last by WitchLord 18 years, 11 months ago
I decided to try and write some quick and dirty code to see if I could get AS working. Well, I got the engine initilized and loaded the script, but when I go to RegisterScriptString I get an error...
Quote: Main.obj : error LNK2001: unresolved external symbol "void __cdecl RegisterScriptString(class asIScriptEngine *)" (?RegisterScriptString@@YAXPAVasIScriptEngine@@@Z) Debug/AngelScript_Test.exe : fatal error LNK1120: 1 unresolved externals Error executing link.exe. AngelScript_Test.exe - 2 error(s), 0 warning(s)
my code...

#include <iostream>
#include <assert.h>
#include <conio.h>
#include <stdio.h>
#include <angelscript.h>
#include <scriptstring.h>

using namespace std;

// Prototypes
void PrintString(string &str);

int main(int argc, char **argv)
{
	asIScriptEngine *engine = asCreateScriptEngine(ANGELSCRIPT_VERSION);
	if(engine == 0)
		cout << "Faild to creat Scripting Engine";

	engine->SetCommonMessageStream((asOUTPUTFUNC_t)printf, 0);

	// Load Script
	FILE *f = fopen("test.as", "rb");
	//int length = _filelength(f);
	char *script = new char[255];
	fread(script,255,1,f);
	fclose(f);
	// Register Stuff
	int r;

	RegisterScriptString(engine);
	
	r = engine->RegisterGlobalFunction("void Print(string ∈)", asFUNCTION(PrintString), asCALL_CDECL); assert( r >= 0);


	// Compile Script
	engine->AddScriptSection("module","section",script,255);
	engine->Build("module");
	
	asIScriptContext *ctx = engine->CreateContext();

	int funcId = engine->GetFunctionIDByDecl(0,"void init()");
	int a = ctx->Prepare(funcId);
	
	cout << "Executing Script\n------\n";

	ctx->Execute();

	ctx->Release();
	engine->Release();
	system("pause");
	return 0;
}

void PrintString(string &str)
{
	cout << str;
}
Blupix Games
You have to include the cpp file associated with script string in your project. It's an addon, not a part of the core library, so it is not compiled into the .lib.
Advertisement
ok I did that. Now it compiles fine, but I get this error when running the program...

Assertion failed: r >= 0, file c:\angelscript\sdk\add_on\scriptstring\scriptstring.cpp, line 318
Blupix Games
A couple of background questions first:

- What version of AngelScript are you using?
- What compiler are you using?

The assert fails because for some reason the call to register the ScriptString's constructor failed. What is the value of r when the assert fails?

This is probably not a coding error, but rather a configuration problem. Did you define any of the preprocessor flags in as_config.h to alter the default behaviour of AngelScript?





AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

This topic is closed to new replies.

Advertisement