View Single Post
  #1  
Old 10-14-2014, 05:11 PM
CoryWalker
Fire Beetle
 
Join Date: Oct 2014
Posts: 23
Default Linking against libcommon.a fails

I am able to create libcommon.a without any linker issues at all. However, when I attempt to further link against libcommon.a and create an executable - such as shared_memory - I get the following 4 linker errors:

--
g++49 -o test -nodefaultlibs -L/usr/local/lib/gcc49 main.o /usr/local/build/everquest/common/libcommon.a /usr/lib/libthr.so /usr/local/lib/mysql/libmysqlclient.so -lgcc_s -lstdc++ -lc

/usr/local/build/everquest/common/libcommon.a: undefined reference to `SPDAT_RECORDS'

/usr/local/build/everquest/common/libcommon.a: undefined reference to `CatchSignal(int)'

/usr/local/build/everquest/common/libcommon.a: undefined reference to `timeout_manager'

/usr/local/build/everquest/common/libcommon.a: undefined reference to `spells'
collect2: error: ld returned 1 exit status
--

I know the exact cause of the errors. However, I do not know what the safe way of fixing the issue is. All of these errors are caused by declaring external variables in a header file but are not defined in the application that uses them - at the very least shared_memory is not defining them.

The following extern variables and functions are in question:

spdat.h, line 754:
extern int32 SPDAT_RECORDS;

eqemu_error.cpp, line 32:
void CatchSignal(int sig_num);

timeoutmgr.h, line 64:
extern TimeoutManager timeout_manager;

spdat.h, line 753:
extern const SPDat_Spell_Struct* spells;

What is the best way to resolve this issue? Are these globals still used? Should I manually defined them? Should I just delete them and recompile/relink?
Reply With Quote