【问题标题】:Homebrew / TinyTDS / FreeTDS bundle errorHomebrew / TinyTDS / FreeTDS 捆绑错误
【发布时间】:2012-04-17 08:53:10
【问题描述】:

我使用自制软件(Linux 端口)安装 freeTDS,并尝试使用 gem tinytds 部署 /bundle 安装我的应用程序。进行捆绑安装时出现此错误输出

Installing tiny_tds (0.5.1) with native extensions 
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

        /home/deployer/.rbenv/versions/1.9.2-p290/bin/ruby extconf.rb 

/usr/bin/ld: /opt/homebrew/lib/libsybdb.a(dblib.o): relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC

/opt/homebrew/lib/libsybdb.a: could not read symbols: Bad value

与此修复非常相似,但我的文件夹中没有引用的文件:https://stackoverflow.com/a/7119224/1130736

自制lib文件夹的内容:

/opt/homebrew/lib$ ls
libct.a  libsybdb.a

完整的错误转储:

full error dump:

Installing tiny_tds (0.5.1) with native extensions 
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

        /home/deployer/.rbenv/versions/1.9.2-p290/bin/ruby extconf.rb 
checking for iconv_open() in iconv.h... yes
checking for sybfront.h... yes
checking for sybdb.h... yes
checking for tdsdbopen() in -lsybdb... yes
checking for ct_bind() in -lct... yes
creating Makefile

make
/usr/bin/gcc -I. -I/home/deployer/.rbenv/versions/1.9.2-p290/include/ruby-1.9.1/x86_64-linux -I/home/deployer/.rbenv/versions/1.9.2-p290/include/ruby-1.9.1/ruby/backward -I/home/deployer/.rbenv/versions/1.9.2-p290/include/ruby-1.9.1 -I. -DHAVE_ICONV_OPEN -DHAVE_SYBFRONT_H -DHAVE_SYBDB_H -I/opt/homebrew/include -I/usr/local/include -I/usr/include -I'/home/deployer/.rbenv/versions/1.9.2-p290/include'    -fPIC -O3 -ggdb -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-missing-field-initializers -Wno-long-long   -o client.o -c client.c
client.c: In function ‘tinytds_err_handler’:
client.c:52: warning: initialization discards qualifiers from pointer target type
client.c: In function ‘tinytds_msg_handler’:
client.c:100: warning: initialization discards qualifiers from pointer target type
/usr/bin/gcc -I. -I/home/deployer/.rbenv/versions/1.9.2-p290/include/ruby-1.9.1/x86_64-linux -I/home/deployer/.rbenv/versions/1.9.2-p290/include/ruby-1.9.1/ruby/backward -I/home/deployer/.rbenv/versions/1.9.2-p290/include/ruby-1.9.1 -I. -DHAVE_ICONV_OPEN -DHAVE_SYBFRONT_H -DHAVE_SYBDB_H -I/opt/homebrew/include -I/usr/local/include -I/usr/include -I'/home/deployer/.rbenv/versions/1.9.2-p290/include'    -fPIC -O3 -ggdb -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-missing-field-initializers -Wno-long-long   -o result.o -c result.c
/usr/bin/gcc -I. -I/home/deployer/.rbenv/versions/1.9.2-p290/include/ruby-1.9.1/x86_64-linux -I/home/deployer/.rbenv/versions/1.9.2-p290/include/ruby-1.9.1/ruby/backward -I/home/deployer/.rbenv/versions/1.9.2-p290/include/ruby-1.9.1 -I. -DHAVE_ICONV_OPEN -DHAVE_SYBFRONT_H -DHAVE_SYBDB_H -I/opt/homebrew/include -I/usr/local/include -I/usr/include -I'/home/deployer/.rbenv/versions/1.9.2-p290/include'    -fPIC -O3 -ggdb -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-missing-field-initializers -Wno-long-long   -o tiny_tds_ext.o -c tiny_tds_ext.c
/usr/bin/gcc -shared -o tiny_tds.so client.o result.o tiny_tds_ext.o -L. -L/home/deployer/.rbenv/versions/1.9.2-p290/lib -Wl,-R/home/deployer/.rbenv/versions/1.9.2-p290/lib -L/home/deployer/.rbenv/versions/1.9.2-p290/lib -Wl,-R/home/deployer/.rbenv/versions/1.9.2-p290/lib -L/opt/homebrew/lib -Wl,-R/opt/homebrew/lib -L/usr/lib -Wl,-R/usr/lib -L. -L'/home/deployer/.rbenv/versions/1.9.2-p290/lib'  -rdynamic -Wl,-export-dynamic    -lct -lsybdb  -lpthread -lrt -ldl -lcrypt -lm   -lc 
/usr/bin/ld: /opt/homebrew/lib/libsybdb.a(dblib.o): relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
/opt/homebrew/lib/libsybdb.a: could not read symbols: Bad value
collect2: ld returned 1 exit status
make: *** [tiny_tds.so] Error 1


