2
votes

Erreur SQLite lors de la création d'un projet de rails sous Windows

Je suis un newbee aux rails. J'essaye de créer un projet de rails

rails nouveau dépôt

Malheureusement, cela échoue au moment où les rails essaient de faire l'installation de la gemme de sqlite

Le l'erreur est la suivante

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

J'ai installé (copié les binaires) de la page de téléchargement SQLite dans mon dossier C: \ sqlite. Mon système d'exploitation est 64 bits, j'ai donc téléchargé "sqlite-dll-win64-x64-3260000.zip" et "sqlite-tools-win32-x86-3260000.zip" (à partir d'ici https://www.sqlite.org/download.html ) J'ai également les fichiers dll et d'en-tête comme indiqué

"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 */

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

À cause de cette erreur, j'ai essayé d'installer sqlite3 avec la commande gem Comme mon en-tête et ma DLL sont dans le répertoire C: \ sqlite, j'ai utilisé la commande suivante sur le terminal 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>

Y a-t-il un indice qui manque?

Le mkmf log dit

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

En dernier recours, j'ai construit le SQlite en utilisant mingw64 Plus tard, j'ai essayé d'installer la gemme. Et une nouvelle erreur qui ressemble à shostopper

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>


0 commentaires

4 Réponses :


0
votes

Selon la description mentionnée dans l'article, il semble que sqlite n'est pas correctement installé sur votre machine, y compris tous les en-têtes requis.

Exécutez la commande mentionnée ci-dessous pour l'installer correctement:

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


2 commentaires

Malheureusement, cela n'a pas fonctionné. J'ai mis à jour l'erreur dans le message d'origine


Im vraiment à un point de blocage ici .. J'ai tout essayé des articles Web, rien ne fonctionne. Je me demande pourquoi le livre Agile Web Development Using Rails 5 de Sam Ruby avait déjà choisi SQLite comme base de données de choix. Il n'y a rien dans le livre concernant l'installation. La honte :-(



2
votes

Pointez sur le fork du gem sqlite3-ruby et utilisez la branche mise à jour pour la dernière fois en 2018:

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

vers votre Gemfile. Jusqu'à présent, cela a fonctionné pour moi. Bonne chance! :)


0 commentaires

3
votes

Nous avons trouvé une solution très intéressante ici

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

Il voit qu'il ne manque qu'une bibliothèque dans msys2.

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

Après cela, la compilation s'est bien déroulée.

gem installer sqlite3 -v 1.4.0

Remarque: - l'ajout d'une dépendance sur une branche git ne semble pas idéal.


0 commentaires

0
votes

C'est un simple problème d'autorisation, suivez les étapes ci-dessous.

  1. Désinstaller Ruby
  2. Réinstallez Ruby, * lors de la réinstallation de Ruby, installez-le sous le dossier C: \ user-name * .
  3. Après avoir installé Ruby, réexécutez l'installation de gem sqllite3 sous C: \ user-name \ Folder. ici le nom d'utilisateur est l'utilisateur de votre répertoire d'utilisateurs. Exemple: C: \ Users \ rose \

0 commentaires