首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Ruby Sqlite3 installation sqlite3_libversion_number() macOS塞拉利昂

Ruby Sqlite3 installation sqlite3_libversion_number() macOS塞拉利昂
EN

Stack Overflow用户
提问于 2016-12-28 22:24:22
回答 3查看 3.9K关注 0票数 4

我正在尝试安装Metasploit框架(并不重要),而bundler正在尝试安装sqlite3,这是它一贯失败的地方。安装了Sqlite3 (在命令行执行sqlite3将我带到环境中),并使用brew link sqlite3进行链接(由于某种原因添加了-force),但是bundler install每次都失败,出现此错误:

代码语言:javascript
复制
sudo gem install sqlite3
Building native extensions.  This could take a while...
ERROR:  Error installing sqlite3:
    ERROR: Failed to build gem native extension.

    /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb
Error: Running Homebrew as root is extremely dangerous and no longer supported.
As Homebrew does not drop privileges on installation you would be giving all
build scripts full access to your system.
checking for sqlite3.h... yes
checking for pthread_create() in -lpthread... yes
checking for sqlite3_libversion_number() in -lsqlite3... no
sqlite3 is missing. Try 'brew install sqlite3',
'yum install sqlite-devel' or 'apt-get install libsqlite3-dev'
and check your shared library search path (the
location where your sqlite3 shared library is located).
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
    --with-opt-dir
    --without-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby
    --with-sqlite3-config
    --without-sqlite3-config
    --with-pkg-config
    --without-pkg-config
    --with-sqlite3-dir
    --without-sqlite3-dir
    --with-sqlite3-include
    --without-sqlite3-include=${sqlite3-dir}/include
    --with-sqlite3-lib
    --without-sqlite3-lib=${sqlite3-dir}/
    --with-pthreadlib
    --without-pthreadlib
    --with-sqlite3lib
    --without-sqlite3lib


Gem files will remain installed in /Library/Ruby/Gems/2.0.0/gems/sqlite3-1.3.12 for inspection.
Results logged to /Library/Ruby/Gems/2.0.0/gems/sqlite3-1.3.12/ext/sqlite3/gem_make.out
EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2017-06-23 19:13:44

最后,我通过指定了内置的macOS库目录(macOS Sierra10.12.5(16F73))来解决这个问题:

代码语言:javascript
复制
$ whereis sqlite3
/usr/bin/sqlite3
# if binary is in /usr/bin then library is typically in /usr/lib
$ gem install sqlite3 -- --with-sqlite3-lib=/usr/lib
Building native extensions with: '--with-sqlite3-lib=/usr/lib'
This could take a while...
Successfully installed sqlite3-1.3.13
Parsing documentation for sqlite3-1.3.13
Done installing documentation for sqlite3 after 0 seconds
1 gem installed

我试图指定自制软件库目录,但由于某些原因,它没有工作:

代码语言:javascript
复制
$ brew ls --verbose sqlite3
/usr/local/Cellar/sqlite/3.19.3/.brew/sqlite.rb
/usr/local/Cellar/sqlite/3.19.3/bin/sqlite3
/usr/local/Cellar/sqlite/3.19.3/include/msvc.h
/usr/local/Cellar/sqlite/3.19.3/include/sqlite3.h
/usr/local/Cellar/sqlite/3.19.3/include/sqlite3ext.h
/usr/local/Cellar/sqlite/3.19.3/INSTALL_RECEIPT.json
/usr/local/Cellar/sqlite/3.19.3/lib/libsqlite3.0.dylib
/usr/local/Cellar/sqlite/3.19.3/lib/libsqlite3.a
/usr/local/Cellar/sqlite/3.19.3/lib/libsqlite3.dylib
/usr/local/Cellar/sqlite/3.19.3/lib/pkgconfig/sqlite3.pc
/usr/local/Cellar/sqlite/3.19.3/README.txt
/usr/local/Cellar/sqlite/3.19.3/share/man/man1/sqlite3.1
$ gem install sqlite3 -- --with-sqlite3-lib=/usr/local/Cellar/sqlite/3.19.3/lib
This could take a while...
ERROR:  Error installing sqlite3:
    ERROR: Failed to build gem native extension.
...

如果有人知道如何指定Homebrew库目录,请告诉我,因为这将为安装提供更多的控制(据称MacPorts工作,但我不再使用它)。

对于任何好奇的人,下面是安装Ruby的续集的完整命令

代码语言:javascript
复制
gem install sequel mysql sqlite3 -- --with-sqlite3-lib=/usr/lib

以及如何将侦听主机端口3306的拉勒维尔家园 MySQL数据库从我对这个问题的评论转换为SQLite

代码语言:javascript
复制
sequel mysql://homestead:secret@192.168.10.10:3306/my_database -C sqlite://my_database.sqlite
票数 20
EN

Stack Overflow用户

发布于 2018-08-15 09:28:10

这对我来说是适用于MacHighSieraOS10.13的

代码语言:javascript
复制
gem install sqlite3 -- --with-sqlite3-lib=/usr/lib
票数 5
EN

Stack Overflow用户

发布于 2021-07-09 05:57:26

通过替换指向安装尝试的日志的文件指针的最后部分,深入了解您将找到的mkmf.log。就我而言:

代码语言:javascript
复制
Results logged to ~/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/extensions/x86_64-darwin-19/2.2.0-static/sqlite3-1.3.13/gem_make.out

所以我在这里找到了mkmf.log

代码语言:javascript
复制
~/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/extensions/x86_64-darwin-19/2.2.0-static/sqlite3-1.3.13/mkmf.log

我发现了对这些错误的更明确的描述:

代码语言:javascript
复制
conftest.c:13:15: error: implicit declaration of function 'pthread_create' is invalid in C99 [-Werror,-Wimplicit-function-declaration]

conftest.c:13:15: error: implicit declaration of function 'sqlite3_libversion_number' is invalid in C99 [-Werror,-Wimplicit-function-declaration]

所以添加--with-cflags="-Wno-error=implicit-function-declaration"就成了诀窍!

代码语言:javascript
复制
gem install sqlite3 -- --with-cflags="-Wno-error=implicit-function-declaration"
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/41370565

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档