linux troubles

Started by
4 comments, last by WitchLord 19 years ago
I have troubles compiling angelscript in linux. I don't have a 64bit machine. I compiled the library by using the unmodified makefile in /mingw. the library file I renamed from .a to .so and copied it into my /usr/local/lib/ dir. when compiling I get the following errors:
obj/linux/debug/i_script.o(.text+0x3da): In function `afascumm::ScriptMgr::ScriptMgr[not-in-charge]()':
src/i_script.cpp:63: undefined reference to `asCreateScriptEngine'
obj/linux/debug/i_script.o(.text+0xe60): In function `afascumm::ScriptMgr::ScriptMgr[in-charge]()':
src/i_script.cpp:63: undefined reference to `asCreateScriptEngine'
collect2: ld returned 1 exit status
make: *** [foa2] Error 1
any help would be greatly appreciated
Advertisement
I don't know much about Linux, but I do know that you can't just rename the library file from .a to .so. One is meant for static linking, and the other for dynamic linking. You need to find the correct settings to compile the library as a .so directly.

Hope that gives you an idea of how to proceed.

Regards,
Andreas

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

Thank you very much for the suggestion WitchLord.

I've taken a look at the makefile of another library I already got to compile. Apparently it builds a .a file and is linked properly. So I can just skip the renaming part. "ar rs" seems to be the proper cmds for creating a statically linked lib.

Maybe the fault lies in my linking order or might there be a missing #define?

This the makefile I use (usually SRCNAMES is one line):
# Angelscript makefile for linux (based on MingW makefile)# Type 'make' then 'make install' to complete the installation of the library# !! where are lib/ and include/ ?LOCAL = /usr/localCXX = gccCXXFLAGS = -gSRCDIR = ../../sourceOBJDIR = objSRCNAMES = as_string.cpp as_string_util.cpp as_bstr_util.cpp as_builder.cppas_bytecode.cpp as_callfunc_x86.cpp as_compiler.cpp as_context.cppas_datatype.cpp as_map.cpp as_module.cpp as_objecttype.cppas_outputbuffer.cpp as_parser.cpp as_restore.cpp as_scriptcode.cppas_scriptengine.cpp as_scriptfunction.cpp as_scriptnode.cpp as_thread.cppas_tokenizer.cpp as_typeinfo.cpp as_variablescope.cpp as_arrayobject.cppas_generic.cppOBJ = $(addprefix $(OBJDIR)/, $(notdir $(SRCNAMES:.cpp=.o)))BIN = ../../lib/libangelscript.aDELETER = rm -fCOPIER = cpINCLUDEFILES_D = ../../include/angelscript.hUNINSTALLFILES_D = $(LOCAL)\lib\libangelscript.a $(LOCAL)\include\angelscript.hall: $(BIN)$(BIN): $(OBJ)        ar rs $(BIN) $(OBJ)        @echo -------------------------------------------------------------------        @echo Done. Now type 'make install' to install the library.$(OBJDIR)/%.o: $(SRCDIR)/%.cpp        $(CXX) $(CXXFLAGS) -o $@ -c $<clean:        $(DELETER) $(OBJ) $(BIN)install: $(BIN)        $(COPIER) $(BIN) $(LOCAL)/lib        $(COPIER) $(INCLUDEFILES_D) $(LOCAL)/include        @echo -------------------------------------------------------------------        @echo Angelscript library installed. Enjoy!uninstall:        $(DELETER) $(UNINSTALLFILES_D)        @echo -------------------------------------------------------------------        @echo Angelscript library uninstalled..PHONY: all clean install uninstall
It could be that not all the modules are linked into the library file. I think you need to end each line for SRCNAMES with a backslash \ so that all the lines will be taken as one.

You may also take a look at the makefiles that are available from the library download page. They may not work as they are now, but the changes needed to them ought to be just the inclusion/exclusion of the source files that have changed.

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

ok I finally managed :)

it really was the linking order. I tried compiling one of the angelscript tests and as that worked flawlessly (yay, nice work!) it was obvious that something with my own project had to be wrong. I feel silly for not having tested one of the original progs first.

anyway... somehow it was important for the final linking of my project to add the "-langelscript" parameter _after_ all other parameters, including the object files. I'm a bit puzzeled about that as the other librarys work fine and follow right after the gcc command.

I've sent you an updated version of the linux makefile in case you are interested.

again, thanks for your quick replies WitchLord!
Great to hear that you managed to get it working.

I don't know either why the library has to be the last parameter. One would think the order didn't matter.

I'll make sure to include a Linux makefile in the library download (the one you sent me), in future versions. So that it will be easier for others to get it working.

Regards,
Andreas

PS. I will add your game engine to the site as soon as time lets me.



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