Ошибка Sqlite при создании проекта rails в Windows - PullRequest
0 голосов
/ 05 февраля 2019

Я новичок в рельсах.Я пытаюсь создать проект rails

rails new depot

К сожалению, это не удается в тот момент, когда рельсы пытаются сделать geminstall sqlite

Ошибка заключается в следующем

Fetching sqlite3 1.4.0
Installing sqlite3 1.4.0 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

current directory:
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/sqlite3-1.4.0/ext/sqlite3
C:/Ruby24-x64/bin/ruby.exe -r ./siteconf20190205-19788-3qr0ge.rb extconf.rb
checking for sqlite3.h... no
sqlite3.h is missing. Install SQLite3 from http://www.sqlite.org/ first.
*** 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=C:/Ruby24-x64/bin/$(RUBY_BASE_NAME)
        --with-sqlcipher
        --without-sqlcipher
        --with-sqlite3-config
        --without-sqlite3-config
        --with-pkg-config
        --without-pkg-config
        --with-sqlcipher
        --without-sqlcipher
        --with-sqlite3-dir
        --without-sqlite3-dir
        --with-sqlite3-include
        --without-sqlite3-include=${sqlite3-dir}/include
        --with-sqlite3-lib
        --without-sqlite3-lib=${sqlite3-dir}/lib

To see why this extension failed to compile, please check the mkmf.log which can
be found here:

C:/Ruby24-x64/lib/ruby/gems/2.4.0/extensions/x64-mingw32/2.4.0/sqlite3-1.4.0/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in
C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/sqlite3-1.4.0 for inspection.
Results logged to
C:/Ruby24-x64/lib/ruby/gems/2.4.0/extensions/x64-mingw32/2.4.0/sqlite3-1.4.0/gem_make.out

An error occurred while installing sqlite3 (1.4.0), and Bundler cannot continue.
Make sure that `gem install sqlite3 -v '1.4.0'` succeeds before bundling.

In Gemfile:
  sqlite3

C:\Users\rose\railsprojects>

