How do I install sqlite3 gem on an M1 Mac? - ruby-on-rails

I am trying to install the sqlite3-ruby gem on my Mac, which is running an M1 Pro chip.
The installation fails with the following output:
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /Users/jay/.frum/versions/3.1.0/lib/ruby/gems/3.1.0/gems/sqlite3-1.4.2/ext/sqlite3
/Users/jay/.frum/versions/3.1.0/bin/ruby -I /Users/jay/.frum/versions/3.1.0/lib/ruby/3.1.0 -r ./siteconf20220215-37077-7vshdb.rb extconf.rb
checking for sqlite3.h... yes
checking for pthread_create() in -lpthread... yes
checking for -ldl... 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.
Looking at the mkmf.log file, there are a number of errors that seem to be related to compilation process building for the wrong architecture:
DYLD_FALLBACK_LIBRARY_PATH=.:/Users/jay/.frum/versions/3.1.0/lib pkg-config --exists sqlite3
DYLD_FALLBACK_LIBRARY_PATH=.:/Users/jay/.frum/versions/3.1.0/lib pkg-config --libs sqlite3 |
=> "-L/opt/homebrew/Cellar/sqlite/3.37.2/lib -lsqlite3\n"
DYLD_FALLBACK_LIBRARY_PATH=.:/Users/jay/.frum/versions/3.1.0/lib "clang -o conftest -I/Users/jay/.frum/versions/3.1.0/include/ruby-3.1.0/arm64-darwin21 -I/Users/jay/.frum/versions/3.1.0/include/ruby-3.1.0/ruby/backward -I/Users/jay/.frum/versions/3.1.0/include/ruby-3.1.0 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -fdeclspec -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wdeprecated-declarations -Wdivision-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wshorten-64-to-32 -Wwrite-strings -Wold-style-definition -Wmissing-noreturn -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wunused-variable -Wextra-tokens -Wundef -pipe conftest.c -L. -L/Users/jay/.frum/versions/3.1.0/lib -L. -fstack-protector-strong -L/usr/local/lib -lruby.3.1-static -framework CoreFoundation -lpthread -ldl -lobjc "
ld: warning: ignoring file /Users/jay/.frum/versions/3.1.0/lib/libruby.3.1-static.a, building for macOS-x86_64 but attempting to link with file built for macOS-arm64
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main(int argc, char **argv)
4: {
5: return !!argv[argc];
6: }
/* end */
DYLD_FALLBACK_LIBRARY_PATH=.:/Users/jay/.frum/versions/3.1.0/lib "clang -o conftest -I/Users/jay/.frum/versions/3.1.0/include/ruby-3.1.0/arm64-darwin21 -I/Users/jay/.frum/versions/3.1.0/include/ruby-3.1.0/ruby/backward -I/Users/jay/.frum/versions/3.1.0/include/ruby-3.1.0 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -fdeclspec -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wdeprecated-declarations -Wdivision-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wshorten-64-to-32 -Wwrite-strings -Wold-style-definition -Wmissing-noreturn -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wunused-variable -Wextra-tokens -Wundef -pipe conftest.c -L. -L/Users/jay/.frum/versions/3.1.0/lib -L. -fstack-protector-strong -L/usr/local/lib -lruby.3.1-static -framework CoreFoundation -lpthread -ldl -lobjc -L/opt/homebrew/Cellar/sqlite/3.37.2/lib -lsqlite3 "
ld: warning: ignoring file /Users/jay/.frum/versions/3.1.0/lib/libruby.3.1-static.a, building for macOS-x86_64 but attempting to link with file built for macOS-arm64
ld: warning: ignoring file /opt/homebrew/Cellar/sqlite/3.37.2/lib/libsqlite3.dylib, building for macOS-x86_64 but attempting to link with file built for macOS-arm64
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main(int argc, char **argv)
4: {
5: return !!argv[argc];
6: }
/* end */
DYLD_FALLBACK_LIBRARY_PATH=.:/Users/jay/.frum/versions/3.1.0/lib pkg-config --cflags-only-I sqlite3 |
=> "-I/opt/homebrew/Cellar/sqlite/3.37.2/include\n"
DYLD_FALLBACK_LIBRARY_PATH=.:/Users/jay/.frum/versions/3.1.0/lib pkg-config --cflags-only-other sqlite3 |
=> "\n"
DYLD_FALLBACK_LIBRARY_PATH=.:/Users/jay/.frum/versions/3.1.0/lib pkg-config --libs-only-l sqlite3 |
=> "-lsqlite3\n"
package configuration for sqlite3
incflags: -I/opt/homebrew/Cellar/sqlite/3.37.2/include
cflags:
ldflags: -L/opt/homebrew/Cellar/sqlite/3.37.2/lib
libs: -lsqlite3
find_header: checking for sqlite3.h... -------------------- yes
DYLD_FALLBACK_LIBRARY_PATH=.:/Users/jay/.frum/versions/3.1.0/lib "clang -I/Users/jay/.frum/versions/3.1.0/include/ruby-3.1.0/arm64-darwin21 -I/Users/jay/.frum/versions/3.1.0/include/ruby-3.1.0/ruby/backward -I/Users/jay/.frum/versions/3.1.0/include/ruby-3.1.0 -I. -I/opt/homebrew/Cellar/sqlite/3.37.2/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -fdeclspec -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wdeprecated-declarations -Wdivision-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wshorten-64-to-32 -Wwrite-strings -Wold-style-definition -Wmissing-noreturn -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wunused-variable -Wextra-tokens -Wundef -pipe -c conftest.c"
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: #include <sqlite3.h>
/* end */
--------------------
find_library: checking for pthread_create() in -lpthread... -------------------- yes
DYLD_FALLBACK_LIBRARY_PATH=.:/Users/jay/.frum/versions/3.1.0/lib "clang -o conftest -I/Users/jay/.frum/versions/3.1.0/include/ruby-3.1.0/arm64-darwin21 -I/Users/jay/.frum/versions/3.1.0/include/ruby-3.1.0/ruby/backward -I/Users/jay/.frum/versions/3.1.0/include/ruby-3.1.0 -I. -I/opt/homebrew/Cellar/sqlite/3.37.2/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -fdeclspec -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wdeprecated-declarations -Wdivision-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wshorten-64-to-32 -Wwrite-strings -Wold-style-definition -Wmissing-noreturn -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wunused-variable -Wextra-tokens -Wundef -pipe conftest.c -L. -L/Users/jay/.frum/versions/3.1.0/lib -L. -fstack-protector-strong -L/usr/local/lib -L/opt/homebrew/Cellar/sqlite/3.37.2/lib -lsqlite3 -lruby.3.1-static -framework CoreFoundation -lpthread -ldl -lobjc -lpthread -lsqlite3 "
conftest.c:14:57: error: use of undeclared identifier 'pthread_create'
int t(void) { void ((*volatile p)()); p = (void ((*)()))pthread_create; return !p; }
^
1 error generated.
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: /*top*/
4: extern int t(void);
5: int main(int argc, char **argv)
6: {
7: if (argc > 1000000) {
8: int (* volatile tp)(void)=(int (*)(void))&t;
9: printf("%d", (*tp)());
10: }
11:
12: return !!argv[argc];
13: }
14: int t(void) { void ((*volatile p)()); p = (void ((*)()))pthread_create; return !p; }
/* end */
DYLD_FALLBACK_LIBRARY_PATH=.:/Users/jay/.frum/versions/3.1.0/lib "clang -o conftest -I/Users/jay/.frum/versions/3.1.0/include/ruby-3.1.0/arm64-darwin21 -I/Users/jay/.frum/versions/3.1.0/include/ruby-3.1.0/ruby/backward -I/Users/jay/.frum/versions/3.1.0/include/ruby-3.1.0 -I. -I/opt/homebrew/Cellar/sqlite/3.37.2/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -fdeclspec -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wdeprecated-declarations -Wdivision-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wshorten-64-to-32 -Wwrite-strings -Wold-style-definition -Wmissing-noreturn -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wunused-variable -Wextra-tokens -Wundef -pipe conftest.c -L. -L/Users/jay/.frum/versions/3.1.0/lib -L. -fstack-protector-strong -L/usr/local/lib -L/opt/homebrew/Cellar/sqlite/3.37.2/lib -lsqlite3 -lruby.3.1-static -framework CoreFoundation -lpthread -ldl -lobjc -lpthread -lsqlite3 "
ld: warning: ignoring file /opt/homebrew/Cellar/sqlite/3.37.2/lib/libsqlite3.dylib, building for macOS-x86_64 but attempting to link with file built for macOS-arm64
ld: warning: ignoring file /Users/jay/.frum/versions/3.1.0/lib/libruby.3.1-static.a, building for macOS-x86_64 but attempting to link with file built for macOS-arm64
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: /*top*/
4: extern int t(void);
5: int main(int argc, char **argv)
6: {
7: if (argc > 1000000) {
8: int (* volatile tp)(void)=(int (*)(void))&t;
9: printf("%d", (*tp)());
10: }
11:
12: return !!argv[argc];
13: }
14: extern void pthread_create();
15: int t(void) { pthread_create(); return 0; }
/* end */
--------------------
have_library: checking for -ldl... -------------------- yes
DYLD_FALLBACK_LIBRARY_PATH=.:/Users/jay/.frum/versions/3.1.0/lib "clang -o conftest -I/Users/jay/.frum/versions/3.1.0/include/ruby-3.1.0/arm64-darwin21 -I/Users/jay/.frum/versions/3.1.0/include/ruby-3.1.0/ruby/backward -I/Users/jay/.frum/versions/3.1.0/include/ruby-3.1.0 -I. -I/opt/homebrew/Cellar/sqlite/3.37.2/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -fdeclspec -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wdeprecated-declarations -Wdivision-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wshorten-64-to-32 -Wwrite-strings -Wold-style-definition -Wmissing-noreturn -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wunused-variable -Wextra-tokens -Wundef -pipe conftest.c -L. -L/Users/jay/.frum/versions/3.1.0/lib -L. -fstack-protector-strong -L/usr/local/lib -L/opt/homebrew/Cellar/sqlite/3.37.2/lib -lpthread -lsqlite3 -lruby.3.1-static -framework CoreFoundation -lpthread -ldl -lobjc -ldl -lpthread -lsqlite3 "
ld: warning: ignoring file /opt/homebrew/Cellar/sqlite/3.37.2/lib/libsqlite3.dylib, building for macOS-x86_64 but attempting to link with file built for macOS-arm64
ld: warning: ignoring file /Users/jay/.frum/versions/3.1.0/lib/libruby.3.1-static.a, building for macOS-x86_64 but attempting to link with file built for macOS-arm64
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: /*top*/
4: extern int t(void);
5: int main(int argc, char **argv)
6: {
7: if (argc > 1000000) {
8: int (* volatile tp)(void)=(int (*)(void))&t;
9: printf("%d", (*tp)());
10: }
11:
12: return !!argv[argc];
13: }
14:
15: int t(void) { ; return 0; }
/* end */
--------------------
find_library: checking for sqlite3_libversion_number() in -lsqlite3... -------------------- no
DYLD_FALLBACK_LIBRARY_PATH=.:/Users/jay/.frum/versions/3.1.0/lib "clang -o conftest -I/Users/jay/.frum/versions/3.1.0/include/ruby-3.1.0/arm64-darwin21 -I/Users/jay/.frum/versions/3.1.0/include/ruby-3.1.0/ruby/backward -I/Users/jay/.frum/versions/3.1.0/include/ruby-3.1.0 -I. -I/opt/homebrew/Cellar/sqlite/3.37.2/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -fdeclspec -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wdeprecated-declarations -Wdivision-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wshorten-64-to-32 -Wwrite-strings -Wold-style-definition -Wmissing-noreturn -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wunused-variable -Wextra-tokens -Wundef -pipe conftest.c -L. -L/Users/jay/.frum/versions/3.1.0/lib -L. -fstack-protector-strong -L/usr/local/lib -L/opt/homebrew/Cellar/sqlite/3.37.2/lib -ldl -lpthread -lsqlite3 -lruby.3.1-static -framework CoreFoundation -lpthread -ldl -lobjc -lsqlite3 -ldl -lpthread -lsqlite3 "
conftest.c:14:57: error: use of undeclared identifier 'sqlite3_libversion_number'
int t(void) { void ((*volatile p)()); p = (void ((*)()))sqlite3_libversion_number; return !p; }
^
1 error generated.
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: /*top*/
4: extern int t(void);
5: int main(int argc, char **argv)
6: {
7: if (argc > 1000000) {
8: int (* volatile tp)(void)=(int (*)(void))&t;
9: printf("%d", (*tp)());
10: }
11:
12: return !!argv[argc];
13: }
14: int t(void) { void ((*volatile p)()); p = (void ((*)()))sqlite3_libversion_number; return !p; }
/* end */
DYLD_FALLBACK_LIBRARY_PATH=.:/Users/jay/.frum/versions/3.1.0/lib "clang -o conftest -I/Users/jay/.frum/versions/3.1.0/include/ruby-3.1.0/arm64-darwin21 -I/Users/jay/.frum/versions/3.1.0/include/ruby-3.1.0/ruby/backward -I/Users/jay/.frum/versions/3.1.0/include/ruby-3.1.0 -I. -I/opt/homebrew/Cellar/sqlite/3.37.2/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -fdeclspec -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wdeprecated-declarations -Wdivision-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wshorten-64-to-32 -Wwrite-strings -Wold-style-definition -Wmissing-noreturn -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wunused-variable -Wextra-tokens -Wundef -pipe conftest.c -L. -L/Users/jay/.frum/versions/3.1.0/lib -L. -fstack-protector-strong -L/usr/local/lib -L/opt/homebrew/Cellar/sqlite/3.37.2/lib -ldl -lpthread -lsqlite3 -lruby.3.1-static -framework CoreFoundation -lpthread -ldl -lobjc -lsqlite3 -ldl -lpthread -lsqlite3 "
ld: warning: ignoring file /opt/homebrew/Cellar/sqlite/3.37.2/lib/libsqlite3.dylib, building for macOS-x86_64 but attempting to link with file built for macOS-arm64
ld: warning: ignoring file /Users/jay/.frum/versions/3.1.0/lib/libruby.3.1-static.a, building for macOS-x86_64 but attempting to link with file built for macOS-arm64
Undefined symbols for architecture x86_64:
"_sqlite3_libversion_number", referenced from:
_t in conftest-593102.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: /*top*/
4: extern int t(void);
5: int main(int argc, char **argv)
6: {
7: if (argc > 1000000) {
8: int (* volatile tp)(void)=(int (*)(void))&t;
9: printf("%d", (*tp)());
10: }
11:
12: return !!argv[argc];
13: }
14: extern void sqlite3_libversion_number();
15: int t(void) { sqlite3_libversion_number(); return 0; }
/* end */
--------------------
I installed sqlite3 via Homebrew, with the following output:
sqlite: stable 3.37.2 (bottled) [keg-only]
Command-line interface for SQLite
https://sqlite.org/index.html
/opt/homebrew/Cellar/sqlite/3.37.2 (11 files, 4.3MB)
Poured from bottle on 2022-02-15 at 13:01:01
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/sqlite.rb
License: blessing
==> Dependencies
Required: readline ✔
==> Caveats
sqlite is keg-only, which means it was not symlinked into /opt/homebrew,
because macOS already provides this software and installing another version in
parallel can cause all kinds of trouble.
If you need to have sqlite first in your PATH, run:
echo 'export PATH="/opt/homebrew/opt/sqlite/bin:$PATH"' >> ~/.zshrc
For compilers to find sqlite you may need to set:
export LDFLAGS="-L/opt/homebrew/opt/sqlite/lib"
export CPPFLAGS="-I/opt/homebrew/opt/sqlite/include"
For pkg-config to find sqlite you may need to set:
export PKG_CONFIG_PATH="/opt/homebrew/opt/sqlite/lib/pkgconfig"
Taking the advice from Homebrew, I set bundle config build.sqlite3 --with-sqlite3-include=$(brew --prefix sqlite)/include --with-sqlite3-lib=$(brew --prefix sqlite)/lib but I got what appears to be the same result.
Can somebody please tell me what's the correct way to install this gem given this setup? Thank you very much.

