Autor Beitrag
erti
Hält's aus hier
Beiträge: 1



BeitragVerfasst: Fr 25.12.15 23:11 
Hallo!

habe ein problem mit dem mysql libs
Zitat:
root@intern:/home/erti/c#/testmysqlcon# gcc -I/usr/include/mysql -o mysqltest main.c
/tmp/ccdEYkWu.o: In function `main':
main.c:(.text+0x10): undefined reference to `mysql_get_client_info'
collect2: error: ld returned 1 exit status

ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
#include <stdio.h>
#include <my_global.h>
#include <mysql.h>

int main(int argc, char **argv)
{
    printf("MySQL client version: %s\n", mysql_get_client_info());
}

Zitat:
Versionen
root@intern:/home/erti/c#/testmysqlcon# ld --version
GNU ld (GNU Binutils for Debian) 2.22
Copyright 2011 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) a later version.
This program has absolutely no warranty.
root@intern:/home/erti/c#/testmysqlcon# gcc --version
gcc (Debian 4.7.2-5) 4.7.2
Copyright (C) 2012 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

root@intern:/home/erti/c#/testmysqlcon# mysql_config --libs
-L/usr/lib/x86_64-linux-gnu -lmysqlclient -lpthread -lz -lm -lrt -ldl

werd da leider nicht schlau draus, wäre Super wenn Ihr mir weiterhelfen könntet!
LG.Patrick

Moderiert von user profile iconTh69: Code-Tags hinzugefügt
Moderiert von user profile iconTh69: Quote-Tags hinzugefügt.
Th69
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Moderator
Beiträge: 4764
Erhaltene Danke: 1052

Win10
C#, C++ (VS 2017/19/22)
BeitragVerfasst: Sa 26.12.15 11:28 
Hallo,

du mußt dem Linker (ld) noch die MySQL-Library mitgeben. Dies geht mit dem gcc-Parameter '-l' (und evtl. noch den Pfad dahin mit '-L'):
ausblenden Quelltext
1:
2:
// Beispiel
gcc -I/usr/include/mysql -L/usr/libs/mysql -lmysql -o mysqltest main.c

Besser ist es aber, du benutzt ein makefile, s. z.B. GCC and Make - Compiling, Linking and Building C/C++ Applications (unter "2. GNU Make").