Yeah, I know this isn't one of the 'supported' codebases out here, and yes I know I'm a total newbie who doesn't deserve to have his own MUD... Nonetheless, I would like to get this one working.
You can download a copy from: http://www.dragonssquare.com or, if you're too lazy you could go directly to: http://www.dragonssquare.com/scratch/download.php
Now, then.. It extracts just fine, though I'll post that ouput below as well just for reference;
Ok, then... Looks fine, right? This is what happens when you 'MAKE' with Cygwin.
g++ -c -Wall -O -ggdb src/avatar.cpp -o obj/avatar.o
src/avatar.cpp:17:25: mysql/mysql.h: No such file or directory
In file included from src/avatar.cpp:18:
src/smysql.h:38: error: `std::vector<std::map<std::string, std::string, std::less<std::string>, std::allocator<std::pair<const std::string, std::string> > >, std::allocator<std::map<std::string, std::string, std::less<std::string>, std::allocator<std::pair<const std::string, std::string> > > > >' is not a template
src/avatar.cpp: In member function `std::string Avatar::EncryptPassword(const std::string&)':
src/avatar.cpp:179: error: `crypt' undeclared (first use this function)
src/avatar.cpp:179: error: (Each undeclared identifier is reported only once for each function it appears in.)
make: *** [obj/avatar.o] Error 1
^Not good.
And last, but not least.. The contents of the makefile are;
at the top of your avatar.cpp file (with the other includes) should get rid of your crypt error.
As for MySQL, you need to install it. Head over to www.mysql.com and find the download (I would recommend the admin application unless you are very command line savvy).
Could you paste line 38 from smysql.h (and the general code around it)?
Nick: First thing, it looks like you need to install mySQL for it to work.
Well, before I posted here I went and grabbed a copy from the website www.mysql.com. I installed the program and then
tried re-making the files (after MAKE CLEAN, of course) but it still gave me the same error..
Samson: And then you need to install the crypt library if you don't have it and make sure any files reporting this error
include crypt.h
I'm pretty sure I have downloaded it sometime in the last month or so because some of the MUD servers I've worked
with in the last bit had the -lcrypt flag and seemed to work... Though I'm not sure how I could tell if I do, for sure, have
the library... Is there a specific file I could look for somewhere in the Cygwin directory?
And last, but not least;
Whiteknight:
Adding the line: #include <crypt.h> at the top of your avatar.cpp file (with the other includes) should get rid of your crypt error. As for MySQL, you need to install it. Head over to www.mysql.com and find the download (I would recommend the admin
application unless you are very command line savvy). Could you paste line 38 from smysql.h (and the general code around it)?
This is what happened -after- I added <crypt.h> to the file (also, is there a difference between "crypt.h" and <crypt.h>?)
g++ -c -Wall -O -ggdb src/avatar.cpp -o obj/avatar.o
src/avatar.cpp:17:25: mysql/mysql.h: No such file or directory
In file included from src/avatar.cpp:18:
src/smysql.h:38: error: `std::vector<std::map<std::string, std::string, std::less<std::string>, std::allocator<std::pair<const std::string, std::string> > >, std::allocator<std::map<std::string, std::string, std::less<std::string>, std::allocator<std::pair<const std::string, std::string> > > > >' is not a template
make: *** [obj/avatar.o] Error 1
And, here is the contents of Avatar.CPP (From the first non-comment line down to what I believe is the end of that line of code, which is line 49.)
src/avatar.cpp:17:25: mysql/mysql.h: No such file or directory
Well, there are more than one ways of installing mysql. It looks to me from this error that it expects mysql.h in a subdirectory. Is that file indeed there? You may have the mysql executables and not the source. You may not have even installed mysql.h, or if you have it may be in a different place.
I would fix that before worrying about the error message about:
src/smysql.h:38: error: `std::vector blah-de-blah-blah > > > >' is not a template
Well, if I head back to www.mysql.com and download the source instead.. Where am I supposed to drop the files? A subdirectory in the SRC folder called MYSQL? I'm just asking because I have no idea where I should have this bloody thing installed.. I do have something from the www.mysql.com site installed to my program files..
I'm not totally certain myself, I seem to recall a certain amount of pain being associated with getting the mysql source to work.
One approach would be to download and unzip the source, and then simply find mysql.h in the downloaded directory and put it where it is expected. However this may merely delay the problem, as it needs other files, libraries, etc.
Quote:
...I'm a total newbie who doesn't deserve to have his own MUD ...
This obviously isn't true. Anyone can "deserve" to have a MUD. Some are easier to set up than others. :)
If I may suggest, the SmaugFUSS codebase, available here and supported by Samson, doesn't require mysql and works "out of the box". Using mysql to store whatever-it-is that they store is adding another layer of complexity.
For MUD "newbies" it is probably easiest on yourself to find a codebase that works with minimal extra work. At least with SmaugFUSS I generally get it to compile and run without any fuss (no pun) on both Cygwin and Linux.
Well, I was hoping to go with Scratch because it comes free of all the stock areas and resets that tend to destroy the MUD when I fool around with it too much, though I am also already tinkering about with the SmaugFUSS from this site. Something I have been meanin' to drop in here and thank you for porting. Well, I guess I'll tinker with the MySQL a little more and if I still don't get it, I'll just have to wait until I get some more experience with coding and working with *nix systems.. Thanks, again.
I managed to weasel the MySQL files into the compile well enough that it's no longer having issues with that. (I think.)
What I did was download the MySQL Source (as was suggested) and copied mysql.h into the SRC directory of this mud server. Then, in Avatar.CPP I changed #include <mysql/mysql.h> to #include "mysql.h". This managed to get me a horrendously long error log.. After reading through it to the top, I noticed it now wanted the following files;
After hunting those down in the source for MySQL, and dropping them into the SRC file of the server, I managed to get it down to 2 errors. One of which was smysql.h (came with server) was still linking to the #include <mysql/mysql.h>, so I changed it to #include "mysql.h" like I did in Avatar.cpp. Another make, and things seemed to being well, until this one kicked in;
g++ -c -Wall -O -ggdb src/avatar.cpp -o obj/avatar.o
In file included from src/avatar.cpp:18:
src/smysql.h:38: error: `std::vector<std::map<std::string, std::string, std::less<std::string>, std::allocator<std::pair<const std::string, std::string> > >, std::allocator<std::map<std::string, std::string, std::less<std::string>, std::allocator<std::pair<const std::string, std::string> > > > >' is not a template
make: *** [obj/avatar.o] Error 1
So, using my lackluster coding experience, I've been able to figure out that it's in smysql.h on line 38. Since that header is so short, I'll post it here in its entirety.
///////////////////////////////////////////////////////////
///////////////// Have an itch? Scratch it! ///////////////
///////////////////////// SCRATCH /////////////////////////
///////////////////// A MUD Server ////////////////////
///////////////////// By: Jared Devall ////////////////////
///////////////////// Thanks: ////////////////////
///////////////////// DIKU/Merc/ROM ////////////////////
///////////////////// Aetas/Deus Gang ////////////////////
///////////////////// Beej ////////////////////
///////////////////////////////////////////////////////////
// Our singleton instance
inline Mysql &Mysql::Instance() {
static Mysql instance( "localhost", "rendelven", "rendelhaven", "rendelven" );;
return instance;
}
#endif // _SMYSQL_H
Alright, so... Look forward to any more help that can be provided.
-Edit: I just figured out the difference between "blah.h" and <blah.h> so I've moved the MySQL-related files into CygwinRoot/Usr/Include and changed the #Include links to reflect this...
I'm still havin' issues with this particular error. I'm guessing there's been no replies because no one realizes thie thread is still active. I appreciated the help that has been given thus far, and I hope someone out there may have some more information that may lead to me slaying this proverbial dragon.
I've gotten this to compile using Dev-C++ and it works fine. The error you are having is with this line:
RESULT< LMAP > _info;
Delete the < LMAP > portion. I do not know if this is how it should be, but it seems to work. The only downside is that you should really copy whatever the thing is holding after a query because it will later be modified and screw with your data.
Sorry for not replying sooner, I wasn't really keen to find and install the codebase, find and install mysql source, and then work out what the error was, when you might have had a different version of gcc.
Whiteknight is right, basically.
A test program illustrates the problem:
#include <vector>
void test ()
{
typedef int LMAP; // for testing
typedef std::vector< LMAP > RESULT;
RESULT< LMAP > _info;
}
$ gcc test.cpp
test.cpp: In function `void test()':
test.cpp:10: non-template type `RESULT' used as a template
test.cpp:10: ISO C++ forbids declaration of `_info' with no type
The extra <LMAP> is redundant here. This compiles OK:
#include <vector>
void test ()
{
typedef int LMAP; // for testing
typedef std::vector< LMAP > RESULT;
RESULT _info;
}
Wow, another success. It made it through the first four or five files without a hitch, then it ran into smysql.cpp and the horror began. I had a page-length and a half of errors, or so. So, I figured something out. If WhiteKnight downloaded the codebase, and it worked fine for him using Dev-CPP then I must be doin' something wrong (aside from using Cygwin, that is). So, seeing as I already have Dev-CPP I was hopin' perhaps WhiteKnight might be willing to give me some basic directions on how to actually compile properly with the program, because I'm always getting little issues with "this doesn't point to that" and "this file included by this file doesn't know what the hell that is" and all that fun stuff.... So.. Thank again for a large chunk of help, now I just need to use Dev-CPP it appears..
Just post your errors here. It shouldn't be hard to compile in Dev. Just make sure you downloaded a MySQL package and link in the mysql library (along with crypt (for my testing purposes i just modified it to not use crypt) and wsock32 ).
Also, make sure you define WIN32 so the preprocessor will make the correct changes.
Beyond that just change your connection info for your local mysql stuffs and you should be all set.
On another note, you will need to make a character and manually give yourself hte admin group. There is no way to do it in game.
The base, besides the minor defects, seems quite stable and easily expandible.
Thanks for your coninued help, WhiteKnight. Unfortunately, I don't know how to do any of that with Dev-CPP, though I can puzzle most of it out with Cygwin given enough time.
Anyways, the error ouput is too large to be posted here in all at once, since there's a 6000 character limit. I'll post a large portion this time, and the last of it in the next post.
I believe the instantiation errors are the reason I stopped trying to compile on Cygwin. Sorry about that, but I'm really not sure what to do about them.
Asking the original programmer would probably shed some light on these things. His e-mail was in the readme I to believe.
SQL problems aside( Cygwin has no direct support for it ) the STL problems here are not restricted to just this base.
Quote:
Compiling o/imc.o....
/usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/bits/stl_list.h: In function `void imcban(char_data*, std::string)':
/usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/bits/stl_list.h:435: warning: '__p' might be used uninitialized in th
is function
make[1]: *** [o/imc.o] Error 1
I get this when trying to compile my C++ code in Cygwin as well so whatever the issue is is either something we're all doing wrong or a bug in Cygwin's version of the STL.
Hey, sorry I've been M.I.A. for so long. I was busy for awhile with transitioning to a new job, and so haven't kept up to date with alot of stuff... Also had to format my computer.. Anyways, I re-installed my Dev-C++ and my Cygwin and downloaded, but didn't install, a copy of Code:Blocks and some other Dev-C++ variant...
I went to email Rendelven about help with porting the code over to be more stable on a Win-system.. Unfortunately his webpage seems to be down.. I'm hoping WhiteKnight might be able to post/email me a description of what he had to do to disable the crypt function (I don't think it's really necessary at this early of a phase) because it's just about the only error holding me back from compiling this codebase under Dev-C++... Well, here's hopin'..
Thanks for your continued assistance and advice, and just for clarification I do still intend to email Rendelven with my issues and seek his assistance as well, but I'd really help if I could get some input from here as well..
Well, I haven't heard from WhiteKnight just yet, but I think I managed to contain the Crypt function and so I was able to -almost- compile in Dev-C++ again.. The issue I am now having seems to be related to mysql_com.h, (It's a DevPack Include I downloaded somewhere) on lines 299 and line 300. I can't post the error or the file itself here just yet because I am not at home. However, I can comment out a line (It doesn't seem to matter which I comment out, the other one stays as an error.) but then if I comment out both, I get Linker Errors. I'm assuming Linker Errors are a step backwards from where I was just a few moments before. Anyways, I will post the Error and the contents of the file on the forum later this afternoon.
For the time being, could someone define a Linker Error to me?
Thank you, in advance, for whatever help you can provide.
Link errors are when everything compiles correctly, but some functions are not actually found. For example,
extern int i; i = 3;
will produce a link error in isolation, but not a compile error. This is because the compile is satisfied that the code is syntactically correct. But the linker needs to find the memory allocated for 'i' before assigning anything to it.
More common errors are when .o files aren't given to the linker, when the .o file in question contains a whole bunch of function definitions.
Well, I don't know if I'd call it a good thing... :) Sometimes link errors can be harder to figure out than syntax errors. With a syntax error it can tell you exactly what's going on. But with a link error all it can say is "symbol not found", or "duplicate symbol". It gets especially difficult when you have to deal with linking several libraries together, all of which link in statically different versions of the C runtime library (this is mainly a problem on Windows).
/*
The following function is not meant for normal usage
Currently it's used internally by manager.c
*/
struct sockaddr;
int my_connect(my_socket s, const struct sockaddr *name, unsigned int namelen,
unsigned int timeout);
Line 299 starts with INT and Line 300 starts with UNSIGNED
Those are from MySql_Com.H which comes from some BloodShed Dev-CPP update I downloaded... Now, here is the only errors remaining between me and a successful compile of Avatar.CPP;
Line 299 - 'SOCKET' was not declared in this Scope
Line 299 - expected primary-expression before "const"
Line 299 - expected primary-expression before "unsigned"
Line 300 - expected primary-expression before "unsigned"
Line 300 - intializer expression list treated as compound expression
The only one of those I even vaguely understand is the first one about a socket, but I don't see where it's having that issue... Well, I want to try and avoid pasting the contents of that entire file here since it's over 300 lines long.. But I'll have to see what all info you guys need to help me out.
On a positive note, I managed to make small contact with Rendelven the coder, but he is "Away" right now, so I can't expect any answers.
I don't really know, actually. I just suspect that it's been defined to equal SOCKET, and you haven't included the winsock header files. It's just a random guess, really.
Actually, we're looking for the definition of my_socket, which is probably defined as being SOCKET, and if SOCKET isn't defined before my_socket, my_socket will not resolve to a useful type...
Err.. Sorta, Ksilyan. I understand the logic of what you're saying. That if SOCKET isn't defined before it's called upon, that's what's causing the error.. But I'm not finding any lines like that, except maybe this one that I commented out earlier to get rid of errors;
// my_socket fd; /* For Perl DBI/dbd (Using Windows, Added By Slime)*/
unsigned long max_packet,max_packet_size;
unsigned int pkt_nr,compress_pkt_nr;
unsigned int write_timeout, read_timeout, retry_count;
int fcntl;
my_bool compress;
/*
The following variable is set if we are doing several queries in one
command ( as in LOAD TABLE ... FROM MASTER ),
and do not want to confuse the client with OK at the wrong time
*/
unsigned long remain_in_buf,length, buf_length, where_b;
unsigned int *return_status;
unsigned char reading_or_writing;
char save_char;
my_bool no_send_ok;
/*
Pointer to query object in query cache, do not equal NULL (0) for
queries in cache that have not stored its results yet
*/
#endif
I'm shootin' an email to Valiant_Dragon@Yahoo.Com (The Codebase Maker) right now to ask him a few questions as well, but I'm guessin' it could be awhile before he gets back in touch. He seems to be a rather busy person.
I apologize for my website being down. I host it on my own computer and occasionally take it down here and there.
The 'crypt' problem is the same problem every other MUD has. You must have crypt installed correctly on your machine for it to work, or you could comment it out and not have encrypted passwords.
The MySQL problem, however, was my fault. :) I believe Nick got it correct with pointing out that you didn't need the redundant RESULT. You could just do this:
std::vector< LMAP > _info;
I notice you seem to be trying to use the MFC Socket class. If you will look in socket.h/socket.cpp you will see that I have my own SocketServer and Socket class defined.
With the 2 errors above properly fixed and MySQL properly installed you shouldn't have any problems compiling the code.
The problem is, in fact, that SOCKET is not defined when my_socket is defined, which is defined as SOCKET. The headers and #ifdefs that come with Dev-C++ can be kind of screwy sometimes. This is especially true for some of the downloadable packages. Check to make sure that SOCKET is, in fact, being defined in winsock.h, and that winsock.h is included in mysql_com.h.
Or you could do another hackish approach and merely redefine my_socket to u_int or related.
Oh, nice little base by the way. It was just the thing I was looking for (that is, a Socketmud of the C++ world).
As I said before, I don't use any of the native winsock API for handling sockets. I simply use BSD sockets and just initialize winsock. You should not have to use SOCKET.
You will have to include the winsock library to your Dev-C++ project. As well as the crypt and mysql libraries. I haven't worked with Dev-C++ in a while so I'm not sure exactly how to do it. I may open it up later as I recently got a Windows box and see if I can get it running for you windows folk. :)
If you download the source and make the needed change in smysql.h, and include the correct libraries - what errors do you have?
I'm a -very- unlearned coder. I wouldn't know how to do that. Right now, I've learned most of the definitions of the tags used in C/C++ I don't actually have experience coding yet. That I'm saving for after my next semester at school, and I intend to rely heavily on a friend who codes.