zoukankan      html  css  js  c++  java
  • Linux使用C语言链接MsSQL

    1.安装gcc编译器

    yum install gcc

    2.下载freetds

    wget ftp://ftp.freetds.org/pub/freetds/stable/freetds-patched.tar.gz

    3.安装

    tar xzf freetds-patched.tar.gz
    ./configure --with-tdsver=7.4 --enable-msdblib
    make&&make install
     
    填坑:
    1.编译遇到如下错误:
    start.c:(.text+0x27b): undefined reference to `dbinit'
    start.c:(.text+0x280): undefined reference to `dblogin'
    start.c:(.text+0x29c): undefined reference to `dbsetlname'
    start.c:(.text+0x2b4): undefined reference to `dbsetlname'
    start.c:(.text+0x2cc): undefined reference to `tdsdbopen'
    start.c:(.text+0x2f4): undefined reference to `dbuse'
    start.c:(.text+0x31a): undefined reference to `dbcmd'
    start.c:(.text+0x326): undefined reference to `dbsqlexec'
    start.c:(.text+0x332): undefined reference to `dbresults'
    start.c:(.text+0x357): undefined reference to `dbbind'
    start.c:(.text+0x36f): undefined reference to `dbclose'

    解决方法:

    编译的时候带上库目录

    gcc -o start start.c -L/usr/local/lib/ -lsybdb

    2.执行的时候遇到如下错误:

    error while loading shared libraries: libsybdb.so.5: cannot open shared object file: No such file or directory

    解决方法:

    建立lib目录的链接

    vim /etc/ld.so.conf.d/freetds.conf

    添加/usr/local/lib后保存退出,之后执行

    ldconfig

    再编译即可通过

  • 相关阅读:
    mysql添加用户
    ubantu更新源
    内存的crash记录分析
    windows下sublime2 clojure环境配置
    服务器使用recast navigation
    网络库crash以及boost asio strand dispath分析
    CentOS7 监控进程网络流量工具安装
    vs2013提高编译速度
    Centos6.5 gitlab安装使用
    linux命令行将已有项目提交到github
  • 原文地址:https://www.cnblogs.com/liuyi2614/p/8509814.html
Copyright © 2011-2022 走看看