Search code examples
ruby-on-railsrubyrubygemsbundlerrbenv

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


Solution

  • 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.