In case anyone else stumbles along this, I had a similar issue. I have my dev environment set up part emulated and part ARM.
To navigate this, I have two different versions of Homebrew installed. One version is for M1 architecture, which lives in /opt/homebrew/. And I have a version of Homebrew that runs on x86 architecture that lives in /usr/local/Homebrew.
I have the x86 version aliased to ibrew, like this:
alias ibrew='arch --x86_64 /usr/local/Homebrew/bin/brew'
(See this answer for more info on running two separate Homebrew versions.)
OP's bundle config command worked for me, I just had to swap out brew for ibrew:
bundle config build.sqlite3 --with-sqlite3-include=$(brew --prefix sqlite)/include --with-sqlite3-lib=$(brew --prefix sqlite)/lib

have you installed sqilte3 already? it said
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).
so try brew install sqlite first
https://formulae.brew.sh/formula/sqlite

Related

Error installing nio4r 2.1.0 and bundler cannot continue

I'm trying to install and try a new project on rails but I can't even create a new project for this error.
the mkmf.log file shows:
"gcc -o conftest.exe -IC:/RailsInstaller/Ruby2.3.0/include/ruby-2.3.0/i386-mingw32 -IC:/RailsInstaller/Ruby2.3.0/include/ruby-2.3.0/ruby/backward -IC:/RailsInstaller/Ruby2.3.0/include/ruby-2.3.0 -I. -DFD_SETSIZE=2048 -D_WIN32_WINNT=0x0501 -D__MINGW_USE_VC2005_COMPAT -D_FILE_OFFSET_BITS=64 -O3 -fno-omit-frame-pointer -fno-fast-math -g -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat conftest.c -L. -LC:/RailsInstaller/Ruby2.3.0/lib -L. -lmsvcrt-ruby230 -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 */
please help...

