This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Yes, Mysql.mod again :/

Discussion of Eggdrop's code and module programming in C.
Post Reply
A
Aimar`
Voice
Posts: 8
Joined: Wed Aug 29, 2007 1:04 pm

Yes, Mysql.mod again :/

Post by Aimar` »

Hey guys, actually i read alot threads here about that mod, found way to fix mysql.h etc etc

got it compiled but with errors which makes it un-usefully ... when i try to use any binded mysql command in tcl my bot crashes with only that
•6:41PM• * NoF (aimar@xxx) Quit (Remote host closed the connection)

Nothin @ party line with bot ;/


Here is error code:

Code: Select all

make[2]: Entering directory`/home/aimar/eggdrop1.6.16/src/mod/mysql.mod'
gcc -pipe -fPIC -g -O2 -Wall -I. -I../../.. -I../../.. -I../../../src/mod -DHAVE_CONFIG_H   `mysql_config --cflags` -DMAKING_MODS -c .././mysql.mod/mysql.c
/bin/sh: line 1: mysql_config: command not found
In file included from ../mysql.mod/mysql_mod.h:32,
                 from ../mysql.mod/mysql.c:24:
../../../src/mod/module.h:190:1: warning: "list_delete" redefined
In file included from ../mysql.mod/mysql.c:24:
../mysql.mod/mysql_mod.h:31:1: warning: this is the location of the previous definition
../mysql.mod/mysql.c: In function `tcl_mysql_connect':
../mysql.mod/mysql.c:171: warning: passing arg 2 of `Tcl_AppendToObj' discards qualifiers from pointer target type
../mysql.mod/mysql.c: In function `tcl_mysql_query':
../mysql.mod/mysql.c:212: warning: passing arg 2 of `Tcl_AppendToObj' discards qualifiers from pointer target type
mv mysql.o ../
gcc -pipe -shared -nostartfiles -o ../../../mysql.so ../mysql.o -L/usr/lib -ltcl -lm -ldl -lnsl   `mysql_config --libs`
/bin/sh: line 1: mysql_config: command not found
touch ../../../mysql.so
make[2]: Leaving directory`/home/aimar/eggdrop1.6.16/src/mod/mysql.mod'

Any idea? plz help me asap it's really urgent
User avatar
rosc2112
Revered One
Posts: 1454
Joined: Sun Feb 19, 2006 8:36 pm
Location: Northeast Pennsylvania

Post by rosc2112 »

/bin/sh: line 1: mysql_config: command not found
A
Aimar`
Voice
Posts: 8
Joined: Wed Aug 29, 2007 1:04 pm

Post by Aimar` »

saw that too... but what that means?

command not found, so what i need? include additional libraries? or what?
User avatar
rosc2112
Revered One
Posts: 1454
Joined: Sun Feb 19, 2006 8:36 pm
Location: Northeast Pennsylvania

Post by rosc2112 »

