| |

VerySource

 Forgot password?
 Register
Search
View: 1978|Reply: 16

It is also a problem of C operation MYSQL: undefined reference to '_mysql_init' etc.

[Copy link]

1

Threads

4

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

Post time: 2020-1-6 17:30:01
| Show all posts |Read mode
After reading some old posts, but still can't get it, always prompt:
undefined reference to '_mysql_init'
undefined reference to '_mysql_real_connection'
undefined reference to '_mysql_error'
undefined reference to '_mysql_real_query'
...
and many more
The environment I use is:
WINDOWS XP SP2
cygwin
gcc3.4.4
MYSQL is Windows version 5.0
Works fine with JAVA.

My compilation is:
gcc -o main.exe main.c -I / usr / include / mysql -lmysqlclient

I have COPY the include file under mysql to / usr / include / mysql
mysqlclient.lib under lib / opt is also COPY to / usr / lib.

Please give me some advice. Thank you very much!
Here is the source code


The source code is from another post of COPY
#include <mysql / mysql.h>
#include <stdio.h>

int main () {
   MYSQL * mysql;
   MYSQL_RES * res;
   MYSQL_ROW row;
   char * query;
   int t, r;

   mysql_init (mysql);
   if (! mysql_real_connect (mysql, "localhost", "root",
        "loveyou", "spider", 0, NULL, 0))
   {
       printf ("Error connecting to database:% s\n", mysql_error (mysql));
   }
   else printf ("Connected ...\n");

   query = "select * from spider_work_unsite";

   t = mysql_real_query (mysql, query, (unsigned int) strlen (query));
   if (t)
   {
      printf ("Error making query:% s\n",
              mysql_error (mysql));
   }
   else printf ("Query made ...\n");
   res = mysql_use_result (mysql);
   for (r = 0; r <= mysql_field_count (mysql); r ++) {
           row = mysql_fetch_row (res);
           if (row <0) break;
           for (t = 0; t <mysql_num_fields (res); t ++) {
                   printf ("% s", row [t]);
           }
           printf ("\n");
   }
   mysql_close (mysql);
}
Reply

Use magic Report

0

Threads

36

Posts

13.00

Credits

Newbie

Rank: 1

Credits
13.00

 China

Post time: 2020-1-7 13:15:01
| Show all posts
The path to the library could not be found, or your include path is incorrect. Please check if your include path includes your include file
Reply

Use magic Report

0

Threads

41

Posts

28.00

Credits

Newbie

Rank: 1

Credits
28.00

 China

Post time: 2020-1-17 15:18:01
| Show all posts
I have COPY the include file under mysql to / usr / include / mysql
mysqlclient.lib under lib / opt is also COPY to / usr / lib.
How could the windows directory look like this? What about the drive letter?
Obviously the directory settings are wrong
Reply

Use magic Report

0

Threads

18

Posts

9.00

Credits

Newbie

Rank: 1

Credits
9.00

 China

Post time: 2020-1-29 08:54:01
| Show all posts
Let me show you the way. ?
Reply

Use magic Report

0

Threads

63

Posts

43.00

Credits

Newbie

Rank: 1

Credits
43.00

 China

Post time: 2020-3-11 17:30:01
| Show all posts
-I / usr / include / mysql There are spaces in the middle? ?
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-3-23 10:30:01
| Show all posts
Or path problem
Reply

Use magic Report

0

Threads

2

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-7-15 18:45:01
| Show all posts
-I /usr/include mysql
-L /usr/lib/mysql
-lmysqlclient
Reply

Use magic Report

0

Threads

2

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-7-15 19:00:01
| Show all posts
Library file not found
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-7-16 23:15:01
| Show all posts
Feeling is a matter of path
Reply

Use magic Report

0

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-7-20 23:30:01
| Show all posts
1. The following is the result of studying mysql 5.0.22, describing and using standard c++ performance
Shows the process of simple operation of the database using MySQLC API functions;
The example program is debugged on VC6 (VC7.1) + windows 2000;
The example program was debugged on red hat linux 9, red fc6

http://blog.csdn.net/kill31/archive/2006/12/14/1443031.aspx
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list