code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
| //
// to compile this program on the csp machines
//
// gcc mysql_capi.c -o mysql_capi -lmysqlclient
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <mysql/mysql.h>
#define MYSQL_HOST "192.168.1.1" // database server name
#define MYSQL_DB "doelsparen" // database name
#define MYSQL_USERID "root" // database user id
#define MYSQL_PASSWD "" // userid password
#define MYSQL_TABLE "doelsparen" // table name
#define PROGRAM_HEADER "<H1>MySQL C-API Example Query Results</H1>\n"
// This is not the best or safest way to process field forms in C since
// sscanf is unsage. It is used here only to simplify the example
int main() {
MYSQL mysql;
MYSQL_RES *result;
MYSQL_ROW row;
unsigned int num_fields;
int record_count;
char query_str[100];
char target_petname[50];
#ifndef LINUX
mysql_init(&mysql);
#endif
if (!mysql_connect(&mysql,MYSQL_HOST,MYSQL_USERID,MYSQL_PASSWD))
{
printf(PROGRAM_HEADER);
printf("Failed to connect to database: Error: %s\n",mysql_error(&mysql));
return 0;
}
if (mysql_select_db(&mysql,MYSQL_DB)) {
printf(PROGRAM_HEADER);
printf("Failed to select table: Error: %s\n",mysql_error(&mysql));
mysql_close(&mysql);
return 0;
}
strcpy(query_str,"SELECT * FROM doelen WHERE id = 606638504");
mysql_query(&mysql,query_str);
result = mysql_use_result(&mysql);
record_count = 0;
num_fields = mysql_num_fields(result);
while ((row = mysql_fetch_row(result)))
{
unsigned long *lengths = mysql_fetch_lengths(result);
printf("%.*s %.*s\n",
(int) lengths[0], row[0] ? row[0] : "NULL",
(int) lengths[1], row[1] ? row[1] : "NULL");
record_count++;
}
if (record_count == 0) {
printf("No records matched.\n\n");
}
mysql_close(&mysql);
return 0;
} |
deze probeer ik te compilen met
gcc -o test test_mysql.c
maar dan zegt hij dat hij mysql/mysql.h niet kan vinden
wanneer ik dit pad volledig maak /usr/local/include/mysql/mysql.h
dan klaagt hij nog steeds over
code:
1
2
3
4
5
6
7
8
9
10
11
12
| /var/tmp//ccAsK7Ri.o(.text+0x1e): undefined reference to `mysql_init' /var/tmp//ccAsK7Ri.o(.text+0x3c): undefined reference to `mysql_connect' /var/tmp//ccAsK7Ri.o(.text+0x65): undefined reference to `mysql_error' /var/tmp//ccAsK7Ri.o(.text+0x8f): undefined reference to `mysql_select_db' /var/tmp//ccAsK7Ri.o(.text+0xb8): undefined reference to `mysql_error' /var/tmp//ccAsK7Ri.o(.text+0xd8): undefined reference to `mysql_close' /var/tmp//ccAsK7Ri.o(.text+0x10d): undefined reference to `mysql_query' /var/tmp//ccAsK7Ri.o(.text+0x11f): undefined reference to `mysql_use_result' /var/tmp//ccAsK7Ri.o(.text+0x140): undefined reference to `mysql_num_fields' /var/tmp//ccAsK7Ri.o(.text+0x157): undefined reference to `mysql_fetch_row' /var/tmp//ccAsK7Ri.o(.text+0x17c): undefined reference to `mysql_fetch_lengths' /var/tmp//ccAsK7Ri.o(.text+0x235): undefined reference to `mysql_close' |
als ik het dan probeer met
-bash-2.05b$ gcc mysql_test.c -o test -l mysqlclient
dan:
/usr/bin/ld: cannot find -lmysqlclient
mysql.h bestaat wel, mysql draaid ook al perfect icm. php en apache.
ook mysql323-client is geinstalleerd.
toen dacht ik nog
-bash-2.05b$ gcc mysql_test.c -o test -l mysql323-client
maar ook dan:
/usr/bin/ld: cannot find -lmysqlclient
Iemand enig idee ?
--EDIT--
FreeBSD 5.0
[ Voor 6% gewijzigd door xychix op 10-04-2003 21:57 ]
Every failure offers you a new opportunity! | Lokatie database|GoT - Notepad