zerebubuth / cgimap-ruby Goto Github PK
View Code? Open in Web Editor NEWA gem exposing cgimap functionality to Ruby.
License: GNU General Public License v2.0
A gem exposing cgimap functionality to Ruby.
License: GNU General Public License v2.0
When writing gems it's best to avoid using Gemfile.lock and instead put dependencies into a .gemspec file. Further reading at http://yehudakatz.com/2010/12/16/clarifying-the-roles-of-the-gemspec-and-gemfile/
We need to
gemspec
Compiling fails, but I'm not sure if the output is misleading, since it certainly doesn't match the details in mkmf.log
checking for std::string() in -lstdc++... *** ../../../../ext/cgimap/extconf.rb failed ***
vs
/usr/bin/ld: cannot find -lrice
Full outputs below:
vagrant@cgimap-ruby:~/cgimap-ruby$ bundle exec rake compile
mkdir -p lib/cgimap
mkdir -p tmp/x86_64-linux/cgimap/1.9.3
cd tmp/x86_64-linux/cgimap/1.9.3
/usr/bin/ruby1.9.1 -I. ../../../../ext/cgimap/extconf.rb
checking for std::string() in -lstdc++... *** ../../../../ext/cgimap/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=../../../../ext/cgimap
--curdir
--ruby=/usr/bin/ruby1.9.1
--with-libpath
--without-libpath
--with-cgimap-dir
--without-cgimap-dir
--with-cgimap-include
--without-cgimap-include=${cgimap-dir}/include
--with-cgimap-lib
--without-cgimap-lib=${cgimap-dir}/lib
--with-stdc++lib
--without-stdc++lib
/usr/lib/ruby/1.9.1/mkmf.rb:381:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from /usr/lib/ruby/1.9.1/mkmf.rb:461:in `try_link0'
from /usr/lib/ruby/1.9.1/mkmf.rb:476:in `try_link'
from /usr/lib/ruby/1.9.1/mkmf.rb:619:in `try_func'
from /usr/lib/ruby/1.9.1/mkmf.rb:845:in `block in have_library'
from /usr/lib/ruby/1.9.1/mkmf.rb:790:in `block in checking_for'
from /usr/lib/ruby/1.9.1/mkmf.rb:284:in `block (2 levels) in postpone'
from /usr/lib/ruby/1.9.1/mkmf.rb:254:in `open'
from /usr/lib/ruby/1.9.1/mkmf.rb:284:in `block in postpone'
from /usr/lib/ruby/1.9.1/mkmf.rb:254:in `open'
from /usr/lib/ruby/1.9.1/mkmf.rb:280:in `postpone'
from /usr/lib/ruby/1.9.1/mkmf.rb:789:in `checking_for'
from /usr/lib/ruby/1.9.1/mkmf.rb:840:in `have_library'
from ../../../../ext/cgimap/extconf.rb:8:in `<main>'
rake aborted!
Command failed with status (1): [/usr/bin/ruby1.9.1 -I. ../../../../ext/cgi...]
/var/lib/gems/1.9.1/gems/rake-compiler-0.9.5/lib/rake/extensiontask.rb:191:in `block (2 levels) in define_compile_tasks'
/var/lib/gems/1.9.1/gems/rake-compiler-0.9.5/lib/rake/extensiontask.rb:188:in `block in define_compile_tasks'
Tasks: TOP => compile => compile:x86_64-linux => compile:cgimap:x86_64-linux => copy:cgimap:x86_64-linux:1.9.3 => tmp/x86_64-linux/cgimap/1.9.3/cgimap.so => tmp/x86_64-linux/cgimap/1.9.3/Makefile
(See full trace by running task with --trace)
"g++ -o conftest -I/usr/include/ruby-1.9.1/x86_64-linux -I/usr/include/ruby-1.9.1/ruby/backward -I/usr/include/ruby-1.9.1 -I../../../../ext/cgimap -D_FORTIFY_SOURCE=2 -D_FORTIFY_SOURCE=2 -I/home/vagrant/.bundler/tmp/19134/gems/rice-1.7.0/ruby/lib/include -I/usr/include/libxml2 -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -Wall -fno-strict-aliasing conftest.c -L. -L/usr/lib -L. -Wl,-Bsymbolic-functions -Wl,-z,relro -L/build/buildd/ruby1.9.1-1.9.3.484/debian/lib -rdynamic -Wl,-export-dynamic -lrice -lruby-1.9.1 -lpthread -lrt -ldl -lcrypt -lm -lc"
/usr/bin/ld: cannot find -lrice
collect2: error: ld returned 1 exit status
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main(int argc, char **argv)
4: {
5: return 0;
6: }
/* end */
Following on from #4 , I now can't get this to compile. Target system is Ubuntu 16.04 with cgimap 0.6.0.
$bundle exec rake compile
cd tmp/x86_64-linux-gnu/cgimap/2.3.1
/usr/bin/ruby2.3 -I. ../../../../ext/cgimap/extconf.rb
checking for std::string() in -lstdc++... no
missing standard C++ libraries
*** ../../../../ext/cgimap/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=../../../../ext/cgimap
--curdir
--ruby=/usr/bin/$(RUBY_BASE_NAME)2.3
--with-libpath
--without-libpath
--with-cgimap-dir
--without-cgimap-dir
--with-cgimap-include
--without-cgimap-include=${cgimap-dir}/include
--with-cgimap-lib
--without-cgimap-lib=${cgimap-dir}/lib
--with-stdc++lib
--without-stdc++lib
rake aborted!
Command failed with status (1): [/usr/bin/ruby2.3 -I. ../../../../ext/cgima...]
/usr/local/src/cgimap-ruby/vendor/bundle/ruby/2.3.0/gems/rake-compiler-1.0.4/lib/rake/extensiontask.rb:205:in `block (2 levels) in define_compile_tasks'
/usr/local/src/cgimap-ruby/vendor/bundle/ruby/2.3.0/gems/rake-compiler-1.0.4/lib/rake/extensiontask.rb:202:in `block in define_compile_tasks'
/usr/local/src/cgimap-ruby/vendor/bundle/ruby/2.3.0/gems/rake-12.3.1/exe/rake:27:in `<top (required)>'
Tasks: TOP => compile => compile:x86_64-linux-gnu => compile:cgimap:x86_64-linux-gnu => copy:cgimap:x86_64-linux-gnu:2.3.1 => tmp/x86_64-linux-gnu/cgimap/2.3.1/cgimap.so => tmp/x86_64-linux-gnu/cgimap/2.3.1/Makefile
(See full trace by running task with --trace)
contents of mkmf.log:
have_library: checking for std::string() in -lstdc++... -------------------- no
"g++ -o conftest -I/usr/include/x86_64-linux-gnu/ruby-2.3.0 -I/usr/include/ruby-2.3.0/ruby/backward -I/usr/include/ruby-2.3.0 -I../../../../ext/cgimap -Wdate-time -D_FORTIFY_SOURCE=2 -I/usr/local/src/c
gimap-ruby/vendor/bundle/ruby/2.3.0/gems/rice-2.1.2/ruby/lib/include -I/usr/include/libxml2 -g -O2 -fstack-protector-strong -Wformat -Werror=format-security conftest.c -L. -L/usr/lib/x86_64-linux-gnu -L.
-Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -fstack-protector -rdynamic -Wl,-export-dynamic -L/usr/local/src/cgimap-ruby/vendor/bundle/ruby/2.3.0/gems/rice-2.1.2/ruby/lib/lib -lrice -lruby-2.3
-lpthread -lgmp -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 */
"g++ -o conftest -I/usr/include/x86_64-linux-gnu/ruby-2.3.0 -I/usr/include/ruby-2.3.0/ruby/backward -I/usr/include/ruby-2.3.0 -I../../../../ext/cgimap -Wdate-time -D_FORTIFY_SOURCE=2 -I/usr/local/src/cgimap-ruby/vendor/bundle/ruby/2.3.0/gems/rice-2.1.2/ruby/lib/include -I/usr/include/libxml2 -g -O2 -fstack-protector-strong -Wformat -Werror=format-security conftest.c -L. -L/usr/lib/x86_64-linux-gnu -L. -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -fstack-protector -rdynamic -Wl,-export-dynamic -L/usr/local/src/cgimap-ruby/vendor/bundle/ruby/2.3.0/gems/rice-2.1.2/ruby/lib/lib -lrice -lruby-2.3 -lstdc++ -lpthread -lgmp -ldl -lcrypt -lm -lc"
conftest.c: In function 'int t()':
conftest.c:15:68: error: expected primary-expression before ';' token
int t(void) { void ((*volatile p)()); p = (void ((*)()))std::string; return !p; }
^
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: #include <string>
4:
5: /*top*/
6: extern int t(void);
7: int main(int argc, char **argv)
8: {
9: if (argc > 1000000) {
10: printf("%p", &t);
11: }
12:
13: return 0;
14: }
15: int t(void) { void ((*volatile p)()); p = (void ((*)()))std::string; return !p; }
/* end */
"g++ -o conftest -I/usr/include/x86_64-linux-gnu/ruby-2.3.0 -I/usr/include/ruby-2.3.0/ruby/backward -I/usr/include/ruby-2.3.0 -I../../../../ext/cgimap -Wdate-time -D_FORTIFY_SOURCE=2 -I/usr/local/src/cgimap-ruby/vendor/bundle/ruby/2.3.0/gems/rice-2.1.2/ruby/lib/include -I/usr/include/libxml2 -g -O2 -fstack-protector-strong -Wformat -Werror=format-security conftest.c -L. -L/usr/lib/x86_64-linux-gnu -L. -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -fstack-protector -rdynamic -Wl,-export-dynamic -L/usr/local/src/cgimap-ruby/vendor/bundle/ruby/2.3.0/gems/rice-2.1.2/ruby/lib/lib -lrice -lruby-2.3 -lstdc++ -lpthread -lgmp -ldl -lcrypt -lm -lc"
conftest.c:15:25: error: 'void std::string()' should have been declared inside 'std'
extern void std::string();
^
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: #include <string>
4:
5: /*top*/
6: extern int t(void);
7: int main(int argc, char **argv)
8: {
9: if (argc > 1000000) {
10: printf("%p", &t);
11: }
12:
13: return 0;
14: }
15: extern void std::string();
16: int t(void) { std::string(); return 0; }
/* end */
--------------------
cgimap itself compiled fine on this system, so I'm confused as to what library might be missing, or whether this is a bogus error being shown for some other reason.
When compiling with bundle exec rake compile
I get
conftest.c:3:42: fatal error: cgimap/backend/apidb/apidb.hpp: No such file or directory
That hpp file isn't installed by openstreetmap-cgimap make install
. The full list of installed headers corresponds to https://github.com/zerebubuth/openstreetmap-cgimap/blob/library_split/Makefile.am#L9, namely:
vagrant@default-ubuntu-1410:/usr/local/include/cgimap$ ls -l
total 68
-rw-r--r-- 1 root root 1573 Feb 24 15:09 backend.hpp
-rw-r--r-- 1 root root 929 Feb 24 15:09 bbox.hpp
-rw-r--r-- 1 root root 2997 Feb 24 15:09 config.hpp
-rw-r--r-- 1 root root 3564 Feb 24 15:09 data_selection.hpp
-rw-r--r-- 1 root root 1314 Feb 24 15:09 handler.hpp
-rw-r--r-- 1 root root 4419 Feb 24 15:09 http.hpp
-rw-r--r-- 1 root root 334 Feb 24 15:09 logger.hpp
-rw-r--r-- 1 root root 459 Feb 24 15:09 mime_types.hpp
-rw-r--r-- 1 root root 339 Feb 24 15:09 output_buffer.hpp
-rw-r--r-- 1 root root 3251 Feb 24 15:09 output_formatter.hpp
-rw-r--r-- 1 root root 508 Feb 24 15:09 process_request.hpp
-rw-r--r-- 1 root root 474 Feb 24 15:09 rate_limiter.hpp
-rw-r--r-- 1 root root 1278 Feb 24 15:09 request_helpers.hpp
-rw-r--r-- 1 root root 3821 Feb 24 15:09 request.hpp
-rw-r--r-- 1 root root 975 Feb 24 15:09 routes.hpp
-rw-r--r-- 1 root root 109 Feb 24 15:09 types.hpp
Full logs
bundle exec rake compile
https://gist.github.com/gravitystorm/c4277338a2e6af2a0f43mkmf.log
https://gist.github.com/gravitystorm/1685a3b6acc8ddf4c658Copied over to separate issue as per #6 (comment)
I'm not quite sure on your overall approach to bundle this as Gem. Somehow we'd need to download cgimap sources, compile them, all during cgimap-ruby compilation/installation. Otherwise, installing openstreetmap-cgimap PPA first, before installing cgimap-ruby seems to somehow defeat the purpose of having something easily installable. Then, there's the issue of keeping the new Gem in sync with cgimap sources.
In case your goal was to have one single cgimap.so
with no additional dependencies to other cgimap shared libs, a static build seems like the way to go. In this case additional shared libraries need to be included, like I mentioned in #5.
Static build (./configure --enable-static --disable-shared CXXFLAGS="-fPIC" --enable-yajl
) requires additional references to yajl and libmemcached:
abort "missing yajl" unless have_library('yajl', 'yajl_gen_alloc(NULL)', 'yajl/yajl_gen.h')
abort "missing memcached" unless have_library('memcached', 'memcache::Memcache m()', 'libmemcached/memcached.hpp')
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.