Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


- - - - -

Using AngelScript namespace causes linker error (VC11)


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 thewavelength   Members   -  Reputation: 109

Like
0Likes
Like

Posted 21 September 2012 - 09:14 AM

Hello,

I'm using Visual Studio 2012 and MSVC11 and get linker errors when using RegisterStdString function from the string addon when I enable namespaces.
I don't know if this is also the case for older compiler versions.

Fails with two linker errors (RegisterStdString and RegisterStdStringUtils):
[source lang="cpp"]#define AS_USE_NAMESPACE#include <angelscript.h>#include <add_on/scriptstdstring/scriptstdstring.h>using namespace AngelScript;void test(){ asIScriptEngine *engine = asCreateScriptEngine(ANGELSCRIPT_VERSION); RegisterStdString(engine); RegisterStdStringUtils(engine);}[/source]

Compiles like a charm:
[source lang="cpp"]#include <angelscript.h>#include <add_on/scriptstdstring/scriptstdstring.h>void test(){ asIScriptEngine *engine = asCreateScriptEngine(ANGELSCRIPT_VERSION); RegisterStdString(engine); RegisterStdStringUtils(engine);}[/source]
Is this a bug or am I doing something wrong?
Thanks in advance!

Edit: The forum removes include paths for some reason.
These are the files included:

<angelscript.h>
<add_on/scriptstdstring/scriptstdstring.h>

Edit 2: Of course I'm compiling both scriptstdstring.cpp and scriptstdstring_utils.cpp.

Edited by thewavelength, 21 September 2012 - 09:23 AM.


Sponsor:

#2 Jake Albano   Members   -  Reputation: 649

Like
0Likes
Like

Posted 21 September 2012 - 10:13 AM

I've never had to use the Angelscript namespace. The tutorials in the documentation use the same form as your second example, so you should be fine if you do it that way.

#3 Andreas Jonsson   Moderators   -  Reputation: 3452

Like
1Likes
Like

Posted 21 September 2012 - 11:15 AM

It's better to define AS_USE_NAMESPACE on the project settings, rather than in the code. Otherwise it is very easy to forget it in some places which makes part of the code refer to AngelScript functions without the namespace, and others with it, which is sure to cause linker errors.

In your case the namespace got declared when you included the scriptstdstring.h, thus the code sees the RegisterStdString() as part of the namespace. On the other hand, when the scriptstdstring.cpp was compiled the namespace was not declared, so RegisterStdString() was implemented outside the namespace.
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

#4 thewavelength   Members   -  Reputation: 109

Like
0Likes
Like

Posted 21 September 2012 - 11:33 AM

Wow. So obvious and I was blind, but now I see. Thanks!




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS