.:: Bots United ::.  
filebase forums discord server github wiki web
cubebot epodbot fritzbot gravebot grogbot hpbbot ivpbot jkbotti joebot
meanmod podbotmm racc rcbot realbot sandbot shrikebot soulfathermaps yapb

Go Back   .:: Bots United ::. > Enhancement Workshop > Metamod and metamod plugins
Metamod and metamod plugins Plugins and improvements for the metamod server-side mod

Reply
 
Thread Tools
Linker errors with Metamod
Old
  (#1)
atomen
Member
 
Status: Offline
Posts: 3
Join Date: Jul 2010
Question Linker errors with Metamod - 24-04-2012

Hi!

I've been experiencing some problems while setting up a development
environment for metamod plugins using linux (Ubuntu Oneiric). On windows
everything work(ed) flawlessly but since I've changed OS I need to change
my tools (I previously used VS2008 ).

Everything works fine when compiling the stub plugin using the supplied
makefile (but it's a mess...) so I've been trying to create my own that I
can use for custom created plugins.

So to break it down; I am trying to compile the stub_plugin (on both
metamod and metamod-p) with my own makefile which is using the
following structure for source files:
Code:
-(project)
  --(source)  #contains custom source files (incl dllapi.cpp, sdk_util.cpp etc.)
  --(include) #contains custom header files
  --(build)   #contains build output such as *.so and *.o
This might seem as a simple task but because of the ambiguous makefile
supplied it is hard to see what one is doing wrong. But more importantly,
the problem I'm having appears during the linking process.

The individual source files all compiles (with a few warnings, which also
appears if I use the supplied makefile) but when I link them all to form
the final *.so library it fails with the following output:
Code:
gcc -ggdb3 -Wall -Wno-unknown-pragmas -m32 -DOPT_TYPE="\"debugging\"" -shared -ldl -lm -static-libgcc  build/dllapi.o  build/engine_api.o  build/h_export.o  build/meta_api.o  build/sdk_util.o -o stub_mm_i386.so
build/engine_api.o: In function `GetEntityAPI2':
/home/user/Desktop/metamod-p-1.19p32/stub/source/dllapi.cpp:106: multiple definition of `GetEntityAPI2'
build/dllapi.o:/home/user/Desktop/metamod-p-1.19p32/stub/source/dllapi.cpp:106: first defined here
build/h_export.o: In function `GetEntityAPI2':
/home/user/Desktop/metamod-p-1.19p32/stub/source/dllapi.cpp:106: multiple definition of `GetEntityAPI2'
build/dllapi.o:/home/user/Desktop/metamod-p-1.19p32/stub/source/dllapi.cpp:106: first defined here
build/meta_api.o: In function `GetEntityAPI2':
/home/user/Desktop/metamod-p-1.19p32/stub/source/dllapi.cpp:106: multiple definition of `GetEntityAPI2'
build/dllapi.o:/home/user/Desktop/metamod-p-1.19p32/stub/source/dllapi.cpp:106: first defined here
build/sdk_util.o: In function `GetEntityAPI2':
/home/user/Desktop/metamod-p-1.19p32/stub/source/dllapi.cpp:106: multiple definition of `GetEntityAPI2'
build/dllapi.o:/home/user/Desktop/metamod-p-1.19p32/stub/source/dllapi.cpp:106: first defined here
collect2: ld returned 1 exit status
make: *** [stub_mm_i386.so] Error 1
The weird thing is that the makefile output is practically identical (my makefile
compared to the supplied one). Here is the makefile I am using:
Code:
CC          =    gcc
CMNFLAGS    =    -ggdb3 -Wall -Wno-unknown-pragmas -m32 -DOPT_TYPE="\"debugging\""
CFLAGS      =    $(CMNFLAGS) -fPIC
LDFLAGS     =    $(CMNFLAGS) -shared -ldl -lm -static-libgcc
BUILD       =    build
SOURCE      =    source
INCLUDE     =    include
TARGET      =    $(shell basename $(CURDIR))_mm_i386.so
HLSDK       =    ../hlsdk

INCLUDES    =    -I$(INCLUDE) -I../metamod -I$(HLSDK)/engine -I$(HLSDK)/common \
                -I$(HLSDK)/pm_shared -I$(HLSDK)/dlls -I$(HLSDK)

SOURCES        = $(wildcard $(SOURCE)/*.cpp)
OBJECTS        = $(foreach dir, $(SOURCES:.cpp=.o), $(BUILD)/$(notdir $(dir)))

.PHONY: clean

all: $(SOURCES) $(TARGET)

$(TARGET): $(OBJECTS)
    $(CC) $(LDFLAGS) $(OBJECTS) -o $@

$(OBJECTS): $(SOURCES)
    $(CC) $(CFLAGS) $(INCLUDES) -o $@ -c $<

clean:
    -rm -r $(BUILD)
Can anyone tell what's wrong?

And last but not least, here is the two make outputs;
The output generated by my own makefile (make | lee out.txt)
Code:
gcc -ggdb3 -Wall -Wno-unknown-pragmas -m32 -DOPT_TYPE="\"debugging\"" -fPIC -Iinclude -I../metamod -I../hlsdk/engine -I../hlsdk/common -I../hlsdk/pm_shared -I../hlsdk/dlls -I../hlsdk -o build/dllapi.o -c source/dllapi.cpp
gcc -ggdb3 -Wall -Wno-unknown-pragmas -m32 -DOPT_TYPE="\"debugging\"" -fPIC -Iinclude -I../metamod -I../hlsdk/engine -I../hlsdk/common -I../hlsdk/pm_shared -I../hlsdk/dlls -I../hlsdk -o build/engine_api.o -c source/dllapi.cpp
gcc -ggdb3 -Wall -Wno-unknown-pragmas -m32 -DOPT_TYPE="\"debugging\"" -fPIC -Iinclude -I../metamod -I../hlsdk/engine -I../hlsdk/common -I../hlsdk/pm_shared -I../hlsdk/dlls -I../hlsdk -o build/h_export.o -c source/dllapi.cpp
gcc -ggdb3 -Wall -Wno-unknown-pragmas -m32 -DOPT_TYPE="\"debugging\"" -fPIC -Iinclude -I../metamod -I../hlsdk/engine -I../hlsdk/common -I../hlsdk/pm_shared -I../hlsdk/dlls -I../hlsdk -o build/meta_api.o -c source/dllapi.cpp
gcc -ggdb3 -Wall -Wno-unknown-pragmas -m32 -DOPT_TYPE="\"debugging\"" -fPIC -Iinclude -I../metamod -I../hlsdk/engine -I../hlsdk/common -I../hlsdk/pm_shared -I../hlsdk/dlls -I../hlsdk -o build/sdk_util.o -c source/dllapi.cpp
gcc -ggdb3 -Wall -Wno-unknown-pragmas -m32 -DOPT_TYPE="\"debugging\"" -shared -ldl -lm -static-libgcc  build/dllapi.o  build/engine_api.o  build/h_export.o  build/meta_api.o  build/sdk_util.o -o stub_mm_i386.so
The makefile output generated by the supplied makefile:
Code:
gcc -MM -I. -I../metamod -I../hlsdk/engine -I../hlsdk/common -I../hlsdk/pm_shared -I../hlsdk/dlls -I../hlsdk dllapi.cpp engine_api.cpp h_export.cpp meta_api.cpp sdk_util.cpp | sed "s;\(^[^     ]*\):\(.*\);debug.linux_i386/\1: Makefile Config.mak \2;" > debug.linux_i386/Rules.depend
gcc -ggdb3 -Wall -Wno-unknown-pragmas  -m32 -DOPT_TYPE="\"debugging\""  -fPIC -I. -I../metamod -I../hlsdk/engine -I../hlsdk/common -I../hlsdk/pm_shared -I../hlsdk/dlls -I../hlsdk -o debug.linux_i386/dllapi.o -c dllapi.cpp 
gcc -ggdb3 -Wall -Wno-unknown-pragmas  -m32 -DOPT_TYPE="\"debugging\""  -fPIC -I. -I../metamod -I../hlsdk/engine -I../hlsdk/common -I../hlsdk/pm_shared -I../hlsdk/dlls -I../hlsdk -o debug.linux_i386/engine_api.o -c engine_api.cpp 
gcc -ggdb3 -Wall -Wno-unknown-pragmas  -m32 -DOPT_TYPE="\"debugging\""  -fPIC -I. -I../metamod -I../hlsdk/engine -I../hlsdk/common -I../hlsdk/pm_shared -I../hlsdk/dlls -I../hlsdk -o debug.linux_i386/h_export.o -c h_export.cpp 
gcc -ggdb3 -Wall -Wno-unknown-pragmas  -m32 -DOPT_TYPE="\"debugging\""  -fPIC -I. -I../metamod -I../hlsdk/engine -I../hlsdk/common -I../hlsdk/pm_shared -I../hlsdk/dlls -I../hlsdk -o debug.linux_i386/meta_api.o -c meta_api.cpp 
gcc -ggdb3 -Wall -Wno-unknown-pragmas  -m32 -DOPT_TYPE="\"debugging\""  -fPIC -I. -I../metamod -I../hlsdk/engine -I../hlsdk/common -I../hlsdk/pm_shared -I../hlsdk/dlls -I../hlsdk -o debug.linux_i386/sdk_util.o -c sdk_util.cpp 
gcc -ggdb3 -Wall -Wno-unknown-pragmas  -m32 -DOPT_TYPE="\"debugging\""  -shared -ldl -lm -static-libgcc  debug.linux_i386/dllapi.o debug.linux_i386/engine_api.o debug.linux_i386/h_export.o debug.linux_i386/meta_api.o debug.linux_i386/sdk_util.o -o debug.linux_i386/stub_mm_i386.so
The only difference in the two outputs is that the supplied makefile issues
an additional call to gcc, but I do not quite understand what this call does
(new to both linux and the GNU toolchain) and I can not tell if it is of any
importance. I've tried using the call (gcc -MM ...) manually and then call
my own makefile but without avail. From my understanding the only thing
that line does is to output some data to rules.depend (am I correct?).

I'm so sorry for the long post and it was not intended to be this extensive. I do
know there aren't so many people out there who still possess knowledge about
metamod but I would appreciate it greatly if anyone could help me!

NOTE: Here's the supplied makefile (in case of interest): http://pastebin.com/m01u2wAn
NOTE2: The source files have not been modified in any way
NOTE3: Since the errors is related to GetEntityApi2 which uses C_DLLEXPORT, could that
be related to the error somehow? I also run AMD64 which might require modifications
to the makefile.

Last edited by atomen; 24-04-2012 at 13:50..
  
Reply With Quote
Reply

Tags
metamod makefile linker


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
vBulletin Skin developed by: vBStyles.com