Sign in to follow this  

GCC Compile Error.. Help

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

Hello everyone, I'm a game porgrammer for hobby. Now I'm develop for PSP by using GCC. When I'm compiling the codes, gcc's compiler says: scriptstring.cpp : undefined reference to 'asGetLibraryOptions'... and other error about "undefined refrence" here is my makefile: TARGET = ARPGMaker OBJS = debug.o GraphicsData.o Graphics.o Input.o log.o Text.o sprite.o publicSprite.o scenemap.o tile.o Person.o Skill.o Sound.o Equip.o Scene.o UIFrame.o AngelScriptBinder.o scriptstring.o scriptstring_utils.o scriptbuilder.o BUILD_PRX = 1 PSP_FW_VERSION=371 INCDIR = ../../include LIBDIR = ../../lib CFLAGS = -G0 -w -O2 -D_DEBUG_LOG CXXFLAGS = $(CFLAGS) ASFLAGS = $(CFLAGS) LDFLAGS = LIBS += -lnge2 -lfreetype -lpng -lz -ljpeg -lg -lstdc++ -lpspmpeg -lpspaudiocodec -lpspaudio -lpsppower -lpspgum -lpspgu -lpsprtc -lm libangelscript.a EXTRA_TARGETS = EBOOT.PBP PSP_EBOOT_TITLE = RPGMakerDEMO PSPSDK=$(shell psp-config --pspsdk-path) PSPBIN = $(PSPSDK)/../bin include $(PSPSDK)/lib/build.mak Can you tell me where is the mistake? Thanks!!

Share this post


Link to post
Share on other sites
Undefined reference means that the definition of a function is missing at linking time. This usually rises up when you're including headers from a library but not linking to the library itself. The best you can do is find out to which library the functions listed as undefined belong to and link to it.

Share this post


Link to post
Share on other sites
I apologise if this is a stupid suggestion, but are you using g++ or gcc to build this program? Your libraries and source files appear to be C++ files, which requires g++ to build rather than the C gcc compiler.

The other cause is going to be a missing function definition as owl says. Did you build the angelscript libraries yourself?

Share this post


Link to post
Share on other sites
The way that I do it is to include the directory that the file is in with something like "-I /usr/include/libxml2", then link to the library in the normal way, without the extension or "lib" prefix. I didn't explain that very well, so I'll give some examples:

To link to "/usr/include/libxml2/libxml2.a", I'd use the compile command:

g++ -I /usr/include/libxml2 -lxml2 program.cpp.

So for your particular problem, I'd include the angelscript directory with -I and then add the library with "-langelscript". Hope this helps.

EDIT: If you don't want to add the path, then just drop libangelscript.a into your libraries directory and link to it in the usual way, with "-langelscript".

Share this post


Link to post
Share on other sites
I have seen such notes in angelscript.h , in line 415

// ANGELSCRIPT_EXPORT is defined when compiling the dll or lib
// ANGELSCRIPT_DLL_LIBRARY_IMPORT is defined when dynamically linking to the
// dll through the link lib automatically generated by MSVC++
// ANGELSCRIPT_DLL_MANUAL_IMPORT is defined when manually loading the dll
// Don't define anything when linking statically to the lib

I will use static lib in my project. so shall I cancel these defines?
I think this problem is not about makefile.Because other static libs works well.
Can you teach me?

Share this post


Link to post
Share on other sites
To include the path for the library you need to use the command swith -L, not -I. -I is to add paths for include files.

To build the test applications in the AngelScript SDK the command used is:


g++ -o testgnuc $(OBJ) -langelscript -L ../../../../angelscript/lib


Where $(OBJ) is the list of C++ modules included.

-langelscript tells the compiler to link with the libangelscript.a, and -L ../../../../angelscript/lib tells the compiler where it can find the library.

There is no need to modify the ANGELSCRIPT_EXPORT, ANGELSCRIPT_DLL_MANUAL_IMPORT, or ANGELSCRIPT_DLL_LIBRARY_IMPORT defines. You can leave these as they are. GNUC doesn't need those to link properly.

Regards,
Andreas

Share this post


Link to post
Share on other sites

This topic is 3039 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this