Error on installing dm-postgres-adapter gem (PostgreSQL build environment not found)

I need to implement a small ruby webapp on Windows 7 (64bit) using sinatra and datamapper with Postgres. To get started I installed Ruby 2.1.7 (x64) and DevKit DevKit mingw64-64-4.7.2 via Rubyinstaller.org and installed postgresql-9.4.4-3-windows-x64 via official site. Following this Datamapper guide I first tried to install dm-postgres-adapter.
This is what I get:
C:\Ruby DevKit>gem install dm-postgres-adapter
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
ERROR: Error installing dm-postgres-adapter:
ERROR: Failed to build gem native extension.
C:/Ruby21-x64/bin/ruby.exe extconf.rb
checking for main() in -lpq... no
checking for main() in -llibpq... no
*** 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:/Ruby21-x64/bin/ruby
--with-pgsql-server-dir
--without-pgsql-server-dir
--with-pgsql-server-include
--without-pgsql-server-include=${pgsql-server-dir}/include
--with-pgsql-server-lib
--without-pgsql-server-lib=${pgsql-server-dir}/lib
--with-pgsql-client-dir
--without-pgsql-client-dir
--with-pgsql-client-include
--without-pgsql-client-include=${pgsql-client-dir}/include
--with-pgsql-client-lib
--without-pgsql-client-lib=${pgsql-client-dir}/lib
--with-pgsql-win32-dir
--without-pgsql-win32-dir
--with-pgsql-win32-include
--without-pgsql-win32-include=${pgsql-win32-dir}/include
--with-pgsql-win32-lib
--without-pgsql-win32-lib=${pgsql-win32-dir}/lib
--with-pqlib
--without-pqlib
--with-libpqlib
--without-libpqlib
Could not find PostgreSQL build environment (libraries & headers): Makefile not
created
extconf failed, exit code 1
Gem files will remain installed in C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/do_pos
tgres-0.10.16 for inspection.
Results logged to C:/Ruby21-x64/lib/ruby/gems/2.1.0/extensions/x64-mingw32/2.1.0
/do_postgres-0.10.16/gem_make.out
Content of C:\Ruby21-x64\lib\ruby\gems\2.1.0\extensions\x64-mingw32\2.1.0\do_postgres-0.10.16\mkmf.log is:
have_library: checking for main() in -lpq... -------------------- no
"x86_64-w64-mingw32-gcc -o conftest.exe -IC:/Ruby21-x64/include/ruby-2.1.0/x64-mingw32 -IC:/Ruby21-x64/include/ruby-2.1.0/ruby/backward -IC:/Ruby21-x64/include/ruby-2.1.0 -I. -DFD_SETSIZE=2048 -D_WIN32_WINNT=0x0501 -D__MINGW_USE_VC2005_COMPAT -D_FILE_OFFSET_BITS=64 -O3 -fno-omit-frame-pointer -fno-fast-math -g -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -UENABLE_NLS -DHAVE_GETTIMEOFDAY -DHAVE_CRYPT -DHAVE_NO_DATETIME_NEWBANG conftest.c -L. -LC:/Ruby21-x64/lib -L. -lx64-msvcrt-ruby210 -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:/Ruby21-x64/include/ruby-2.1.0/x64-mingw32 -IC:/Ruby21-x64/include/ruby-2.1.0/ruby/backward -IC:/Ruby21-x64/include/ruby-2.1.0 -I. -DFD_SETSIZE=2048 -D_WIN32_WINNT=0x0501 -D__MINGW_USE_VC2005_COMPAT -D_FILE_OFFSET_BITS=64 -O3 -fno-omit-frame-pointer -fno-fast-math -g -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -UENABLE_NLS -DHAVE_GETTIMEOFDAY -DHAVE_CRYPT -DHAVE_NO_DATETIME_NEWBANG conftest.c -L. -LC:/Ruby21-x64/lib -L. -lx64-msvcrt-ruby210 -lpq -lshell32 -lws2_32 -liphlpapi -limagehlp -lshlwapi "
conftest.c: In function 't':
conftest.c:16:32: warning: variable 'p' set but not used [-Wunused-but-set-variable]
c:/ruby devkit/mingw/bin/../lib/gcc/x86_64-w64-mingw32/4.7.2/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lpq
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: int t(void) { void ((*volatile p)()); p = (void ((*)()))main; return 0; }
/* end */
"x86_64-w64-mingw32-gcc -o conftest.exe -IC:/Ruby21-x64/include/ruby-2.1.0/x64-mingw32 -IC:/Ruby21-x64/include/ruby-2.1.0/ruby/backward -IC:/Ruby21-x64/include/ruby-2.1.0 -I. -DFD_SETSIZE=2048 -D_WIN32_WINNT=0x0501 -D__MINGW_USE_VC2005_COMPAT -D_FILE_OFFSET_BITS=64 -O3 -fno-omit-frame-pointer -fno-fast-math -g -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -UENABLE_NLS -DHAVE_GETTIMEOFDAY -DHAVE_CRYPT -DHAVE_NO_DATETIME_NEWBANG conftest.c -L. -LC:/Ruby21-x64/lib -L. -lx64-msvcrt-ruby210 -lpq -lshell32 -lws2_32 -liphlpapi -limagehlp -lshlwapi "
conftest.c: In function 't':
conftest.c:16:1: error: too few arguments to function 'main'
conftest.c:8:5: note: declared here
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) { main(); return 0; }
/* end */
--------------------
have_library: checking for main() in -llibpq... -------------------- no
"x86_64-w64-mingw32-gcc -o conftest.exe -IC:/Ruby21-x64/include/ruby-2.1.0/x64-mingw32 -IC:/Ruby21-x64/include/ruby-2.1.0/ruby/backward -IC:/Ruby21-x64/include/ruby-2.1.0 -I. -DFD_SETSIZE=2048 -D_WIN32_WINNT=0x0501 -D__MINGW_USE_VC2005_COMPAT -D_FILE_OFFSET_BITS=64 -O3 -fno-omit-frame-pointer -fno-fast-math -g -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -UENABLE_NLS -DHAVE_GETTIMEOFDAY -DHAVE_CRYPT -DHAVE_NO_DATETIME_NEWBANG conftest.c -L. -LC:/Ruby21-x64/lib -L. -lx64-msvcrt-ruby210 -llibpq -lshell32 -lws2_32 -liphlpapi -limagehlp -lshlwapi "
conftest.c: In function 't':
conftest.c:16:32: warning: variable 'p' set but not used [-Wunused-but-set-variable]
c:/ruby devkit/mingw/bin/../lib/gcc/x86_64-w64-mingw32/4.7.2/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -llibpq
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: int t(void) { void ((*volatile p)()); p = (void ((*)()))main; return 0; }
/* end */
"x86_64-w64-mingw32-gcc -o conftest.exe -IC:/Ruby21-x64/include/ruby-2.1.0/x64-mingw32 -IC:/Ruby21-x64/include/ruby-2.1.0/ruby/backward -IC:/Ruby21-x64/include/ruby-2.1.0 -I. -DFD_SETSIZE=2048 -D_WIN32_WINNT=0x0501 -D__MINGW_USE_VC2005_COMPAT -D_FILE_OFFSET_BITS=64 -O3 -fno-omit-frame-pointer -fno-fast-math -g -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -UENABLE_NLS -DHAVE_GETTIMEOFDAY -DHAVE_CRYPT -DHAVE_NO_DATETIME_NEWBANG conftest.c -L. -LC:/Ruby21-x64/lib -L. -lx64-msvcrt-ruby210 -llibpq -lshell32 -lws2_32 -liphlpapi -limagehlp -lshlwapi "
conftest.c: In function 't':
conftest.c:16:1: error: too few arguments to function 'main'
conftest.c:8:5: note: declared here
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) { main(); return 0; }
/* end */
--------------------
As it is pointed out by the error message I tried to use several configuration options trying to specify the PostgreSQL installation path i.e.
gem install -p dm-postgres-adapter -- --with-pgsql-server-dir=C:/Program Files/PostgreSQL/9.4
gem install -p dm-postgres-adapter -- --with-pgsql-server-include=C:/Program Files/PostgreSQL/9.4/include
gem install -p dm-postgres-adapter -- --with-pgsql-win32-dir=C:/Program Files/PostgreSQL/9.4
but nothing changed the outcome. After some research I found out that on Linux this problem is often solved by RPM-installing some postgres-dev package. But what to do on Windows?
Any help would be greatly appreciated! Thank you!
Well, I hope this is kind of an answer:
After reading a bit about gem/devkit problems under Windows 64bit systems I decided to download/install everything (postgres, rubyinstaller, devkit) for 32bit (x86). dm-postgres-adapter, data_mapper and all dependencies installed smoothly.

