PDA

View Full Version : Net.cpp fails to compile


Darkmeerkat
09-17-2005, 08:12 AM
I'm having a problem compiling the "net.cpp" file:
When I run make in the zone directory, I get this at the end of the output:

gcc -c -Wall -Wuninitialized -Wwrite-strings -Wcast-qual -Wstrict-prototypes -Wno-deprecated -Wcomment -Wcast-align -O2 -ggdb -pthread -pipe -D_GNU_SOURCE -DINVERSEXY -DFX -DZONE -DEQDEBUG=5 -DNO_PIDLOG -DSHAREMEM -DSPELL_EFFECT_SPAM -DFIELD_ITEMS `mysql_config --cflags` net.cpp -o net.o
net.cpp: In function `char* strsep(char**, const char*)':
net.cpp:969: error: declaration of `char* strsep(char**, const char*)' throws
different exceptions
net.cpp:144: error: than previous declaration `char* strsep(char**, const
char*) throw ()'
make: *** [net.o] Error 1

As far as I can tell, it has something to do with the strsep function, but I'm not skilled enough to figure out much beyond that.
The closest I could find to a replication of the problem was this post (http://www.eqemulator.net/forums/showthread.php?t=18375&highlight=net.o+zone), and I'm not running SuSE. (Slackware for me! ;))
Any ideas?

Cisyouc
09-17-2005, 11:33 AM
What gcc version are you using?

(gcc --version)

Darkmeerkat
09-17-2005, 01:20 PM
3.3.4
Here's the full output, if it helps any:

(Sat 17 Sep 2005 05:47:18 PM MST)-(nate@meerkat)-(~)
$ gcc -v
Reading specs from /usr/lib/gcc-lib/i486-slackware-linux/3.3.4/specs
Configured with: ../gcc-3.3.4/configure --prefix=/usr --enable-shared --enable-threads=posix --enable-__cxa_atexit --disable-checking --with-gnu-ld --verbose --target=i486-slackware-linux --host=i486-slackware-linux
Thread model: posix
gcc version 3.3.4

bleh
09-17-2005, 05:29 PM
Comment out the code declaring strsep in net.cpp. Let it use the function already on your system, and see if that doesn't work.

Darkmeerkat
09-19-2005, 04:41 AM
Thanks, that got me past that part. Now it just throws this error:

(Sat 17 Sep 2005 10:56:02 PM MST)-(root@meerkat)-(/usr/local/bin/EQEmu/source/9-17-05/zone)
# make
gcc -Wall -Wuninitialized -Wwrite-strings -Wcast-qual -Wstrict-prototypes -Wno-deprecated -Wcomment -Wcast-align -O2 -ggdb -pthread -pipe -D_GNU_SOURCE -DINVERSEXY -DFX -DZONE -DEQDEBUG=5 -DNO_PIDLOG -DSHAREMEM -DSPELL_EFFECT_SPAM -DFIELD_ITEMS `mysql_config --cflags` .obj/EQNetwork.o ../common/timer.o ../common/packet_dump.o ../common/packet_functions.o ../common/unix.o ../common/packet_dump_file.o ../common/Mutex.o ../common/MiscFunctions.o zone.o entity.o mob.o client.o client_process.o npc.o net.o spawn2.o attack.o hate_list.o ../common/serverinfo.o ../common/moremath.o worldserver.o spells.o spawngroup.o loottables.o faction.o Map.o PlayerCorpse.o petitions.o MobAI.o Object.o ../common/eqtime.o groups.o ../common/classes.o ../common/races.o ../common/TCPConnection.o forage.o ../common/crc32.o ../common/md5.o ../common/dbcore.o ../common/dbasync.o zonedbasync.o parser.o beacon.o ../common/EMuShareMem.o ../common/EQEMuError.o ../common/ptimer.o .obj/debug.o .obj/database.o .obj/Item.o .obj/misc.o doors.o command.o AA.o client_packet.o tribute.o zone_profile.o bonuses.o trading.o spdat.o spell_effects.o aggro.o guilds.o inventory.o client_mods.o tradeskills.o waypoints.o pets.o effects.o trap.o perl_client.o perl_entity.o perl_mob.o perl_npc.o perl_PlayerCorpse.o perl_groups.o questmgr.o client_logs.o perlparser.o ../common/rdtsc.o ../common/extprofile.o horse.o exp.o fearpath.o special_attacks.o ../common/timeoutmgr.o ../common/Condition.o pathing.o -rdynamic -L. -lstdc++ -ldl `mysql_config --libs` -o zone
/usr/lib/gcc-lib/i486-slackware-linux/3.3.4/../../../../i486-slackware-linux/bin/ld: cannot find -lmysqlclient
collect2: ld returned 1 exit status
make: *** [zone] Error 1
(Sat 17 Sep 2005 10:56:09 PM MST)-(root@meerkat)-(/usr/local/bin/EQEmu/source/9-17-05/zone)

I'm assuming it's choking trying to find the MySQL libraries (Which are located in /usr/local/bin/mysql/lib, but linked to in /usr/bin). I dinked around with it a little, and eventually modified the decleration part of the makefile to::

CC=gcc
LINKER=gcc
MYSQL_FLAGS=`mysql_config --cflags`
# Making this link directly to the libs didn't work. (returned "/usr/local/bin/mysql/lib is a directory", then a bunch of undefined errors.)
#MYSQL_LIB=`/usr/local/bin/mysql/lib/`
DFLAGS=-DEQDEBUG=5 -DNO_PIDLOG -DSHAREMEM -DSPELL_EFFECT_SPAM -DFIELD_ITEMS
WFLAGS=-Wall -Wuninitialized -Wwrite-strings -Wcast-qual -Wstrict-prototypes -Wno-deprecated -Wcomment -Wcast-align
COPTS=$(WFLAGS) -O2 -ggdb -pthread -pipe -D_GNU_SOURCE -DINVERSEXY -DFX -DZONE $(DFLAGS) $(MYSQL_FLAGS)
#LINKOPTS=-rdynamic -L. -lstdc++ -ldl $(MYSQL_LIB)
LINKOPTS=-rdynamic -L. -lstdc++ -ldl -L/usr/bin -lmysqlclient -lz -lcrypt -lnsl -lm -lc -lnss_files -lnss_dns -lresolv -lc-lnss_files -lnss_dns -lresolv

It now returns this when I make it:

(Sun 18 Sep 2005 11:05:01 PM MST)-(root@meerkat)-(/usr/local/bin/EQEmu/source/9-17-05/zone)
# make
gcc -Wall -Wuninitialized -Wwrite-strings -Wcast-qual -Wstrict-prototypes -Wno-deprecated -Wcomment -Wcast-align -O2 -ggdb -pthread -pipe -D_GNU_SOURCE -DINVERSEXY -DFX -DZONE -DEQDEBUG=5 -DNO_PIDLOG -DSHAREMEM -DSPELL_EFFECT_SPAM -DFIELD_ITEMS `mysql_config --cflags` .obj/EQNetwork.o ../common/timer.o ../common/packet_dump.o ../common/packet_functions.o ../common/unix.o ../common/packet_dump_file.o ../common/Mutex.o ../common/MiscFunctions.o zone.o entity.o mob.o client.o client_process.o npc.o net.o spawn2.o attack.o hate_list.o ../common/serverinfo.o ../common/moremath.o worldserver.o spells.o spawngroup.o loottables.o faction.o Map.o PlayerCorpse.o petitions.o MobAI.o Object.o ../common/eqtime.o groups.o ../common/classes.o ../common/races.o ../common/TCPConnection.o forage.o ../common/crc32.o ../common/md5.o ../common/dbcore.o ../common/dbasync.o zonedbasync.o parser.o beacon.o ../common/EMuShareMem.o ../common/EQEMuError.o ../common/ptimer.o .obj/debug.o .obj/database.o .obj/Item.o .obj/misc.o doors.o command.o AA.o client_packet.o tribute.o zone_profile.o bonuses.o trading.o spdat.o spell_effects.o aggro.o guilds.o inventory.o client_mods.o tradeskills.o waypoints.o pets.o effects.o trap.o perl_client.o perl_entity.o perl_mob.o perl_npc.o perl_PlayerCorpse.o perl_groups.o questmgr.o client_logs.o perlparser.o ../common/rdtsc.o ../common/extprofile.o horse.o exp.o fearpath.o special_attacks.o ../common/timeoutmgr.o ../common/Condition.o pathing.o -rdynamic -L. -lstdc++ -ldl -L/usr/bin -lmysqlclient -lz -lcrypt -lnsl -lm -lc -lnss_files -lnss_dns -lresolv -lc -lnss_files -lnss_dns -lresolv -o zone
.obj/EQNetwork.o(.gnu.linkonce.t._ZN8APPLAYERC1E9EmuOpc odej+0xc0): In function `APPLAYER::APPLAYER[in-charge](EmuOpcode, unsigned)':
../common/EQNetwork.h:197: undefined reference to `OpcodeNames'
entity.o(.text+0x1872): In function `EntityList::MakeDoorSpawnPacket(APPLAYER*)':
../common/EQNetwork.h:197: undefined reference to `OpcodeNames'
mob.o(.text+0x1e4f): In function `Mob::CreateSpawnPacket(APPLAYER*, Mob*)':
../common/EQNetwork.h:197: undefined reference to `OpcodeNames'
mob.o(.text+0x22ba): In function `Mob::CreateSpawnPacket(APPLAYER*, NewSpawn_Struct*)':
../common/EQNetwork.h:197: undefined reference to `OpcodeNames'
mob.o(.text+0x274f): In function `Mob::CreateDespawnPacket(APPLAYER*)':
../common/EQNetwork.h:197: undefined reference to `OpcodeNames'
mob.o(.text+0x28a2):../common/EQNetwork.h:197: more undefined references to `OpcodeNames' follow
net.o(.text+0x130): In function `main':
/usr/local/bin/EQEmu/source/9-17-05/zone/net.cpp:205: undefined reference to `OpcodeManager::OpcodeManager[not-in-charge]()'
net.o(.text+0x136):/usr/local/bin/EQEmu/source/9-17-05/zone/net.cpp:205: undefined reference to `vtable for SharedOpcodeManager'
net.o(.text+0x14e):/usr/local/bin/EQEmu/source/9-17-05/zone/net.cpp:207: undefined reference to `vtable for SharedOpcodeManager'
PlayerCorpse.o(.text+0x3dda): In function `Corpse::EndLoot(Client*, APPLAYER const*)':
../common/EQNetwork.h:197: undefined reference to `OpcodeNames'
Object.o(.text+0xffd): In function `Object::CreateSpawnPacket(APPLAYER*)':
../common/EQNetwork.h:197: undefined reference to `OpcodeNames'
Object.o(.text+0x1091): In function `Object::CreateDeSpawnPacket(APPLAYER*)':
../common/EQNetwork.h:197: undefined reference to `OpcodeNames'
client_packet.o(.text+0x1775): In function `Client::HandlePacket(APPLAYER const*)':
/usr/include/c++/3.3.4/bits/stl_tree.h:778: undefined reference to `OpcodeNames'
client_packet.o(.text+0x18c7): In function `Client::HandlePacket(APPLAYER const*)':
/usr/local/bin/EQEmu/source/9-17-05/zone/client_packet.cpp:350: undefined reference to `OpcodeNames'
client_packet.o(.text+0x5494):../common/EQNetwork.h:197: more undefined references to `OpcodeNames' follow
collect2: ld returned 1 exit status
make: *** [zone] Error 1

Am I not including the right libraries?

bleh
09-19-2005, 10:08 AM
Just a guess, but edit the makefile you're using, and look at the "SF" variable. Try adding "../common/opcodemgr.o", "../common/emu_opcodes.o", and "../common/EQPacket.o" to it if they're not there already.

You may also be able to just do "make -f makefile.bsd" (always seemed to be more updated) instead. If neither of those work, you'll have to find which file has "OpcodeNames" defined in it.

johane
09-19-2005, 10:09 AM
Thanks, that got me past that part. Now it just throws this error:

I'm assuming it's choking trying to find the MySQL libraries (Which are located in /usr/local/bin/mysql/lib, but linked to in /usr/bin). I dinked around with it a little, and eventually modified the decleration part of the makefile to::

CC=gcc
LINKER=gcc
MYSQL_FLAGS=`mysql_config --cflags`
# Making this link directly to the libs didn't work. (returned "/usr/local/bin/mysql/lib is a directory", then a bunch of undefined errors.)
#MYSQL_LIB=`/usr/local/bin/mysql/lib/`
DFLAGS=-DEQDEBUG=5 -DNO_PIDLOG -DSHAREMEM -DSPELL_EFFECT_SPAM -DFIELD_ITEMS
WFLAGS=-Wall -Wuninitialized -Wwrite-strings -Wcast-qual -Wstrict-prototypes -Wno-deprecated -Wcomment -Wcast-align
COPTS=$(WFLAGS) -O2 -ggdb -pthread -pipe -D_GNU_SOURCE -DINVERSEXY -DFX -DZONE $(DFLAGS) $(MYSQL_FLAGS)
#LINKOPTS=-rdynamic -L. -lstdc++ -ldl $(MYSQL_LIB)
LINKOPTS=-rdynamic -L. -lstdc++ -ldl -L/usr/bin -lmysqlclient -lz -lcrypt -lnsl -lm -lc -lnss_files -lnss_dns -lresolv -lc-lnss_files -lnss_dns -lresolv

It now returns this when I make it:

Am I not including the right libraries?


This is a common problem with development code in many projects. To resolve it (OK, bad joke I know!) use grep:


cd ${your_source_directory}
grep -r "Object::MethodName" | grep cpp


You'll get a list of all the places that the symbol is used in the cource code. Look at the list, and select a likely culprit - let's assume we decide "common/opcodemgr.cpp" is a good one to try.

Check that it's not in the "APP" line in the makefile. Then APPEND it to that line. Rerun "make clean && make".

Either that fixes it (and possibly another link error shows itself) or it doesnt, in which case you replace the thing you added to the makefile with another likely suspect.

Note that not knowing this kind of stuff suggests you are a bit out of your depth, and a course or decent book on C++ might be a good idea. There's some decent stuff in the LDP (Programming HOWTO for example )to read if you are very bright.

Darkmeerkat
09-21-2005, 09:11 AM
Thanks, Bleh, adding those files worked. :)

I ended up with two more errors, but I somehow managed to fix them myself, as they were similar to the previous ones.
The first one was this:

gcc -c -Wall -Wuninitialized -Wwrite-strings -Wcast-qual -Wstrict-prototypes -Wno-deprecated -Wcomment -Wcast-align -O2 -ggdb -pthread -pipe -D_GNU_SOURCE -DINVERSEXY -DFX -DZONE -DEQDEBUG=5 -DNO_PIDLOG -DSHAREMEM -DSPELL_EFFECT_SPAM -DFIELD_ITEMS `mysql_config --cflags` ../common/EQPacket.cpp -o ../common/EQPacket.o
../common/misc.h: In member function `void EQPacket::DumpRaw(FILE*) const':
../common/misc.h:34: error: too many arguments to function `void
dump_message_column(unsigned char*, long unsigned int,
std::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
../common/EQPacket.cpp:125: error: at this point in file
make: *** [../common/EQPacket.o] Error 1


The call to dump_message_column is indeed being passed too many variables in EQPacket.o:

void EQPacket::DumpRaw(FILE *to) const
{
DumpRawHeader();
if (pBuffer && size)
dump_message_column(pBuffer, size, " ", to);
fprintf(to, "\n");
}


dump_message_column's prototype (in misc.h):

void dump_message_column(unsigned char *buffer, unsigned long length, string leader);


It looked to me as if "to" was erronously added as a fourth parameter, so I took that out and it worked.

The second was:

../common/EQPacket.o(.text+0x10fa): In function `EQProtocolPacket::ValidateCRC(unsigned char const*, int, unsigned)':
../common/EQPacket.cpp:307: undefined reference to `CRC16(unsigned char const*, int, int)'
collect2: ld returned 1 exit status
make: *** [zone] Error 1

Which was easily fixed by adding CRC16.o to the makefile.

However, I ran into another error trying to run world:

(Wed 21 Sep 2005 01:25:01 PM MST)-(root@meerkat)-(/usr/local/bin/EQEmu/server)
# ./world
[Status] Using database 'eqemu' at localhost
[Status] CURRENT_WORLD_VERSION:EQEMu 0.6.0-DR3
[Status] Loading opcodes..
[Error] LoadEMuShareMemDLL::Load() failed to attach a function. Error=0
[Error] Loading opcodes failed. I cant live like this!

I've added the location of the folder that holds libEMuShareMem.so into my /etc/ld.so.conf file, and run ldconfig, as per Muuss's guide (http://www.eqemulator.net/forums/showthread.php?t=17395).
I can't figure out why it would be trying to load a DLL when I'm running this on Linux...


Note that not knowing this kind of stuff suggests you are a bit out of your depth, and a course or decent book on C++ might be a good idea. There's some decent stuff in the LDP (Programming HOWTO for example )to read if you are very bright.

You're right, I am quite a bit in over my head here. :D
I am looking into some books, though. (Judging from reviews, C++ Primer Plus (http://www.amazon.com/exec/obidos/tg/detail/-/0672326973/qid=1127334697/sr=1-2/ref=sr_1_2/102-3784291-7602543?v=glance&s=books) looks good...)