PDA

View Full Version : Compiling mysql on CENTOS



Ni3ls
21st March 2016, 12:28
Hi all,

Im trying to setup async mysql connection with libcod. However, no matter which github I use, I wont compile the mysql functions.
Error using iznogods github (https://github.com/iznogod/libcod)


##### COMPILE GSC_MYSQL.CPP #####
cc1plus: error: unrecognized command line option "-std=gnu++11"

So no mysql is not compiled



[olger@static libcod_iznogod]$ ./doit.sh cod2_1_0
##### COMPILE cod2_1_0 LIBCOD.CPP #####
##### COMPILE cod2_1_0 GSC.CPP #####
##### COMPILE cod2_1_0 GSC_PLAYER.CPP #####
##### COMPILE cod2_1_0 GSC_UTILS.CPP #####
##### LINK libcod2_1_0.so #####



using Voron00 github (https://github.com/voron00/libcod)

##### WARNING: MYSQL libs not found, MYSQL compilation skipped #####


using kungs github (https://github.com/kungfooman/libcod)


##### COMPILE JAVA_EMBED.C #####
Ignore java_embed.c, because java_enable==false (e.g. because the dir $java_jdk=/root/helper/openjdk8 does not exist)




##### COMPILE cod2_1_0 LIBCOD.CPP #####
##### COMPILE cod2_1_0 GSC.CPP #####
##### COMPILE cod2_1_0 GSC_PLAYER.CPP #####
##### COMPILE cod2_1_0 GSC_UTILS.CPP #####
##### LINK libcod2_1_0.so #####
mysql not compiled?!

using mitchs github (https://github.com/M-itch/libcod)

##### WARNING: Skipped java_embed.c because OpenJDK 8 does not exist #####



./doit.sh cod2_1_0
##### COMPILE cod2_1_0 LIBCOD.CPP #####
##### COMPILE cod2_1_0 GSC.CPP #####
##### COMPILE cod2_1_0 GSC_PLAYER.CPP #####
##### COMPILE cod2_1_0 GSC_UTILS.CPP #####
##### LINK libcod2_1_0.so #####
objects_base/cracking.opp: could not read symbols: File in wrong format
collect2: ld returned 1 exit status


What the hell is going on?

IzNoGoD
21st March 2016, 12:42
The java crap can be ignored, was a thingy kung tried to add long ago but never did

voron00
21st March 2016, 13:05
I've recently added some sort of mysql detection (Since i moved my VPS to Arch Linux and the do not provide multilib mysql packages) which checks the existanse of libmysqlclient.so.18 inside /usr/lib and if its not found, mysql compilation will be skipped, if you sure you have mysql installed, just force it then, e.g set mysql_enable="true" in doit.sh after lib checks (e.g line 49)

Ni3ls
21st March 2016, 13:17
I've recently added some sort of mysql detection (Since i moved my VPS to Arch Linux and the do not provide multilib mysql packages) which checks the existanse of libmysqlclient.so.18 inside /usr/lib and if its not found, mysql compilation will be skipped, if you sure you have mysql installed, just force it then, e.g set mysql_enable="true" in doit.sh after lib checks (e.g line 49)

It did compile, but I get segmentation fault by startup. No gametype or map is set at this point.


(gdb) bt
#0 0x00a6bf1d in __memcpy_ssse3_rep () from /lib/libc.so.6
#1 0xf76cda9a in gsc_utils_init ()
from /home/olger/HIGHJUMP/libcod2_1_0_voron_v2.so
#2 0xf76d1af9 in cCallOfDuty2Pro::cCallOfDuty2Pro() ()
from /home/olger/HIGHJUMP/libcod2_1_0_voron_v2.so
#3 0xf76d169b in lib_load () from /home/olger/HIGHJUMP/libcod2_1_0_voron_v2.so
#4 0xf76d1b6d in __do_global_ctors_aux ()
from /home/olger/HIGHJUMP/libcod2_1_0_voron_v2.so
#5 0xf76c46e4 in _init () from /home/olger/HIGHJUMP/libcod2_1_0_voron_v2.so
#6 0x0092101f in _dl_init_internal () from /lib/ld-linux.so.2
#7 0x0091288f in _dl_start_user () from /lib/ld-linux.so.2
(gdb)

voron00
21st March 2016, 14:41
Dunno but seems unrelated to mysql, was there any other errors/warnings durning compilation?

Ni3ls
21st March 2016, 14:44
Dunno but seems unrelated to mysql, was there any other errors/warnings durning compilation?


[olger@static libcod_voron]$ ./doit.sh base
##### COMPILE GSC_ASTAR.CPP #####
##### COMPILE GSC_MYSQL.CPP #####
##### COMPILE SERVER.C #####
##### COMPILE GSC_MEMORY.CPP #####
##### COMPILE CRACKING.CPP #####
##### COMPILE GSC_MATH.CPP #####
##### COMPILE JAVA_EMBED.C #####
##### WARNING: Skipped java_embed.c because /root/helper/openjdk8 does not exist #####
[olger@static libcod_voron]$ ./doit.sh cod2_1_0
##### COMPILE cod2_1_0 LIBCOD.CPP #####
##### COMPILE cod2_1_0 GSC.CPP #####
##### COMPILE cod2_1_0 GSC_PLAYER.CPP #####
##### COMPILE cod2_1_0 GSC_UTILS.CPP #####
##### LINK libcod2_1_0.so #####
[olger@static libcod_voron]$

Thats all.



BTW: Im using this method to compile
http://killtube.org/showthread.php?2036-Help-me-pls)))&p=10702&viewfull=1#post10702

voron00
21st March 2016, 15:22
Does it present in build from kung's or Mitch's repo too or just in mine?

Ni3ls
21st March 2016, 15:34
In all the other ones I also got segmentation fault. And they were even build without mysql.

Mitch
21st March 2016, 17:49
It did compile, but I get segmentation fault by startup. No gametype or map is set at this point.


(gdb) bt
#0 0x00a6bf1d in __memcpy_ssse3_rep () from /lib/libc.so.6
#1 0xf76cda9a in gsc_utils_init ()
from /home/olger/HIGHJUMP/libcod2_1_0_voron_v2.so
#2 0xf76d1af9 in cCallOfDuty2Pro::cCallOfDuty2Pro() ()
from /home/olger/HIGHJUMP/libcod2_1_0_voron_v2.so
#3 0xf76d169b in lib_load () from /home/olger/HIGHJUMP/libcod2_1_0_voron_v2.so
#4 0xf76d1b6d in __do_global_ctors_aux ()
from /home/olger/HIGHJUMP/libcod2_1_0_voron_v2.so
#5 0xf76c46e4 in _init () from /home/olger/HIGHJUMP/libcod2_1_0_voron_v2.so
#6 0x0092101f in _dl_init_internal () from /lib/ld-linux.so.2
#7 0x0091288f in _dl_start_user () from /lib/ld-linux.so.2
(gdb)


CentOS doesn't like this function, but I have no idea why.


char* defaultweapon_mp = (char*)malloc(MAX_WEAPON_NAME_SIZE);
void gsc_utils_init() {
strcpy(defaultweapon_mp, "defaultweapon_mp");
defaultweapon_mp[strlen(defaultweapon_mp)] = '\0';
}

Edit: maybe try this:

strcpy(defaultweapon_mp, (char*)"defaultweapon_mp");

IzNoGoD
21st March 2016, 18:14
Confirmed starting without those 2 lines, but the fix suggested doesnt work.

It works fine without the gsc_utils_init though, so there's definitely a problem in there.

This works though:



#define MAX_WEAPON_IGNORE_SIZE 20
#define MAX_WEAPON_NAME_SIZE 32
char defaultweapon_mp[MAX_WEAPON_NAME_SIZE];
char ignoredWeapons[MAX_WEAPON_IGNORE_SIZE][MAX_WEAPON_NAME_SIZE];
int ignoredWeaponCount = 0;

void gsc_utils_init() {
strcpy(defaultweapon_mp, (char*)"defaultweapon_mp");
defaultweapon_mp[strlen(defaultweapon_mp)] = '\0';
}

void gsc_utils_free() {
//free(defaultweapon_mp);
}



Not sure if this fucks up anything anywhere else, please advise.

IzNoGoD
21st March 2016, 18:19
To follow up on the previous thing: the malloc() the the non-function space (outside of any function) returns a NULL-pointer.

The libcod code doesnt check for that, and as a result, the code will crash.

IzNoGoD
21st March 2016, 18:59
Better fix which follows http://stackoverflow.com/questions/16316902/malloced-variables-with-file-scope-c



#define MAX_WEAPON_IGNORE_SIZE 20
#define MAX_WEAPON_NAME_SIZE 32
char* defaultweapon_mp;
char ignoredWeapons[MAX_WEAPON_IGNORE_SIZE][MAX_WEAPON_NAME_SIZE];
int ignoredWeaponCount = 0;

void gsc_utils_init() {
if(defaultweapon_mp == NULL)
defaultweapon_mp = (char*)malloc(sizeof(char) * MAX_WEAPON_NAME_SIZE);
if(defaultweapon_mp == NULL)
printf("Failed to malloc defaultweapon_mp\n");
strcpy(defaultweapon_mp, (char*)"defaultweapon_mp");
defaultweapon_mp[strlen(defaultweapon_mp)] = '\0';
}

void gsc_utils_free() {
free(defaultweapon_mp);
}

Ni3ls
21st March 2016, 19:34
So it does now compile without any problems.
However, when I use the this script to setup mysql
https://killtube.org/showthread.php?1883-Asynchronous-mysql-queries&p=13719&viewfull=1#post13719

I get this error

unknown function: (file 'maps/mp/gametypes/_mysql.gsc', line 136)
mysql_close(mysql);
*


However, when I open gsc.ccp

#if COMPILE_MYSQL == 1
{"mysql_init" , gsc_mysql_init , 0},
{"mysql_real_connect" , gsc_mysql_real_connect , 0},
{"mysql_close" , gsc_mysql_close , 0},
{"mysql_query" , gsc_mysql_query , 0},
{"mysql_errno" , gsc_mysql_errno , 0},
{"mysql_error" , gsc_mysql_error , 0},
{"mysql_affected_rows" , gsc_mysql_affected_rows , 0},
{"mysql_store_result" , gsc_mysql_store_result , 0},
{"mysql_num_rows" , gsc_mysql_num_rows , 0},
{"mysql_num_fields" , gsc_mysql_num_fields , 0},
{"mysql_field_seek" , gsc_mysql_field_seek , 0},
{"mysql_fetch_field" , gsc_mysql_fetch_field , 0},
{"mysql_fetch_row" , gsc_mysql_fetch_row , 0},
{"mysql_free_result" , gsc_mysql_free_result , 0},
{"mysql_real_escape_string", gsc_mysql_real_escape_string, 0},
{"mysql_async_create_query", gsc_mysql_async_create_query, 0},
{"mysql_async_create_query_nosave", gsc_mysql_async_create_query_nosave, 0},
{"mysql_async_getdone_list", gsc_mysql_async_getdone_list, 0},
{"mysql_async_getresult_and_free", gsc_mysql_async_getresult_and_free, 0},
{"mysql_async_initializer" , gsc_mysql_async_initializer , 0},
{"mysql_reuse_connection" , gsc_mysql_reuse_connection , 0},
#endif

What can be the problem?

Ni3ls
21st March 2016, 19:52
Sorry for double post.
I added the fix of Iznogod to the github of Kungfooman and I can connect to my database :)
Thanks for all the help !