Gem files will remain installed in /home/deployer/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/tiny_tds-0.5.1 for inspection.
Results logged to /home/deployer/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/tiny_tds-0.5.1/ext/tiny_tds/gem_make.out
An error occured while installing tiny_tds (0.5.1), and Bundler cannot continue.
Make sure that `gem install tiny_tds -v '0.5.1'` succeeds before bundling.'

【问题讨论】:

  • 你找到解决方法了吗?

标签: activerecord homebrew freetds tiny-tds


【解决方案1】:

我运行 fedora,但我的解决方法是

sudo yum install freetds-devel

我很确定你只需要 freetds 的开发包就可以了。在我有了开发包之后,我的

gem install tiny_tds

完美运行。

【讨论】:

  • 对于 ubuntu sudo apt-get install freetds-dev
【解决方案2】:

使用自制软件安装 FreeTDS:brew install freetds

那么,这个安装应该可以工作了:gem install tiny_tds

【讨论】:

  • 这对我不起作用,因为它不会生成 lsybdb.so 文件
【解决方案3】:

我遇到了同样的问题,我用这两个命令解决了它: 酿造安装freetds

您需要安装带有 x64 标志的 gem: ARCHFLAGS="-arch x86_64" gem install tiny_tds

【讨论】:

    【解决方案4】:

    在 Mac 上安装 tiny_tds:

    使用 bundler 安装 tiny_tds gem 需要先安装 FreeTDS,并告知 bundler FreeTDS 的位置。

    首先,安装 FreeTDS:

    brew install freetds
    

    默认情况下,tiny_tds 会在某些位置查找,但由 homebrew 安装的 freetds 不会在其中任何位置找到:

    looking for freetds headers in the following directories:
     - /opt/local/include
     - /opt/local/include/freetds
     - /usr/local/include
     - /usr/local/include/freetds
    looking for freetds library in the following directories:
     - /opt/local/lib
     - /opt/local/lib/freetds
     - /usr/local/lib
     - /usr/local/lib/freetds
    

    所以,首先你需要找到 freetds lib 和 include 目录的确切位置:

    ls -l /opt/homebrew/Cellar/freetds
    

    在发这个的时候,brew安装的freetds的版本是1.3.3,所以就是那个ls -l显示的目录:

    drwxr-xr-x  15 [username]  admin  480 Dec  7 15:36 1.3.3
    

    然后,cd 进入该文件夹以查看其内容:

    cd /opt/homebrew/Cellar/freetds/1.3.3
    ls -l
    

    您将在该文件夹中找到 freetds 的 include 和 lib 目录。

    然后,告诉 bundler 告诉 tiny_tds 在哪里可以找到它们:

    bundle config set --global build.tiny_tds --with-freetds-dir=/opt/homebrew/Cellar/freetds/1.3.3
    

    现在,您可以bundle 并构建 tiny_tds gem。

    【讨论】:

      猜你喜欢
      • 2013-02-06
      • 2016-01-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-08-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多