ubuntu 安装freetds
扫描二维码
随时随地手机看文章
大家可能会说,安装freetds的博客到处都是,为何还要多此一举呢,主要是因为笔者在安装的过程中遇到了一些问题,这些问题,没有解决,大家都解决了,或者大家都没有遇到笔者的问题吧,或许,所以,在这里,我写下,自己的困惑
sudo cp -r /home/john/Desktop/freetds-0.91/ /usr/soft/
我把freetds的源代码复制到/usr/soft下,进入到/usr/soft/freetds-0.91尽心安装,可总是出错
txt2man not found all-recivev error 127
等等,我的解决办法是将源代码复制在桌面上,然后进行安装,提示成功
这里我们修改配置文件/etc/ld.so.conf文件为
include /etc/ld.so.conf.d/*.conf
/usr/local/freetds/lib (这是新添加的)
#include#include#include#include#include#includeint main(void) { char szUsername[32] = "sa"; char szPassword[32] = "rjgc214team"; char szDBName[32] = "IKCExamples"; char szServer[32] = "115.24.160.253";//形式如10.10.11.12:1111 //初始化db-library dbinit(); //连接数据库 LOGINREC *loginrec = dblogin(); DBSETLUSER(loginrec, szUsername); DBSETLPWD(loginrec, szPassword); DBPROCESS *dbprocess = dbopen(loginrec, szServer); if(dbprocess == FAIL) { printf("ASB>> Conect MS SQL SERVER fail n"); return 0; } printf("ASB>> ConnectEMS conect MS SQL SERVER successn"); if(dbuse(dbprocess, szDBName) == FAIL) { printf("ASB>> Open database name failn"); } else { printf("ASB>> Open database name successn"); } //查询数据库 /*dbcmd(dbprocess, "select ID,BeginTime,Description from Alarms"); if(dbsqlexec(dbprocess) == FAIL) { printf("ASB>> Query Alarms table errorn"); } DBINT result_code; char szID[1024]; char szBeginTime[1024]; char szDescription[1024]; int rows = 0; while ((result_code = dbresults(dbprocess)) != NO_MORE_RESULTS){ if (result_code == SUCCEED){ dbbind(dbprocess, 1, CHARBIND, (DBINT)0, (BYTE*)szID); dbbind(dbprocess, 2, CHARBIND, (DBCHAR)0, (BYTE*)szBeginTime); dbbind(dbprocess, 3, CHARBIND, (DBCHAR)0, (BYTE*)szDescription); while (dbnextrow(dbprocess) != NO_MORE_ROWS){ printf("ASB>> ID=%sn", szID); printf("ASB>> szAid=%sn", szBeginTime); printf("ASB>> szBeginTime=%sn", szDescription); } } }*/ //关闭数据库连接 dbclose(dbprocess); return 0; }
进行编译链接
gcc -o testsybase SQL.c -L/usr/local/freetds/lib -lsybdb
执行即可
john@john-OptiPlex-780:~/Documents/SQL$ ./testsybase ASB>> ConnectEMS conect MS SQL SERVER success ASB>> Open database name success
提示成功
方法2:直接执行 sudo apt-get install freetds-bin 自动安装也是可以的