Здравствуйте. Стоит система FreeBSD.
Сейчас разбираюсь с MySQL.
Пишу свой модуль для netgraph. Пытаюсь подключиться к БД.
Весь код программы приводить не буду, приведу только код ответственный за подключение к БД:MYSQL *pdb;
char *server ="localhost";
char *user = "user";
char *password = "pass";
char *database ="base";
...
pdb = mysql_init(NULL);
if (!mysql_real_connect (pdb,server,user,password,database,0,NULL,0))
{printf("ERROR");
}
...
Компиляция проходит без проблем.
make -C /usr/src/sys/modules/netgraph/
===> ip(all)
Warning: Object directory not changed from original /usr/src/sys/modules/netgraph/ip
@ -> /usr/src/sys
machine -> /usr/src/sys/i386/include
:> opt_netgraph.h
cc -O2 -pipe -fno-strict-aliasing -Werror -D_KERNEL -DKLD_MODULE -nostdinc -I. -I@ -I@/contrib/altq -finline-limit=8000 --param inline-unit-growth=100 --param large-function-growth=1000 -fno-common -mno-align-long-strings -mpreferred-stack-boundary=2 -mno-mmx -mno-3dnow -mno-sse -mno-sse2 -mno-sse3 -ffreestanding -fstack-protector -std=iso9899:1999 -fstack-protector -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Winline -Wcast-qual -Wundef -Wno-pointer-sign -fformat-extensions -c /usr/src/sys/modules/netgraph/ip/../../../netgraph/ng_ip.c
cc -O2 -pipe -fno-strict-aliasing -Werror -D_KERNEL -DKLD_MODULE -nostdinc -I. -I@ -I@/contrib/altq -finline-limit=8000 --param inline-unit-growth=100 --param large-function-growth=1000 -fno-common -mno-align-long-strings -mpreferred-stack-boundary=2 -mno-mmx -mno-3dnow -mno-sse -mno-sse2 -mno-sse3 -ffreestanding -fstack-protector -std=iso9899:1999 -fstack-protector -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Winline -Wcast-qual -Wundef -Wno-pointer-sign -fformat-extensions -c /usr/src/sys/modules/netgraph/ip/../../../net/slcompress.c
ld -d -warn-common -r -d -o ng_ip.kld ng_ip.o slcompress.o
:> export_syms
awk -f /usr/src/sys/modules/netgraph/ip/../../../conf/kmod_syms.awk ng_ip.kld export_syms | xargs -J% objcopy % ng_ip.kld
ld -Bshareable -d -warn-common -o ng_ip.ko ng_ip.kld
objcopy --strip-debug ng_ip.ko
При попытки загрузки модуля пишется ошибка:
link_elf: symbol mysql_init undefined.
Если в
cc -O2 -pipe -fno-strict-aliasing -Werror -D_KERNEL -DKLD_MODULE -nostdinc -I. -I@ -I@/contrib/altq -finline-limit=8000 --param inline-unit-growth=100 --param large-function-growth=1000 -fno-common -mno-align-long-strings -mpreferred-stack-boundary=2 -mno-mmx -mno-3dnow -mno-sse -mno-sse2 -mno-sse3 -ffreestanding -fstack-protector -std=iso9899:1999 -fstack-protector -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Winline -Wcast-qual -Wundef -Wno-pointer-sign -fformat-extensions -c /usr/src/sys/modules/netgraph/ip/../../../netgraph/ng_ip.c
добавить -L/usr/local/lib/mysql -lmysqlclient, то при компиляции пишет:
cc: -lmysqlclient: linker input file unused because linking not done
Подскажите, как правильно подключить библиотеку libmysqlclient и нужно ли еще подключать какие-нибудь библиотеки.