QQ登录

只需一步,快速开始

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 965|回复: 1

请教一个mysql编程连接出错的问题

[复制链接]
发表于 2005-2-28 16:07:03 | 显示全部楼层 |阅读模式
我试着编了一个简单的mysql连接程序:
#include <mysql.h>
#define NULL 0

int main(void)
{
MYSQL *mysql=0;
if (!(mysql= mysql_init(NULL)))
  {
    /*myerror("mysql_init() failed");*/
    exit(1);
  }

  if (!(mysql_real_connect(mysql,"cu0601","root","123456","grid",0,NULL,0)))
  {
    /*myerror("connection failed");*/
    mysql_close(mysql);
    exit(1);
  }
  printf("Connect successful!");
  mysql_close(mysql);
}
编译顺利通过:
gcc -o mysqlcon mysqlcon.c -I/usr/local/mysql/include/mysql -L/usr/local/mysql/lib/mysql -lmysqlclient
可执行./mysqlcon却出错:
./mysqlcon: error while loading shared libraries: libmysqlclient.so.14: cannot open shared object file: No such file or directory

请问一下是什么原因?
发表于 2005-3-1 01:44:45 | 显示全部楼层
libmysqlclient.so.14 is not installed in standard lib dirs. You have to specify that in a variable:
LD_LIBRARY=/usr/local/mysql/lib/mysql ./mysqlcon
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

GMT+8, 2024-11-6 14:39 , Processed in 0.040290 second(s), 15 queries .

© 2021 Powered by Discuz! X3.5.

快速回复 返回顶部 返回列表