• Advertisement
Sign in to follow this  

Unresolved external....

This topic is 4466 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

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...
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];
	// Register Stuff
	int r;

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

	// Compile Script
	asIScriptContext *ctx = engine->CreateContext();

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


	return 0;

void PrintString(string &str)
	cout << str;

Share this post

Link to post
Share on other sites
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.

Share this post

Link to post
Share on other sites
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

Share this post

Link to post
Share on other sites
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?

Share this post

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

  • Advertisement