| |

VerySource

 Forgot password?
 Register
Search
Author: rustler

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

 Invalid IP Address

 Author| Post time: 2020-8-8 23:30:02
| Show all posts
TO:orangedj

Shouldn't there be spaces? ? ?

TO: OTHER

The path should be correct, because if you randomly specify a path, the error prompt will be different. Says that MYSQL.H cannot be found

Thank you for your support. I went on a business trip two days ago.
Reply

Use magic Report

1

Threads

4

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 Invalid IP Address

 Author| Post time: 2020-8-11 20:00:01
| Show all posts
Top yourself! ! !
Reply

Use magic Report

0

Threads

78

Posts

29.00

Credits

Newbie

Rank: 1

Credits
29.00

 China

Post time: 2020-8-11 20:30:02
| Show all posts
Example of operating MySql with C

mysql_c_exam.c
  
  #Include <stdio.h>
  #Include <mysql.h>
  Int main(char **args)
  {
   MYSQL_RES *query_result;
   MYSQL_ROW row;
   MYSQL *db_handle, mysql;
   int query_error;
   mysql_init(&mysql);
   db_handle=mysql_real_connect(&mysql, "localhost", "root", "12345678", "crm", 0, 0, 0);
   if(db_handle==NULL)
   {
   printf(mysql_error(&mysql));
   return 1;
  }
   query_error=mysql_query(db_handle, "select * from bargain");
   if(query_error!=0)
   {
   printf(mysql_error(db_handle));
   return 1;
  }
   query_result=mysql_store_result(db_handle);
   while((row=mysql_fetch_row(query_result))!=NULL)
   {
printf("%s %s %s\n",(row[0]?row[0]:"NULL"),(row[1]? row[1]:"NULL"),(row[2]? row [2]:"NULL"));
  }
   mysql_free_result(query_result);
   mysql_close(db_handle);
   return 0;
  }
  
   2) Compile
  [Cnscn@test mysql]$ gcc -o mysql_c_exam mysql_c_exam.c -I /usr/local/mysql/include/mysql -L /usr/local/mysql/lib/mysql -l mysqlclient -lz
  
  3) Execution
  [Cnscn@test mysql]$ ./mysql_c_exam
  1 060108-1901001 34342432
  2 060110-10001
  3 060118-101001 34342432222
  4 060118-1021013 3434sde
  5 060118-10210133 3434sded
  6 060118-10001 lkfgksdl2455
  7 060124-19001 dfgg555
  8 060124-11204 sdfsf
Reply

Use magic Report

0

Threads

78

Posts

29.00

Credits

Newbie

Rank: 1

Credits
29.00

 China

Post time: 2020-8-11 20:45:01
| Show all posts
Note that when compiling:
  cc -o test test.c [libmysqlclient.a] -g ...

To write this library...
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-8-11 22:15:01
| Show all posts
http://blog.csdn.net/Radiant/archive/2006/11/23/1409245.aspx

The landlord has a look at this. This is how I used devcpp to connect to mysql under win not long ago. I hope it will be useful to you.
Reply

Use magic Report

1

Threads

4

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 Invalid IP Address

 Author| Post time: 2020-8-16 09:30:01
| Show all posts
Thanks for the method upstairs!

It is ready to run.
It just doesn't work under cygwin, and the path of lib doesn't know how to do it, nor do it. Maybe it should be no problem under linux.

Thank you all! Give points first.
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-9-5 08:45:01
| Show all posts
Thanks for the 13th floor!
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