Presumably it's an executable that comes with mysql, and it's not in your path. Figure out where it lives on your system and add the path to your environment (which, if you don't know how, is beyond the scope of this forum and I can only suggest googling help for your particular operating system.)
A
Aimar`
Voice
Posts: 8
Joined: Wed Aug 29, 2007 1:04 pm

Post by Aimar` »

ok, found mysql_config, included it in mysql.h and now it looks like that:

include lines in mysql_mod.h:

Code: Select all

#define list_delete egg_list_delete
#include "src/mod/module.h"
#undef list_delete
#include </usr/local/mysql/include/mysql/mysql.h>
#include </usr/local/mysql/bin/mysql_config>
Errors code

Code: Select all

gcc -pipe -fPIC -g -O2 -Wall -I. -I../../.. -I../../.. -I../../../src/mod -DHAVE_CONFIG_H   `mysql_config --cflags` -DMAKING_MODS -c .././mysql.mod/mysql.c
/bin/sh: line 1: mysql_config: command not found
In file included from ../mysql.mod/mysql_mod.h:32,
                 from ../mysql.mod/mysql.c:24:
../../../src/mod/module.h:190:1: warning: "list_delete" redefined
In file included from ../mysql.mod/mysql.c:24:
../mysql.mod/mysql_mod.h:31:1: warning: this is the location of the previous definition
In file included from ../mysql.mod/mysql_mod.h:35,
                 from ../mysql.mod/mysql.c:24:
/usr/local/mysql/bin/mysql_config:1:2: invalid preprocessing directive #!
/usr/local/mysql/bin/mysql_config:2:3: invalid preprocessing directive #Copyright
/usr/local/mysql/bin/mysql_config:4:3: invalid preprocessing directive #This
/usr/local/mysql/bin/mysql_config:5:3: invalid preprocessing directive #it
/usr/local/mysql/bin/mysql_config:6:3: invalid preprocessing directive #the
/usr/local/mysql/bin/mysql_config:7:3: invalid preprocessing directive #(
/usr/local/mysql/bin/mysql_config:9:3: invalid preprocessing directive #This
/usr/local/mysql/bin/mysql_config:10:3: invalid preprocessing directive #but
/usr/local/mysql/bin/mysql_config:11:3: invalid preprocessing directive #MERCHANTABILITY
/usr/local/mysql/bin/mysql_config:12:3: invalid preprocessing directive #GNU
/usr/local/mysql/bin/mysql_config:14:3: invalid preprocessing directive #You
/usr/local/mysql/bin/mysql_config:15:3: invalid preprocessing directive #along
/usr/local/mysql/bin/mysql_config:16:3: invalid preprocessing directive #Foundation
/usr/local/mysql/bin/mysql_config:18:3: invalid preprocessing directive #This
/usr/local/mysql/bin/mysql_config:19:3: invalid preprocessing directive #when
In file included from ../mysql.mod/mysql_mod.h:35,
                 from ../mysql.mod/mysql.c:24:
/usr/local/mysql/bin/mysql_config:22: warning: return type defaults to `int'
/usr/local/mysql/bin/mysql_config: In function `which':
/usr/local/mysql/bin/mysql_config:23: `IFS' undeclared (first use in this function)
/usr/local/mysql/bin/mysql_config:23: (Each undeclared identifier is reported only once
/usr/local/mysql/bin/mysql_config:23: for each function it appears in.)
/usr/local/mysql/bin/mysql_config:23: `save_ifs' undeclared (first use in this function)
/usr/local/mysql/bin/mysql_config:24: parse error before "for"
/usr/local/mysql/bin/mysql_config:41:3: invalid preprocessing directive #If
/usr/local/mysql/bin/mysql_config:42:3: invalid preprocessing directive #we
/usr/local/mysql/bin/mysql_config:43:3: invalid preprocessing directive #This
/usr/local/mysql/bin/mysql_config:44:3: invalid preprocessing directive #version
/usr/local/mysql/bin/mysql_config:55: `then' undeclared (first use in this function)
/usr/local/mysql/bin/mysql_config:65:12: missing binary operator
/usr/local/mysql/bin/mysql_config:109:42: missing terminating ' character
/usr/local/mysql/bin/mysql_config:65:1: unterminated #if
../mysql.mod/mysql.c:39: `mysql_start' undeclared (first use in this function)
../mysql.mod/mysql.c:39: initializer element is not constant
../mysql.mod/mysql.c:39: (near initialization for `mysql_table[0]')
../mysql.mod/mysql.c: In function `tcl_mysql_connect':
../mysql.mod/mysql.c:171: warning: passing arg 2 of `Tcl_AppendToObj' discards qualifiers from pointer target type
../mysql.mod/mysql.c: In function `tcl_mysql_query':
../mysql.mod/mysql.c:212: warning: passing arg 2 of `Tcl_AppendToObj' discards qualifiers from pointer target type
../mysql.mod/mysql.c: In function `which':
../mysql.mod/mysql.c:392: parse error at end of input
make[3]: *** [../mysql.o] Error 1
make[3]: Leaving Directory `/home/aimar/eggdrop1.6.16/src/mod/mysql.mod'
make[2]: *** [mysql.mod_so] Error 2
make[2]: Leaving Directory  `/home/aimar/eggdrop1.6.16/src/mod'
make[1]: *** [modules] Error 2
make[1]: Leaving Directory  `/home/aimar/eggdrop1.6.16'
make: *** [doofus] Error 2
/bin/sh: line 1: mysql_config: command not found

but few lines lower it uses it:
/usr/local/mysql/bin/mysql_config:19:3: invalid preprocessing directive #when
In file included from ../mysql.mod/mysql_mod.h:35,
from ../mysql.mod/mysql.c:24:

How to fix these weird errors?
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

Quick reply:
mysql_config is a bash-script designed to generate compiler-flags and such, and is most certainly not intended to be included using c preprocessing directives.
What you need todo, is update your path environment variable to include the location of mysql_config.


Further info (if you are interrested in the actual mechanics at work):
Taking a look at the output of your earlier post:
gcc -pipe -fPIC -g -O2 -Wall -I. -I../../.. -I../../.. -I../../../src/mod -DHAVE_CONFIG_H `mysql_config --cflags` -DMAKING_MODS -c .././mysql.mod/mysql.c
gcc is told to compile mysql.c. We have flags to tell gcc to use moderate optimization of code (-O2), aswell as multiple directives for include-paths (-I, where to look for .h-files to be included). There's also a few other directives, along with this:

Code: Select all

`mysql_config --cflags`
`` are shell-special characters, and behave pretty much like [] does in tcl, that is, execute whatever is inside, and replace the whole piece with whatever the command returns.
What then, is the output from mysql_config --cflags?

Code: Select all

[nml375@linux ~]$ mysql_config  --cflags
-I/usr/include/mysql -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -m32 -march=i386 -mtune=pentium4 -fasynchronous-unwind-tables -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fno-strict-aliasing
[nml375@linux ~]$
Output is taken from my system, and will most likely be slightly different on your system, but simply put, it contains additional compiler flags, specifying how you should compile mysql.c in order to work with the local mysql-libraries installed on the system.

In the end, on my system the final command run would be this:

Code: Select all

gcc -pipe -fPIC -g -O2 -Wall -I. -I../../.. -I../../.. -I../../../src/mod -DHAVE_CONFIG_H   -I/usr/include/mysql -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -m32 -march=i386 -mtune=pentium4 -fasynchronous-unwind-tables -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fno-strict-aliasing -DMAKING_MODS -c .././mysql.mod/mysql.c
NML_375
A
Aimar`
Voice
Posts: 8
Joined: Wed Aug 29, 2007 1:04 pm

Post by Aimar` »

Ok, so way to fix it is just an adding these compiler flags... but what if i get this:

Code: Select all

aimar@p17:~$ `mysql_config` --cflags
-bash: mysql_config: command not found
-bash: --cflags: command not found
aimar@p17:~$ locate mysql_config
/usr/local/mysql/bin/mysql_config
/usr/local/mysql/man/man1/mysql_config.1
aimar@p17:~$ /usr/local/mysql/bin/mysql_config --cflags
-I/usr/local/mysql/include/mysql
aimar@p17:~$ /usr/local/mysql/man/man1/mysql_config.1 --cflags
-bash: /usr/local/mysql/man/man1/mysql_config.1: Brak dostępu (No Access)
aimar@p17:~$ `/usr/local/mysql/bin/mysql_config --cflags`
-bash: -I/usr/local/mysql/include/mysql: Nie ma takiego pliku ani katalogu (No file or dir like this exist there)
aimar@p17:~$
important is this:
aimar@p17:~$ /usr/local/mysql/bin/mysql_config --cflags
-I/usr/local/mysql/include/mysql


No additional flags here ;/
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

Short answer, not the recommended solution:
Just add /usr/local/mysql/bin to your path setting.. just as simple as that. Doing it any other way is pretty much asking for trouble...

As for your results:

Code: Select all

aimar@p17:~$ `mysql_config` --cflags
-bash: mysql_config: command not found
-bash: --cflags: command not found
mysql_config is not located within your searchpath, and hence it is not found. Since the output is nothing, `mysql_config`is replaced with nothing, and the resulting commandline is --cflags. --cflags is not a command, and you get an error saying it was not found.

Code: Select all

aimar@p17:~$ locate mysql_config
/usr/local/mysql/bin/mysql_config
/usr/local/mysql/man/man1/mysql_config.1
You have located both the executable (mysql_config), and the manpage (mysql_config.1). Congrats. Now make proper use of them...

Code: Select all

aimar@p17:~$ /usr/local/mysql/bin/mysql_config --cflags
-I/usr/local/mysql/include/mysql
So, mysql_config tells you that header-files for libmyqsl are located at /usr/local/mysql/include/mysql. When properly set up, this line would automatically be inserted into the gcc commandline when compiling that module...

Code: Select all

aimar@p17:~$ /usr/local/mysql/man/man1/mysql_config.1 --cflags
-bash: /usr/local/mysql/man/man1/mysql_config.1: Brak dostępu (No Access)
mysql_config.1 is a manpage, it's not executable. Don't try to run it...

Code: Select all

aimar@p17:~$ `/usr/local/mysql/bin/mysql_config --cflags`
-bash: -I/usr/local/mysql/include/mysql: Nie ma takiego pliku ani katalogu (No file or dir like this exist there)
You run mysql_config --cflags with a proper path, and substitute all of it with the resulting code (-I/usr/local/mysql/include/mysql) and then try to execute that as a command. Not the way it's intended to be used...
NML_375
A
Aimar`
Voice
Posts: 8
Joined: Wed Aug 29, 2007 1:04 pm

Post by Aimar` »

Code: Select all

aimar@p17:~$ /usr/local/mysql/bin/mysql_config --cflags
-I/usr/local/mysql/include/mysql
So, mysql_config tells you that header-files for libmyqsl are located at /usr/local/mysql/include/mysql. When properly set up, this line would automatically be inserted into the gcc commandline when compiling that module...
Okies :)
Now the line from makefile looks like that:

Code: Select all

../mysql.o:
	$(CC) $(CFLAGS) $(CPPFLAGS) -I/usr/local/mysql/include/mysql -DMAKING_MODS -c $(srcdir)/mysql.c
	@rm -f ../mysql.o
	mv mysql.o ../
Where i placed "-I/usr/local/mysql/include/mysql" before was `mysql_config --cflags`

So ... i did it by way which u leaded me? :>

Doing make in eggdrop now and get this:

Code: Select all

gcc -pipe -fPIC -g -O2 -Wall -I. -I../../.. -I../../.. -I../../../src/mod -DHAVE_CONFIG_H   -I/usr/local/mysql/include/mysql -DMAKING_MODS -c .././mysql.mod/mysql.c
In file included from ../mysql.mod/mysql_mod.h:32,
                 from ../mysql.mod/mysql.c:24:
../../../src/mod/module.h:190:1: warning: "list_delete" redefined
In file included from ../mysql.mod/mysql.c:24:
../mysql.mod/mysql_mod.h:31:1: warning: this is the location of the previous definition
In file included from ../mysql.mod/mysql_mod.h:35,
                 from ../mysql.mod/mysql.c:24:
Lower is same [censored] as before (these preprociessing directives lines)

Shoot me if i'm doing smth wrong again :p
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

Can I say this any more clearer? Don't edit your makefile, get your path environment variable properly set!

Since you've pretty much messed around with most of the files, and seem unable to undo your previous mistakes (such as including the mysql_config executable using a preprocessing directive), I suggest you delete the source for that module entirely, get a fresh copy, unpack it, get your path set properly, do not touch any file whatsoever, and start all over...
NML_375
A
Aimar`
Voice
Posts: 8
Joined: Wed Aug 29, 2007 1:04 pm

Post by Aimar` »

Ok, as u know from yesterday env path to mysql_config is set correctly, mod compiled with some warnings ... but now i'm in point from which i started...

after i do any connection to mysql from bot it just die... but by diffrent way than in first post in this thread (•6:41PM• * NoF (aimar@xxx) Quit (Remote host closed the connection) )


Now it is (Connection closed) .. not remote host closed...

Logs from compiling:

Code: Select all

make[2]: Wchodzę katalog `/home/aimar/eggdrop1.6.16/src/mod/mysql.mod'
gcc -pipe -fPIC -g -O2 -Wall -I. -I../../.. -I../../.. -I../../../src/mod -DHAVE_CONFIG_H   `mysql_config --cflags` -DMAKING_MODS -c .././mysql.mod/mysql.c
In file included from /home/aimar/eggdrop1.6.16/src/mod/mysql.mod/mysql_mod.h:32,
                 from ../mysql.mod/mysql.c:24:
../../../src/mod/module.h:190:1: warning: "list_delete" redefined
In file included from ../mysql.mod/mysql.c:24:
/home/aimar/eggdrop1.6.16/src/mod/mysql.mod/mysql_mod.h:31:1: warning: this is the location of the previous definition
../mysql.mod/mysql.c: In function `tcl_mysql_connect':
../mysql.mod/mysql.c:171: warning: passing arg 2 of `Tcl_AppendToObj' discards qualifiers from pointer target type
../mysql.mod/mysql.c: In function `tcl_mysql_query':
../mysql.mod/mysql.c:212: warning: passing arg 2 of `Tcl_AppendToObj' discards qualifiers from pointer target type
mv mysql.o ../
gcc -pipe -shared -nostartfiles -o ../../../mysql.so ../mysql.o -L/usr/lib -ltcl -lm -ldl -lnsl   `mysql_config --libs`
touch ../../../mysql.so

So just warnings, but cuz of them can't connect to db :/
Post Reply