Ruby on Rails and Bundle install of wubook_wired app

When I execute the command bundle, appears compilation errors that I dont
found a solution.
I work with os Windows 10 and the version of Ruby and Rails are:
ruby:
bin: C:/RailsInstaller/Ruby2.0.0/bin/ruby.exe
version: ruby 2.1.5p273 (2014-11-13 revision 48405) [i386-mingw32]
rails:
bin: C:/RailsInstaller/Ruby2.0.0/bin/rails.bat
version: Rails 4.1.8
The Gem that I intend to install on my project is wubook_wired that is for WuBook API integration , called "Wired":
https://github.com/eilers/wubook_wired
The error that appear is:
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
C:/RailsInstaller/Ruby2.1.0/bin/ruby.exe extconf.rb
checking for expat.h... yes
checking for XML_ParserCreate() in -lexpat... no
checking for XML_ParserCreate() in -lxmltok... no
*** 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.1.0/bin/ruby
--with-perl-enc-map
--without-perl-enc-map
--with-expat-dir
--without-expat-dir
--with-expat-include
--without-expat-include=${expat-dir}/include
--with-expat-lib
--without-expat-lib=${expat-dir}/lib
--with-expatlib
--without-expatlib
--with-xmltoklib
--without-xmltoklib
extconf failed, exit code 1
Gem files will remain installed in C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/xmlparser-0.7.2.1 for inspection.
Results logged to C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/extensions/x86-mingw32/2.1.0/xmlparser-0.7.2.1/gem_make.out
An error occurred while installing xmlparser (0.7.2.1), and Bundler cannot
continue.
Make sure that `gem install xmlparser -v '0.7.2.1'` succeeds before bundling.
The mkmf.log file is:
have_library: checking for XML_ParserCreate() in -lexpat... -------------------- no
"gcc -o conftest.exe -IC:/RailsInstaller/Ruby2.1.0/include/ruby-2.1.0/i386-mingw32 -IC:/RailsInstaller/Ruby2.1.0/include/ruby-2.1.0/ruby/backward -IC:/RailsInstaller/Ruby2.1.0/include/ruby-2.1.0 -I. -DFD_SETSIZE=2048 -D_WIN32_WINNT=0x0501 -D__MINGW_USE_VC2005_COMPAT -D_FILE_OFFSET_BITS=64 -O3 -fno-omit-frame-pointer -fno-fast-math -g -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration conftest.c -L. -LC:/RailsInstaller/Ruby2.1.0/lib -L. -lmsvcrt-ruby210 -lexpat -lshell32 -lws2_32 -liphlpapi -limagehlp -lshlwapi "
conftest.c: In function 't':
conftest.c:16:57: error: 'XML_ParserCreate' undeclared (first use in this function)
conftest.c:16:57: note: each undeclared identifier is reported only once for each function it appears in
conftest.c:16:32: warning: variable 'p' set but not used [-Wunused-but-set-variable]
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: #include
4: #include
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 ((*)()))XML_ParserCreate; return 0; }
/* end */
"gcc -o conftest.exe -IC:/RailsInstaller/Ruby2.1.0/include/ruby-2.1.0/i386-mingw32 -IC:/RailsInstaller/Ruby2.1.0/include/ruby-2.1.0/ruby/backward -IC:/RailsInstaller/Ruby2.1.0/include/ruby-2.1.0 -I. -DFD_SETSIZE=2048 -D_WIN32_WINNT=0x0501 -D__MINGW_USE_VC2005_COMPAT -D_FILE_OFFSET_BITS=64 -O3 -fno-omit-frame-pointer -fno-fast-math -g -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration conftest.c -L. -LC:/RailsInstaller/Ruby2.1.0/lib -L. -lmsvcrt-ruby210 -lexpat -lshell32 -lws2_32 -liphlpapi -limagehlp -lshlwapi "
conftest.c: In function 't':
conftest.c:16:1: warning: implicit declaration of function 'XML_ParserCreate' [-Wimplicit-function-declaration]
c:/railsinstaller/devkit/mingw/bin/../lib/gcc/i686-w64-mingw32/4.7.2/../../../../i686-w64-mingw32/bin/ld.exe: cannot find -lexpat
collect2.exe: error: ld returned 1 exit status
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: #include
4: #include
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) { XML_ParserCreate(); return 0; }
/* end */
--------------------
have_library: checking for XML_ParserCreate() in -lxmltok... -------------------- no
"gcc -o conftest.exe -IC:/RailsInstaller/Ruby2.1.0/include/ruby-2.1.0/i386-mingw32 -IC:/RailsInstaller/Ruby2.1.0/include/ruby-2.1.0/ruby/backward -IC:/RailsInstaller/Ruby2.1.0/include/ruby-2.1.0 -I. -DFD_SETSIZE=2048 -D_WIN32_WINNT=0x0501 -D__MINGW_USE_VC2005_COMPAT -D_FILE_OFFSET_BITS=64 -O3 -fno-omit-frame-pointer -fno-fast-math -g -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration conftest.c -L. -LC:/RailsInstaller/Ruby2.1.0/lib -L. -lmsvcrt-ruby210 -lxmltok -lshell32 -lws2_32 -liphlpapi -limagehlp -lshlwapi "
conftest.c: In function 't':
conftest.c:16:57: error: 'XML_ParserCreate' undeclared (first use in this function)
conftest.c:16:57: note: each undeclared identifier is reported only once for each function it appears in
conftest.c:16:32: warning: variable 'p' set but not used [-Wunused-but-set-variable]
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: #include
4: #include
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 ((*)()))
XML_ParserCreate; return 0; }
/* end */
"gcc -o conftest.exe -IC:/RailsInstaller/Ruby2.1.0/include/ruby-2.1.0/i386-mingw32 -IC:/RailsInstaller/Ruby2.1.0/include/ruby-2.1.0/ruby/backward -IC:/RailsInstaller/Ruby2.1.0/include/ruby-2.1.0 -I. -DFD_SETSIZE=2048 -D_WIN32_WINNT=0x0501 -D__MINGW_USE_VC2005_COMPAT -D_FILE_OFFSET_BITS=64 -O3 -fno-omit-frame-pointer -fno-fast-math -g -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration conftest.c -L. -LC:/RailsInstaller/Ruby2.1.0/lib -L. -lmsvcrt-ruby210 -lxmltok -lshell32 -lws2_32 -liphlpapi -limagehlp -lshlwapi "
conftest.c: In function 't':
conftest.c:16:1: warning: implicit declaration of function 'XML_ParserCreate' [-Wimplicit-function-declaration]
c:/railsinstaller/devkit/mingw/bin/../lib/gcc/i686-w64-mingw32/4.7.2/../../../../i686-w64-mingw32/bin/ld.exe: cannot find -lxmltok
collect2.exe: error: ld returned 1 exit status
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: #include
4: #include
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) { XML_ParserCreate(); return 0; }
/* end */
I would be very grateful for a help.
I did the next steps for solution:
Because I don't found the libexpat.a in the Devkit folder (c:\RailsInstaller\DevKit):
The text "./i686-w64-mingw32/bin/ld.exe: cannot find -lexpat" means a reference the libexpat.a file.
I download the mingw-w64-install.exe and then I install it.
Next I run command bundle but not yet correct.
Later I copy the libexpat.a file from the "C:\Program Files (x86)\mingw-w64\i686-5.1.0-posix-dwarf-rt_v4-rev0\mingw32\opt\lib" folder where the mingw-w64 is installed, to the "C:\RailsInstaller\DevKit\mingw\i686-w64-mingw32\lib" folder.
And "Eureka": The command bundle running ok.
Thats all.
Please if anyone has a better solution.....

