PDA

View Full Version : dbcore.cpp error


Flare83
08-01-2008, 04:13 PM
I'm trying to compile 1119 under debian linux, but i'm getting this error =(

[CODE]-o ../common/dbcore.o
../common/dbcore.cpp: In static member function

Flare83
08-01-2008, 06:11 PM
wierd cut and paste error on my part i guess >.>

../common/dbcore.cpp: In static member function ‘static bool DBcore::ReadDBINI(char*, char*, char*, char*, int32&, bool&, bool*)’:
../common/dbcore.cpp:112: error: ‘atoi’ was not declared in this scope
make[1]: *** [../common/dbcore.o] Error 1
make[1]: Leaving directory `/home/equsr/EQemu/source/EQEmu-0.7.0-1119/world'
make: *** [all] Error 2

trevius
08-02-2008, 01:00 AM
Did you edit your source code before you started to compile? There are multiple changes that you have to make for it to compile. Though, I have never seen that particular error.

AndMetal
08-02-2008, 03:03 AM
I assume you're using GCC 4.3. If so, there's some information about this on the GCC website (http://gcc.gnu.org/gcc-4.3/porting_to.html) that I found through this forum (http://forum.mymediasystem.org/viewtopic.php?t=1258) using this Google search (http://www.google.com/search?hl=en&q=%E2%80%98atoi%E2%80%99+was+not+declared+in+this+ scope):

C++ language issues
Header dependency cleanup

As detailed here (Header dependency streamlining) (http://gcc.gnu.org/onlinedocs/libstdc++/manual/api.html#api.rel_430), many of the standard C++ library include files have been edited to only include the smallest possible number of additional files. As such, many C++ programs that used std::memcpy without including <cstring>, or used std::auto_ptr without including <memory> will no longer compile.

Usually, this error is of the form:

error: 'strcmp' was not declared in this scope

The table below shows some of the missing items, and the header file that will have to be added as an #include for the compile to succeed.
If missing Then include this header
find, for_each, sort <algorithm>
ostream_iterator, istream_iterator <iterator>
auto_ptr <memory>
typeid <typeinfo>
isalnum, toupper <cctype>
INT_MIN, INT_MAX, RAND_MAX <climits>
printf <cstdio>
atoi, free, rand, exit <cstdlib>
EXIT_FAILURE <cstdlib>
strcmp, strdup, strcpy, memcpy <cstring>


In other words, change this in common/dbcore.cpp (http://eqemulator.cvs.sourceforge.net/eqemulator/EQEmuCVS/Source/common/dbcore.cpp?view=markup):

1 #include "../common/debug.h"
2 #include "../common/files.h"
3
4 #ifdef WIN32
5 #include <winsock2.h>
6 #endif
7
8 #include <iostream>
9 using namespace std;
10 #include <errmsg.h>
11 #include <mysqld_error.h>
12 #include <limits.h>
13 #include "dbcore.h"
14 #include <string.h>
15 #include "../common/MiscFunctions.h"
16
17 #ifdef WIN32
18 #define snprintf _snprintf
19 #define strncasecmp _strnicmp
20 #define strcasecmp _stricmp
21 #include <process.h>
22 #else
23 #include "unix.h"
24 #include <pthread.h>
25 #endif
26
27 #ifdef _EQDEBUG
28 #define DEBUG_MYSQL_QUERIES 0
29 #else
30 #define DEBUG_MYSQL_QUERIES 0
31 #endif

to something like this:

#include "../common/debug.h"
#include "../common/files.h"

#ifdef WIN32
#include <winsock2.h>
#endif

#include <iostream>
using namespace std;
#include <errmsg.h>
#include <mysqld_error.h>
#include <limits.h>
#include "dbcore.h"
#include <string.h>
#include "../common/MiscFunctions.h"
#include <cstdlib>

#ifdef WIN32
#define snprintf _snprintf
#define strncasecmp _strnicmp
#define strcasecmp _stricmp
#include <process.h>
#else
#include "unix.h"
#include <pthread.h>
#endif

#ifdef _EQDEBUG
#define DEBUG_MYSQL_QUERIES 0
#else
#define DEBUG_MYSQL_QUERIES 0
#endif


Or you could do it the lazy way and just downgrade to 4.2 or 4.1 of GCC. I personally have 4.1 and it compiles fine. Long term, this is probably something that may needed to be added to the source in general.

trevius
08-02-2008, 03:07 AM
Well, the wiki should be pretty up-to-date for getting everything to compile correctly without having to change anything that isn't in the wiki. I know people have done it as recently as this week and it worked fine. Unless there was some change since then that would cause this, I imagine you missed something in there.

Flare83
08-02-2008, 09:33 AM
yea acually i'm using gcc 4.2 i'll try this here in a few. Guess i shoulda installed etch instead of lenny >.>

Flare83
08-02-2008, 10:23 AM
after applying your fix to about a dozen files Oo, now i'm getting this error.

client.h:141: warning: ‘typedef’ was ignored in this declaration
zone.cpp: In member function ‘bool Zone::LoadZoneObjects()’:
zone.cpp:184: warning: missing braces around initializer for ‘uint32 [2]’
make[1]: *** [zone.o] Error 1
make[1]: Leaving directory `/home/jenco/EQemu/source/EQEmu-0.7.0-1119/zone'
make: *** [all] Error 2

Flare83
08-02-2008, 11:07 AM
i got around that error by passing a fpermissive flag to zone's makefile (i know i should'nt do that to make things compile =( ) but it just looks like eqemu just need to be updated to gcc's new specs is all.