Advertisement

Begginer: Having problems compiling angelscript_clib

Started by June 28, 2020 05:28 AM
4 comments, last by WitchLord 4 years, 4 months ago

Heyo!

I'm starting to develop a game using C w Raylib and AngelScript, installed AngelScript from AUR, following tutorials, I try to compile my prototype, and Error, in include … ‘class’ …, cool, it's for c++, searched a lil, I found this for C: http://www.angelcode.com/angelscript/sdk/docs/manual/doc_addon_clib.html

I tried to compile it using the makefile in clib/projects/gnuc, but it fails with the following output:

g++ -Wall -I/usr/local/include -I../.. -L/usr/local/lib -c -fPIC ../../as_c.cpp -o as_c.o
../../as_c.cpp:53:7: error: conflicting return type specified for ‘virtual void asCBinaryStreamC::Write(const void*, asUINT)’
   53 |  void Write(const void *ptr, asUINT size) { write(ptr, size, param); }
      |       ^~~~~
In file included from ../../as_c.cpp:39:
/usr/local/include/angelscript.h:1168:14: note: overridden function is ‘virtual int asIBinaryStream::Write(const void*, asUINT)’
 1168 |  virtual int Write(const void *ptr, asUINT size) = 0;
      |              ^~~~~
../../as_c.cpp:54:7: error: conflicting return type specified for ‘virtual void asCBinaryStreamC::Read(void*, asUINT)’
   54 |  void Read(void *ptr, asUINT size) { read(ptr, size, param); }
      |       ^~~~
In file included from ../../as_c.cpp:39:
/usr/local/include/angelscript.h:1167:14: note: overridden function is ‘virtual int asIBinaryStream::Read(void*, asUINT)’
 1167 |  virtual int Read(void *ptr, asUINT size) = 0;
      |              ^~~~
../../as_c.cpp: In function ‘int asEngine_RegisterStringFactory(asIScriptEngine*, const char*, asFUNCTION_t, asDWORD, void*)’:
../../as_c.cpp:111:285: error: no matching function for call to ‘asIScriptEngine::RegisterStringFactory(const char*&, asSFuncPtr, asDWORD&, void*&)’
  111 |  e->RegisterStringFactory(datatype, asFUNCTION(factoryFunc), callConv, auxiliary); }
      |                                                                                 ^

In file included from ../../as_c.cpp:39:
/usr/local/include/angelscript.h:694:14: note: candidate: ‘virtual int asIScriptEngine::RegisterStringFactory(const char*, asIStringFactory*)’
  694 |  virtual int RegisterStringFactory(const char *datatype, asIStringFactory *factory) = 0;
      |              ^~~~~~~~~~~~~~~~~~~~~
/usr/local/include/angelscript.h:694:14: note:   candidate expects 2 arguments, 4 provided
make: *** [makefile:10: all] Error 1

I'm not gonna lie, I know that it says:

To compile the AngelScript C library, you need to compile the library source files in sdk/angelscript/source together with the source files in sdk/add-on/clib, and link them as a shared dynamic library. In the application that will use the AngelScript C library, you'll include the angelscript_c.h header file, instead of the ordinary angelscript.h header file. After that you can use the library much the same way that it's used in C++.

But I'm not an expert, and tried as it is anyways, I would like someone to point me in the right direction, thanks for your time and have a nice day!

I think the CLib add-on was removed a long time ago because it's not in the latest SDK.

Advertisement

I made progress!

I found here: https://www.angelcode.com/angelscript/resources.html

at the end, it says:

C interface

I've written a C interface that can be used to integrate AngelScript with other languages than C++, for example C, Delphi, Pascal, etc. As it is not part of the standard SDK I do not keep it updated with every release, but it is quite easy to update for the latest release when needed, so don't hesitate to let me know if you'd like to have it updated.

Download from here

Note: Last updated for 2.31.2 (June 24th, 2017)

Last updated for 2.31.2 :P

Downloaded it and installed the base without problems, error making the clib, somehow a unrecognized option on the compiler ('-Wl'), I removed it and compiles!.

Installed it and now, new problems!:

clang -c -o obj/main.o main.c
In file included from main.c:2:
In file included from ./includes.h:6:
/usr/local/include/angelscript_c.h:441:43: error: expected ')'
       AS_API int               asAtomicInc(int &value);
                                                ^
/usr/local/include/angelscript_c.h:441:38: note: to match this '('
       AS_API int               asAtomicInc(int &value);
                                           ^
/usr/local/include/angelscript_c.h:442:43: error: expected ')'
       AS_API int               asAtomicDec(int &value);
                                                ^
/usr/local/include/angelscript_c.h:442:38: note: to match this '('
       AS_API int               asAtomicDec(int &value);

I had to:

#define ANGELSCRIPT_DLL_MANUAL_IMPORT

and now it compiles, but I had new problems!, outdated documentation for angelscript_c and no doxygen to generate a new one. I mean, there's no

asEngine_ExecuteString

function on the angelscript_h, so I tried to follow the c++ guide, converting to the c counterparts (ex. "engine->RegisterGlobalFunction" turns out to be “asEngine_RegisterGlobalFunction”). But there's no counterpart for “CScriptBuilder”, since that's from a add-on, and the add-on is a cpp file :S.

I would like some help, thanks by the way ?

But there's no counterpart for “CScriptBuilder”, since that's from a add-on, and the add-on is a cpp file :S.

It's not that hard to write your own solution, as it boils down to 4 steps:

  • asEngine_SetMessageCallback
  • asEngine_GetModule
  • asModule_AddScriptSection
  • asModule_Build

That's basically it, most of your job here is just checking return values and spam user with errors, if there are any.

I'd say for start try to make your own builder function, without looking at scriptbuilder. As you just started, you won't miss that much honestly - preprocessor part is very basic, and metadata can be easily replaced with some config file.

Games are meant to be created, not played...

@pibeplay I don't actively maintain the C interface anymore since I really don't have the time for it. However if you identify some changes needed to make it work better, I'd appreciate it if you can send me the updates and I'll have it uploaded to the site.

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