zoukankan      html  css  js  c++  java
  • fatal error: mysql.h: No such file or directory

      转自:http://tangmingjie2009.iteye.com/blog/1521088


          我是在Ubuntu系统下测试的

          此系统下,mysql安装: apt-get install mysql-server 等了有10多分钟

          然后又装了mysql-client: apt-get install mysql-client

          还不够还需要mysql的开发包: apt-get install libmysql++

         没有权限的话sudo 你懂的

          敲下代码

    C代码   收藏代码
    1.   
    2.   
    3. int main(void){  
    4.   
    5.         if(!conn_ptr){  
    6. "mysql_init failed  ");  
    7. return  EXIT_FAILURE;  
    8.   
    9. "localhost","root","111111","mysql",0,NULL,0);  
    10.         if(conn_ptr){  
    11. "Connection success ");  
    12. else{  
    13. "Connection failed ");  
    14.   
    15.         return EXIT_SUCCESS;  
    16. }  

     编译

    gcc -o testmysql testmysql.c

    Java代码   收藏代码
    1. compilation terminated.  

     

    然后修改gcc -o testmysql testmysql.c  -I/usr/include/mysql/

    C代码   收藏代码
    1. testmysql.c:(.text+0x11): undefined reference to `mysql_init'  
    2. testmysql.c:(.text+0xc0): undefined reference to `mysql_close'  
    3. collect2: ld returned 1 exit statu  

     

    最后修改

    C代码   收藏代码
    1. gcc -o testmysql testmysql.c -I/usr/include/mysql/ -lmysqlclient -Wall -g  

    成功

    作者:柒月
    Q群 :2122210(嵌入式/机器学习)
  • 相关阅读:
    线程唤醒
    以前、现在
    黑马程序员训练营基础测试
    流程图
    线程同步
    Thread联系
    Java线程
    Java中文件流笔记
    字符串习题
    匿名内部类
  • 原文地址:https://www.cnblogs.com/Ph-one/p/14437041.html
Copyright © 2011-2022 走看看