Я установил (скопировал двоичные файлы) со страницы загрузки SQLite в мою папку C: \ sqlite.Моя ОС 64-битная, поэтому я скачал "sqlite-dll-win64-x64-3260000.zip" и "sqlite-tools-win32-x86-3260000.zip" (отсюда https://www.sqlite.org/download.html) У меня также есть DLLи файлы заголовков, как показано

02/12/2018  12:38 AM           504,837 shell.c
02/12/2018  12:39 AM           490,496 sqldiff.exe
02/12/2018  12:38 AM         7,770,073 sqlite3.c
02/12/2018  12:26 PM             5,933 sqlite3.def
02/12/2018  12:27 PM         1,878,528 sqlite3.dll
02/12/2018  12:40 AM           911,360 sqlite3.exe
02/12/2018  12:38 AM           556,318 sqlite3.h
02/12/2018  12:38 AM            33,713 sqlite3ext.h
02/12/2018  12:40 AM         2,003,968 sqlite3_analyzer.exe

Из-за этой ошибки я попытался установить sqlite3 с помощью команды gem Поскольку мой заголовок и DLL находятся в каталоге C: \ sqlite, я использовал следующую команду на терминале msys2


ridk enable
C:\Users\rose>gem install sqlite3 --platform=ruby -- --with-sqlite3-dir=C:\sqlite
Fetching: sqlite3-1.4.0.gem (100%)
Installing required msys2 packages: mingw-w64-x86_64-sqlite3
Building native extensions with: '--with-sqlite3-dir=C:\sqlite'
This could take a while...
ERROR:  Error installing sqlite3:
        ERROR: Failed to build gem native extension.

    current directory: C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/sqlite3-1.4.0/ext/sqlite3
C:/Ruby25-x64/bin/ruby.exe -r ./siteconf20190205-17968-rk6pw2.rb extconf.rb --with-sqlite3-dir=C:\sqlite
checking for sqlite3.h... yes
checking for pthread_create() in -lpthread... yes
checking for -ldl... no
checking for dlopen()... no
missing function dlopen
*** 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=C:/Ruby25-x64/bin/$(RUBY_BASE_NAME)
        --with-sqlcipher
        --without-sqlcipher
        --with-sqlite3-config
        --without-sqlite3-config
        --with-pkg-config
        --without-pkg-config
        --with-sqlcipher
        --without-sqlcipher
        --with-sqlite3-dir
        --with-sqlite3-include
        --without-sqlite3-include=${sqlite3-dir}/include
        --with-sqlite3-lib
        --without-sqlite3-lib=${sqlite3-dir}/lib
        --with-pthreadlib
        --without-pthreadlib
        --with-dllib
        --without-dllib

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  C:/Ruby25-x64/lib/ruby/gems/2.5.0/extensions/x64-mingw32/2.5.0/sqlite3-1.4.0/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/sqlite3-1.4.0 for inspection.
Results logged to C:/Ruby25-x64/lib/ruby/gems/2.5.0/extensions/x64-mingw32/2.5.0/sqlite3-1.4.0/gem_make.out

C:\Users\rose>

Есть какие-нибудь подсказки, чего не хватает?

В журнале mkmf написано

"pkg-config --exists sqlite3"
| pkg-config --libs sqlite3
=> "-LC:/Ruby25-x64/msys64/mingw64/lib -lsqlite3\n"
"x86_64-w64-mingw32-gcc -o conftest.exe -IC:/Ruby25-x64/include/ruby-2.5.0/x64-mingw32 -IC:/Ruby25-x64/include/ruby-2.5.0/ruby/backward -IC:/Ruby25-x64/include/ruby-2.5.0 -I. -D_FORTIFY_SOURCE=2 -D__USE_MINGW_ANSI_STDIO=1 -DFD_SETSIZE=2048 -D_WIN32_WINNT=0x0501 -D__MINGW_USE_VC2005_COMPAT -D_FILE_OFFSET_BITS=64  -march=x86-64 -mtune=generic -O2 -pipe conftest.c  -L. -LC:/Ruby25-x64/lib -L. -pipe -s     -lx64-msvcrt-ruby250  -lgmp -lshell32 -lws2_32 -liphlpapi -limagehlp -lshlwapi  "
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: #include <winsock2.h>
4: #include <windows.h>
5: int main(int argc, char **argv)
6: {
7:   return 0;
8: }
/* end */

"x86_64-w64-mingw32-gcc -o conftest.exe -IC:/Ruby25-x64/include/ruby-2.5.0/x64-mingw32 -IC:/Ruby25-x64/include/ruby-2.5.0/ruby/backward -IC:/Ruby25-x64/include/ruby-2.5.0 -I. -D_FORTIFY_SOURCE=2 -D__USE_MINGW_ANSI_STDIO=1 -DFD_SETSIZE=2048 -D_WIN32_WINNT=0x0501 -D__MINGW_USE_VC2005_COMPAT -D_FILE_OFFSET_BITS=64  -march=x86-64 -mtune=generic -O2 -pipe conftest.c  -L. -LC:/Ruby25-x64/lib -L. -pipe -s     -lx64-msvcrt-ruby250 -LC:/Ruby25-x64/msys64/mingw64/lib -lsqlite3 -lgmp -lshell32 -lws2_32 -liphlpapi -limagehlp -lshlwapi  "
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: #include <winsock2.h>
4: #include <windows.h>
5: int main(int argc, char **argv)
6: {
7:   return 0;
8: }
/* end */

| pkg-config --cflags-only-I sqlite3
=> "-IC:/Ruby25-x64/msys64/mingw64/include\n"
| pkg-config --cflags-only-other sqlite3
=> "\n"
| pkg-config --libs-only-l sqlite3
=> "-lsqlite3\n"
package configuration for sqlite3
cflags: 
ldflags: -LC:/Ruby25-x64/msys64/mingw64/lib
libs: -lsqlite3

find_header: checking for sqlite3.h... -------------------- yes

"x86_64-w64-mingw32-gcc -E -IC:/Ruby25-x64/include/ruby-2.5.0/x64-mingw32 -IC:/Ruby25-x64/include/ruby-2.5.0/ruby/backward -IC:/Ruby25-x64/include/ruby-2.5.0 -I. -IC:/Ruby25-x64/msys64/mingw64/include -IC:\sqlite/include -D_FORTIFY_SOURCE=2 -D__USE_MINGW_ANSI_STDIO=1 -DFD_SETSIZE=2048 -D_WIN32_WINNT=0x0501 -D__MINGW_USE_VC2005_COMPAT -D_FILE_OFFSET_BITS=64  -march=x86-64 -mtune=generic -O2 -pipe   conftest.c -o conftest.i"
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: #include <winsock2.h>
4: #include <windows.h>
5: #include <sqlite3.h>
/* end */

--------------------

find_library: checking for pthread_create() in -lpthread... -------------------- yes

"x86_64-w64-mingw32-gcc -o conftest.exe -IC:/Ruby25-x64/include/ruby-2.5.0/x64-mingw32 -IC:/Ruby25-x64/include/ruby-2.5.0/ruby/backward -IC:/Ruby25-x64/include/ruby-2.5.0 -I. -IC:/Ruby25-x64/msys64/mingw64/include -IC:\sqlite/include -D_FORTIFY_SOURCE=2 -D__USE_MINGW_ANSI_STDIO=1 -DFD_SETSIZE=2048 -D_WIN32_WINNT=0x0501 -D__MINGW_USE_VC2005_COMPAT -D_FILE_OFFSET_BITS=64  -march=x86-64 -mtune=generic -O2 -pipe  conftest.c  -L. -LC:/Ruby25-x64/lib -LC:\sqlite/lib -L. -pipe -s -LC:/Ruby25-x64/msys64/mingw64/lib     -lsqlite3 -lx64-msvcrt-ruby250 -lpthread  -lsqlite3 -lgmp -lshell32 -lws2_32 -liphlpapi -limagehlp -lshlwapi  "
conftest.c: In function 't':
conftest.c:16:57: error: 'pthread_create' undeclared (first use in this function); did you mean 'rb_thread_create'?
 int t(void) { void ((*volatile p)()); p = (void ((*)()))pthread_create; return !p; }
                                                         ^~~~~~~~~~~~~~
                                                         rb_thread_create
conftest.c:16:57: note: each undeclared identifier is reported only once for each function it appears in
checked program was:
/* begin */
 1: #include "ruby.h"
 2: 
 3: #include <winsock2.h>
 4: #include <windows.h>
 5: 
 6: /*top*/
 7: extern int t(void);
 8: int main(int argc, char **argv)
 9: {
10:   if (argc > 1000000) {
11:     printf("%p", &t);
12:   }
13: 
14:   return 0;
15: }
16: int t(void) { void ((*volatile p)()); p = (void ((*)()))pthread_create; return !p; }
/* end */

"x86_64-w64-mingw32-gcc -o conftest.exe -IC:/Ruby25-x64/include/ruby-2.5.0/x64-mingw32 -IC:/Ruby25-x64/include/ruby-2.5.0/ruby/backward -IC:/Ruby25-x64/include/ruby-2.5.0 -I. -IC:/Ruby25-x64/msys64/mingw64/include -IC:\sqlite/include -D_FORTIFY_SOURCE=2 -D__USE_MINGW_ANSI_STDIO=1 -DFD_SETSIZE=2048 -D_WIN32_WINNT=0x0501 -D__MINGW_USE_VC2005_COMPAT -D_FILE_OFFSET_BITS=64  -march=x86-64 -mtune=generic -O2 -pipe  conftest.c  -L. -LC:/Ruby25-x64/lib -LC:\sqlite/lib -L. -pipe -s -LC:/Ruby25-x64/msys64/mingw64/lib     -lsqlite3 -lx64-msvcrt-ruby250 -lpthread  -lsqlite3 -lgmp -lshell32 -lws2_32 -liphlpapi -limagehlp -lshlwapi  "
checked program was:
/* begin */
 1: #include "ruby.h"
 2: 
 3: #include <winsock2.h>
 4: #include <windows.h>
 5: 
 6: /*top*/
 7: extern int t(void);
 8: int main(int argc, char **argv)
 9: {
10:   if (argc > 1000000) {
11:     printf("%p", &t);
12:   }
13: 
14:   return 0;
15: }
16: extern void pthread_create();
17: int t(void) { pthread_create(); return 0; }
/* end */

--------------------

have_library: checking for -ldl... -------------------- no

"x86_64-w64-mingw32-gcc -o conftest.exe -IC:/Ruby25-x64/include/ruby-2.5.0/x64-mingw32 -IC:/Ruby25-x64/include/ruby-2.5.0/ruby/backward -IC:/Ruby25-x64/include/ruby-2.5.0 -I. -IC:/Ruby25-x64/msys64/mingw64/include -IC:\sqlite/include -D_FORTIFY_SOURCE=2 -D__USE_MINGW_ANSI_STDIO=1 -DFD_SETSIZE=2048 -D_WIN32_WINNT=0x0501 -D__MINGW_USE_VC2005_COMPAT -D_FILE_OFFSET_BITS=64  -march=x86-64 -mtune=generic -O2 -pipe  conftest.c  -L. -LC:/Ruby25-x64/lib -LC:\sqlite/lib -L. -pipe -s -LC:/Ruby25-x64/msys64/mingw64/lib    -lpthread  -lsqlite3 -lx64-msvcrt-ruby250 -ldl -lpthread  -lsqlite3 -lgmp -lshell32 -lws2_32 -liphlpapi -limagehlp -lshlwapi  "
C:/Ruby25-x64/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.2.1/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -ldl
collect2.exe: error: ld returned 1 exit status
checked program was:
/* begin */
 1: #include "ruby.h"
 2: 
 3: #include <winsock2.h>
 4: #include <windows.h>
 5: 
 6: /*top*/
 7: extern int t(void);
 8: int main(int argc, char **argv)
 9: {
10:   if (argc > 1000000) {
11:     printf("%p", &t);
12:   }
13: 
14:   return 0;
15: }
16: 
17: int t(void) { ; return 0; }
/* end */

--------------------

have_func: checking for dlopen()... -------------------- no

"x86_64-w64-mingw32-gcc -o conftest.exe -IC:/Ruby25-x64/include/ruby-2.5.0/x64-mingw32 -IC:/Ruby25-x64/include/ruby-2.5.0/ruby/backward -IC:/Ruby25-x64/include/ruby-2.5.0 -I. -IC:/Ruby25-x64/msys64/mingw64/include -IC:\sqlite/include -D_FORTIFY_SOURCE=2 -D__USE_MINGW_ANSI_STDIO=1 -DFD_SETSIZE=2048 -D_WIN32_WINNT=0x0501 -D__MINGW_USE_VC2005_COMPAT -D_FILE_OFFSET_BITS=64  -march=x86-64 -mtune=generic -O2 -pipe  conftest.c  -L. -LC:/Ruby25-x64/lib -LC:\sqlite/lib -L. -pipe -s -LC:/Ruby25-x64/msys64/mingw64/lib    -lpthread  -lsqlite3 -lx64-msvcrt-ruby250 -lpthread  -lsqlite3 -lgmp -lshell32 -lws2_32 -liphlpapi -limagehlp -lshlwapi  "
conftest.c: In function 't':
conftest.c:16:57: error: 'dlopen' undeclared (first use in this function); did you mean '_lopen'?
 int t(void) { void ((*volatile p)()); p = (void ((*)()))dlopen; return !p; }
                                                         ^~~~~~
                                                         _lopen
conftest.c:16:57: note: each undeclared identifier is reported only once for each function it appears in
checked program was:
/* begin */
 1: #include "ruby.h"
 2: 
 3: #include <winsock2.h>
 4: #include <windows.h>
 5: 
 6: /*top*/
 7: extern int t(void);
 8: int main(int argc, char **argv)
 9: {
10:   if (argc > 1000000) {
11:     printf("%p", &t);
12:   }
13: 
14:   return 0;
15: }
16: int t(void) { void ((*volatile p)()); p = (void ((*)()))dlopen; return !p; }
/* end */

"x86_64-w64-mingw32-gcc -o conftest.exe -IC:/Ruby25-x64/include/ruby-2.5.0/x64-mingw32 -IC:/Ruby25-x64/include/ruby-2.5.0/ruby/backward -IC:/Ruby25-x64/include/ruby-2.5.0 -I. -IC:/Ruby25-x64/msys64/mingw64/include -IC:\sqlite/include -D_FORTIFY_SOURCE=2 -D__USE_MINGW_ANSI_STDIO=1 -DFD_SETSIZE=2048 -D_WIN32_WINNT=0x0501 -D__MINGW_USE_VC2005_COMPAT -D_FILE_OFFSET_BITS=64  -march=x86-64 -mtune=generic -O2 -pipe  conftest.c  -L. -LC:/Ruby25-x64/lib -LC:\sqlite/lib -L. -pipe -s -LC:/Ruby25-x64/msys64/mingw64/lib    -lpthread  -lsqlite3 -lx64-msvcrt-ruby250 -lpthread  -lsqlite3 -lgmp -lshell32 -lws2_32 -liphlpapi -limagehlp -lshlwapi  "
C:\Users\Navarose\AppData\Local\Temp\ccNQH25m.o:conftest.c:(.text+0x5): undefined reference to `dlopen'
collect2.exe: error: ld returned 1 exit status
checked program was:
/* begin */
 1: #include "ruby.h"
 2: 
 3: #include <winsock2.h>
 4: #include <windows.h>
 5: 
 6: /*top*/
 7: extern int t(void);
 8: int main(int argc, char **argv)
 9: {
10:   if (argc > 1000000) {
11:     printf("%p", &t);
12:   }
13: 
14:   return 0;
15: }
16: extern void dlopen();
17: int t(void) { dlopen(); return 0; }
/* end */

--------------------

В качестве последнего средства я собрал SQlite с помощью mingw64 Позже попытался установить гем. И новыйошибка, которая похожа на shostopper

gem install sqlite3 --platform=ruby -- --with-sqlite3-include=C:\sqlite\ --with-sqlite3-lib=C:\sqlite\.libs\

C:/RailsInstaller/Ruby2.3.3/bin/ruby.exe -r ./siteconf20190205-18436-ve1008.rb extconf.rb --with-sqlite3-include=C:\sqlite\ --with-sqlite3-lib=C:\sqlite\.libs\
checking for sqlite3.h... yes
checking for pthread_create() in -lpthread... no
checking for main() in -ldl... no
checking for dlopen()... no
missing function dlopen
*** 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=C:/RailsInstaller/Ruby2.3.3/bin/$(RUBY_BASE_NAME)
        --with-sqlcipher
        --without-sqlcipher
        --with-sqlite3-config
        --without-sqlite3-config
        --with-pkg-config
        --without-pkg-config
        --with-sqlcipher
        --without-sqlcipher
        --with-sqlite3-dir
        --without-sqlite3-dir
        --with-sqlite3-include=${sqlite3-dir}/include
        --with-sqlite3-lib=${sqlite3-dir}/lib
        --with-pthreadlib
        --without-pthreadlib
        --with-dllib
        --without-dllib

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/extensions/x86-mingw32/2.3.0/sqlite3-1.4.0/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/sqlite3-1.4.0 for inspection.
Results logged to C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/extensions/x86-mingw32/2.3.0/sqlite3-1.4.0/gem_make.out

Ответы [ 3 ]

0 голосов
/ 07 февраля 2019

Укажите на ветвь драгоценного камня sqlite3-ruby и используйте ветку, последний раз обновленную в 2018 году:

gem 'sqlite3', git: "https://github.com/larskanis/sqlite3-ruby", branch: "add-gemspec"

для вашего Gemfile.Пока это работает для меня.Удачи!:)

0 голосов
/ 08 февраля 2019

Здесь найдено очень аккуратное исправление

https://github.com/sparklemotion/sqlite3-ruby/issues/248

Кажется, что в msys2 отсутствует только библиотека.

ridk exec pacman -S mingw-w64-x86_64-dlfcn

После этого компиляция прошла нормально.

gem install sqlite3 -v 1.4.0

Примечание: - добавление зависимости от ветви git не кажется идеальным.

0 голосов
/ 05 февраля 2019

В соответствии с описанием, упомянутым в посте, похоже, что sqlite не установлен должным образом на вашей машине, включая все необходимые заголовки.

Запустите приведенную ниже команду, чтобы установить ее правильно:

gem install sqlite3 --platform=ruby -- --with-sqlite3-dir=C:/path/to/sqlite3

Где C:/path/to/sqlite3 - это место, где находятся заголовки (include) и библиотеки (lib) для sqlite3.

Надеюсь, это поможет.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...