Gem installation fails after use of Bundler for cups gem

So I'm currently working on a project with RoR in a linux environment that involves a print server. We're using CUPS (see http://cups.org). I'm trying to bundle all the various gems that I'm using but this is the only one that doesn't work.
I've cp'd the command prompt output and the mkmf.log from the installation below, cutting out absolute file extensions and replacing the middle bits with "***". I'm using rbenv, so file paths should be obvious.
Command Prompt
Building native extensions. This could take a while...
ERROR: Error installing cups:
ERROR: Failed to build gem native extension.
checking for main() in -lcups... no
*** 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=/home/***/2.0.0-p481/bin/ruby
--with-cupslib
--without-cupslib
Couldn't find CUPS libraries on your system. Check they're installed and in your path.
mkmf.log
have_library: checking for main() in -lcups... -------------------- no
"gcc -o conftest -I/home/***/ruby-2.0.0/x86_64-linux -I/home/***/ruby-2.0.0/ruby/backward -I/home/***/ruby-2.0.0 -I. -I/home/***/2.0.0-p481/include -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration conftest.c -L. -L/home/***/2.0.0-p481/lib -Wl,-R/home/***/2.0.0-p481/lib -L. -L/home/***/2.0.0-p481/lib -fstack-protector -rdynamic -Wl,-export-dynamic -Wl,-R -Wl,/home/***/2.0.0-p481/lib -L/home/***/2.0.0-p481/lib -lruby-static -lpthread -lrt -ldl -lcrypt -lm -lc"
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main(int argc, char **argv)
4: {
5: return 0;
6: }
/* end */
"gcc -o conftest -I/home/***/ruby-2.0.0/x86_64-linux -I/home/***/ruby-2.0.0/ruby/backward -I/home/***/ruby-2.0.0 -I. -I/home/***/2.0.0-p481/include -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration conftest.c -L. -L/home/***/2.0.0-p481/lib -Wl,-R/home/***/2.0.0-p481/lib -L. -L/home/***/2.0.0-p481/lib -fstack-protector -rdynamic -Wl,-export-dynamic -Wl,-R -Wl,/home/***/2.0.0-p481/lib -L/home/***/2.0.0-p481/lib -lruby-static -lcups -lpthread -lrt -ldl -lcrypt -lm -lc"
conftest.c: In function ‘t’:
conftest.c:5:57: error: ‘main’ undeclared (first use in this function)
int t(void) { void ((*volatile p)()); p strong text= (void ((*)()))main; return 0; }
^
conftest.c:5:57: note: each undeclared identifier is reported only once for each function it appears in
conftest.c:5:32: warning: variable ‘p’ set but not used [-Wunused-but-set-variable]
int t(void) { void ((*volatile p)()); p = (void ((*)()))main; return 0; }
^
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: /*top*/
4: extern int t(void);
5: int t(void) { void ((*volatile p)()); p = (void ((*)()))main; return 0; }
6: int main(int argc, char **argv)
7: {
8: if (argc > 1000000) {
9: printf("%p", &t);
10: }
11:
12: return 0;
13: }
/* end */
"gcc -o conftest -I/home/***/ruby-2.0.0/x86_64-linux -I/home/***/ruby-2.0.0/ruby/backward -I/home/***/ruby-2.0.0 -I. -I/home/***/2.0.0-p481/include -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration conftest.c -L. -L/home/***/2.0.0-p481/lib -Wl,-R/home/***/2.0.0-p481/lib -L. -L/home/***/2.0.0-p481/lib -fstack-protector -rdynamic -Wl,-export-dynamic -Wl,-R -Wl,/home/***/2.0.0-p481/lib -L/home/***/2.0.0-p481/lib -lruby-static -lcups -lpthread -lrt -ldl -lcrypt -lm -lc"
conftest.c: In function ‘t’:
conftest.c:5:1: warning: implicit declaration of function ‘main’ [-Wimplicit-function-declaration]
int t(void) { main(); return 0; }
^
/usr/bin/ld: cannot find -lcups
collect2: error: ld returned 1 exit status
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: /*top*/
4: extern int t(void);
5: int t(void) { main(); return 0; }
6: int main(int argc, char **argv)
7: {
8: if (argc > 1000000) {
9: printf("%p", &t);
10: }
11:
12: return 0;
13: }
/* end */
--------------------
Thanks in advance for any help
Most other answers seem to either cover rvm or be irrelevant questions that focus more on the distinction between bundle and gem
You answer is in the first log: Couldn't find CUPS libraries on your system. Check they're installed and in your path.
If you see the gem source here, that message appears when the gem builder is checking for the dependencies.
And according to the gem's documentation you need to install these packages:
sudo apt-get install libcupsys2-dev
or equivalents, depending on your system.
OBS: As #errata pointed out, check to see if you have the gcc tools correctly installed.
You need the cups library installed
sudo apt-get install libcupsys2-dev
there are more library
https://wiki.qt.io/Compile_Qt_4.7_on_Ubuntu_10.10

I get "failed to build gem native extension." when I'm trying to install mysql2 (OSX)

When I'm trying to install mysql2 I get error mysql.h is missing. But when I try to install mysql (needed mysql-devel) then I get warning "mysql is already installed". So why I get the error message? THX for reply! (RoR 2.0.0)
sudo gem install mysql2 -v '0.3.11'
Building native extensions. This could take a while...
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
/Users/michaljurnik/.rvm/rubies/ruby-1.9.3-p448/bin/ruby extconf.rb
checking for rb_thread_blocking_region()... yes
checking for rb_wait_for_single_fd()... yes
checking for mysql.h... no
checking for mysql/mysql.h... no
-----
mysql.h is missing. please check your installation of mysql and try again.
-----
*** 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
--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=/Users/michaljurnik/.rvm/rubies/ruby-1.9.3-p448/bin/ruby
--with-mysql-config
--without-mysql-config
Gem files will remain installed in /Users/michaljurnik/.rvm/gems/ruby-1.9.3- p448/gems/mysql2-0.3.11 for inspection.
Results logged to /Users/michaljurnik/.rvm/gems/ruby-1.9.3-p448/gems/mysql2-0.3.11/ext/mysql2/gem_make.out
And installation of mysql
brew install mysql
Warning: mysql-5.6.12 already installed
mkmf.log:
have_func: checking for rb_thread_blocking_region()... -------------------- yes
"/usr/local/bin/gcc-4.2 -o conftest -I/Users/michaljurnik/.rvm/rubies/ruby-1.9.3-p448/include/ruby-1.9.1/x86_64-darwin12.4.0 -I/Users/michaljurnik/.rvm/rubies/ruby-1.9.3-p448/include/ruby-1.9.1/ruby/backward -I/Users/michaljurnik/.rvm/rubies/ruby-1.9.3-p448/include/ruby-1.9.1 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -I/usr/local/opt/libyaml/include -I/usr/local/opt/readline/include -I/usr/local/opt/libksba/include -I/usr/local/opt/openssl/include -O3 -ggdb -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -fno-common -pipe conftest.c -L. -L/Users/michaljurnik/.rvm/rubies/ruby-1.9.3-p448/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl/lib -L. -L/usr/local/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl/lib -lruby.1.9.1 -lpthread -ldl -lobjc "
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main(int argc, char **argv)
4: {
5: return 0;
6: }
/* end */
"/usr/local/bin/gcc-4.2 -o conftest -I/Users/michaljurnik/.rvm/rubies/ruby-1.9.3-p448/include/ruby-1.9.1/x86_64-darwin12.4.0 -I/Users/michaljurnik/.rvm/rubies/ruby-1.9.3-p448/include/ruby-1.9.1/ruby/backward -I/Users/michaljurnik/.rvm/rubies/ruby-1.9.3-p448/include/ruby-1.9.1 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -I/usr/local/opt/libyaml/include -I/usr/local/opt/readline/include -I/usr/local/opt/libksba/include -I/usr/local/opt/openssl/include -O3 -ggdb -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -fno-common -pipe conftest.c -L. -L/Users/michaljurnik/.rvm/rubies/ruby-1.9.3-p448/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl/lib -L. -L/usr/local/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl/lib -lruby.1.9.1 -lpthread -ldl -lobjc "
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: /*top*/
4: int t() { void ((*volatile p)()); p = (void ((*)()))rb_thread_blocking_region; return 0; }
5: int main(int argc, char **argv)
6: {
7: if (argc > 1000000) {
8: printf("%p", &t);
9: }
10:
11: return 0;
12: }
/* end */
--------------------
have_func: checking for rb_wait_for_single_fd()... -------------------- yes
"/usr/local/bin/gcc-4.2 -o conftest -I/Users/michaljurnik/.rvm/rubies/ruby-1.9.3-p448/include/ruby-1.9.1/x86_64-darwin12.4.0 -I/Users/michaljurnik/.rvm/rubies/ruby-1.9.3-p448/include/ruby-1.9.1/ruby/backward -I/Users/michaljurnik/.rvm/rubies/ruby-1.9.3-p448/include/ruby-1.9.1 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -I/usr/local/opt/libyaml/include -I/usr/local/opt/readline/include -I/usr/local/opt/libksba/include -I/usr/local/opt/openssl/include -O3 -ggdb -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -fno-common -pipe conftest.c -L. -L/Users/michaljurnik/.rvm/rubies/ruby-1.9.3-p448/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl/lib -L. -L/usr/local/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl/lib -lruby.1.9.1 -lpthread -ldl -lobjc "
conftest.c: In function ‘t’:
conftest.c:4: error: ‘rb_wait_for_single_fd’ undeclared (first use in this function)
conftest.c:4: error: (Each undeclared identifier is reported only once
conftest.c:4: error: for each function it appears in.)
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: /*top*/
4: int t() { void ((*volatile p)()); p = (void ((*)()))rb_wait_for_single_fd; return 0; }
5: int main(int argc, char **argv)
6: {
7: if (argc > 1000000) {
8: printf("%p", &t);
9: }
10:
11: return 0;
12: }
/* end */
"/usr/local/bin/gcc-4.2 -o conftest -I/Users/michaljurnik/.rvm/rubies/ruby-1.9.3-p448/include/ruby-1.9.1/x86_64-darwin12.4.0 -I/Users/michaljurnik/.rvm/rubies/ruby-1.9.3-p448/include/ruby-1.9.1/ruby/backward -I/Users/michaljurnik/.rvm/rubies/ruby-1.9.3-p448/include/ruby-1.9.1 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -I/usr/local/opt/libyaml/include -I/usr/local/opt/readline/include -I/usr/local/opt/libksba/include -I/usr/local/opt/openssl/include -O3 -ggdb -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -fno-common -pipe conftest.c -L. -L/Users/michaljurnik/.rvm/rubies/ruby-1.9.3-p448/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl/lib -L. -L/usr/local/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl/lib -lruby.1.9.1 -lpthread -ldl -lobjc "
conftest.c: In function ‘t’:
conftest.c:4: warning: implicit declaration of function ‘rb_wait_for_single_fd’
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: /*top*/
4: int t() { rb_wait_for_single_fd(); return 0; }
5: int main(int argc, char **argv)
6: {
7: if (argc > 1000000) {
8: printf("%p", &t);
9: }
10:
11: return 0;
12: }
/* end */
--------------------
have_header: checking for mysql.h... -------------------- no
"/usr/local/bin/gcc-4.2 -E -I/Users/michaljurnik/.rvm/rubies/ruby-1.9.3-p448/include/ruby-1.9.1/x86_64-darwin12.4.0 -I/Users/michaljurnik/.rvm/rubies/ruby-1.9.3-p448/include/ruby-1.9.1/ruby/backward -I/Users/michaljurnik/.rvm/rubies/ruby-1.9.3-p448/include/ruby-1.9.1 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -I/usr/local/opt/libyaml/include -I/usr/local/opt/readline/include -I/usr/local/opt/libksba/include -I/usr/local/opt/openssl/include -I/usr/local/Cellar/mysql/5.6.12/include -Wno-null-conversion -Os -g -fno-strict-aliasing -O3 -ggdb -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -fno-common -pipe conftest.c -o conftest.i"
cc1: error: unrecognized command line option "-Wno-null-conversion"
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: #include <mysql.h>
/* end */
--------------------
have_header: checking for mysql/mysql.h... -------------------- no
"/usr/local/bin/gcc-4.2 -E -I/Users/michaljurnik/.rvm/rubies/ruby-1.9.3-p448/include/ruby-1.9.1/x86_64-darwin12.4.0 -I/Users/michaljurnik/.rvm/rubies/ruby-1.9.3-p448/include/ruby-1.9.1/ruby/backward -I/Users/michaljurnik/.rvm/rubies/ruby-1.9.3-p448/include/ruby-1.9.1 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -I/usr/local/opt/libyaml/include -I/usr/local/opt/readline/include -I/usr/local/opt/libksba/include -I/usr/local/opt/openssl/include -I/usr/local/Cellar/mysql/5.6.12/include -Wno-null-conversion -Os -g -fno-strict-aliasing -O3 -ggdb -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -fno-common -pipe conftest.c -o conftest.i"
cc1: error: unrecognized command line option "-Wno-null-conversion"
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: #include <mysql/mysql.h>
/* end */
--------------------
Try to install only mysql without the "2":
gem install mysql
The solution is using sudo apt-get install libmysqlclient-dev, because it requires mysql development libraries to be installed on the server.

Resources