Installing PL/Ruby for PostgreSQL 8.3 - ruby

This is to enable the development of postgres functions with embedded ruby code,
but I have been unable to build it.
As advised by
http://www.robbyonrails.com/articles/2005/08/22/installing-untrusted-pl-ruby-for-postgresql
I am trying to build the needed plruby.so from the latest version (plruby-0.5.3.tar.gz) provided at ftp://moulon.inra.fr/pub/ruby/
I've sorted out where my local postgres set up is and adjusted the invocation to:
ruby extconf.rb --with-pgsql-include=/usr/postgresql-8.3.4/include/server --enable-shared --disable-conversion --with-pgsql-version=83
I've tried quite number of variations on that, but it does not seem to be able to successfully make
the 'conftest.c' file
It says this:
checking for catalog/pg_proc.h... yes
*** 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.
And here is what I end up with in my mkmf.log
have_header: checking for catalog/pg_proc.h... -------------------- yes
"gcc -E -I. -I/usr/lib/ruby/1.8/x86_64-linux -I. -I/usr/postgresql-8.3.4/include/server -g -O2 -fPIC conftest.c -o conftest.i"
checked program was:
/* begin */
1: #include <catalog/pg_proc.h>
/* end */
When I run the gcc line manually, it says there is no 'conftest.c' (and there is not, but
it is supposed to be generated).
'uname -a' ... gives
Linux vdev1 2.6.18.8-xen #2 SMP Thu May 8 11:52:29 PDT 2008 x86_64 x86_64 x86_64 GNU/Linux
'ruby -v' ... gives
ruby 1.8.6 (2008-08-11 patchlevel 287) [x86_64-linux]
Any help and/or advice would be appreciated.
-- Mike Berrow

OK, I managed to hand build this (bypassing the fragile extconf.rb and makefile) by googling for a logfile of
a successful build, starting with the gcc lines I saw there, then fiddling with the gcc compile
flags and paths until it worked.
In plruby.h change the SAFE_LEVEL to 0
as shown below
#ifndef SAFE_LEVEL
//#define SAFE_LEVEL 12
#define SAFE_LEVEL 0
#endif
Compile each from shell then link
gcc -I. -I. -I/usr/lib/ruby/1.8/x86_64-linux -I. -DHAVE_CATALOG_PG_PROC_H -DHAVE_RB_HASH_DELETE -DHAVE_ST_H -DHAVE_UTILS_ARRAY_H -I/usr/postgresql-8.3.4/include/server -D_FILE_OFFSET_BITS=64 -fPIC -fno-strict-aliasing -g -g -O2 -fPIC -DHAVE_RB_HASH_DELETE -DHAVE_RB_INITIALIZE_COPY -DPG_UTILS_ARRAY -DPG_PL_TRYCATCH -DPG_PL_VERSION=83 -DPLRUBY_CALL_HANDLER=plruby_call_handler -DPLRUBY_VALIDATOR=plruby_validator -c plruby.c
gcc -I. -I. -I/usr/lib/ruby/1.8/x86_64-linux -I. -DHAVE_CATALOG_PG_PROC_H -DHAVE_RB_HASH_DELETE -DHAVE_ST_H -DHAVE_UTILS_ARRAY_H -I/usr/postgresql-8.3.4/include/server -D_FILE_OFFSET_BITS=64 -fPIC -fno-strict-aliasing -g -g -O2 -fPIC -DHAVE_RB_HASH_DELETE -DHAVE_RB_INITIALIZE_COPY -DPG_UTILS_ARRAY -DPG_PL_TRYCATCH -DPG_PL_VERSION=83 -DPLRUBY_CALL_HANDLER=plruby_call_handler -DPLRUBY_VALIDATOR=plruby_validator -c plplan.c
gcc -I. -I. -I/usr/lib/ruby/1.8/x86_64-linux -I. -DHAVE_CATALOG_PG_PROC_H -DHAVE_RB_HASH_DELETE -DHAVE_ST_H -DHAVE_UTILS_ARRAY_H -I/usr/postgresql-8.3.4/include/server -D_FILE_OFFSET_BITS=64 -fPIC -fno-strict-aliasing -g -g -O2 -fPIC -DHAVE_RB_HASH_DELETE -DHAVE_RB_INITIALIZE_COPY -DPG_UTILS_ARRAY -DPG_PL_TRYCATCH -DPG_PL_VERSION=83 -DPLRUBY_CALL_HANDLER=plruby_call_handler -DPLRUBY_VALIDATOR=plruby_validator -c plpl.c
gcc -I. -I. -I/usr/lib/ruby/1.8/x86_64-linux -I. -DHAVE_CATALOG_PG_PROC_H -DHAVE_RB_HASH_DELETE -DHAVE_ST_H -DHAVE_UTILS_ARRAY_H -I/usr/postgresql-8.3.4/include/server -D_FILE_OFFSET_BITS=64 -fPIC -fno-strict-aliasing -g -g -O2 -fPIC -DHAVE_RB_HASH_DELETE -DHAVE_RB_INITIALIZE_COPY -DPG_UTILS_ARRAY -DPG_PL_TRYCATCH -DPG_PL_VERSION=83 -DPLRUBY_CALL_HANDLER=plruby_call_handler -DPLRUBY_VALIDATOR=plruby_validator -c pltrans.c
gcc -shared -o plruby.so plruby.o plplan.o plpl.o pltrans.o -L. -L/usr/lib -L/usr/postgresql-8.3.4/lib -L. -Wl,-Bsymbolic -rdynamic -Wl,-export-dynamic -lruby -lpthread -ldl -lcrypt -lm -lc
Place the '.so' file built above in the dynamic library path ($libdir)
[ determined using pg_config --pkglibdir giving (in my case) /usr/postgresql-8.3.4/lib ]
Others taking this approach will most likely have to do their own tweaking.
Add these functions ...
CREATE OR REPLACE FUNCTION plruby_call_handler()
RETURNS language_handler AS
'$libdir/plruby', 'plruby_call_handler'
LANGUAGE 'c' VOLATILE
COST 1;
ALTER FUNCTION plruby_call_handler() OWNER TO postgres;
CREATE OR REPLACE FUNCTION plruby_validator(oid)
RETURNS void AS
'$libdir/plruby', 'plruby_validator'
LANGUAGE 'c' VOLATILE
COST 1;
ALTER FUNCTION plruby_validator(oid) OWNER TO postgres;
Add 'plruby' as a procedural language
CREATE PROCEDURAL LANGUAGE 'plruby' HANDLER plruby_call_handler;
Test it:
CREATE FUNCTION ruby_max(int4, int4) RETURNS text AS '
if args[0].to_i > args[1].to_i
return "The one on the left is bigger"
else
return "The one on the right is bigger"
end
' LANGUAGE 'plruby';
select ruby_max(8, 9);
There are other build options for this that enable type 'conversions'.
The above build is the simplest one and all function parameters actually
come into ruby as strings (even though they are declared as int4).
Thus the need for the 'to_i' call here.

Related

does gfortran append underscores... error linking Fortran and C

I am trying to compile FormCalc 9.9 on a MacOS 10.10.5.
Compilation consists in running a bash script on terminal. I redirect both stdout and sterr to a log file, but this is all the output I get:
$ ./compile
Compiling for system type MacOSX-x86-64
cp -p ./bin/MacOSX-x86-64/* MacOSX-x86-64/
gcc -O3 -fomit-frame-pointer -ffast-math -Wall -Wextra -m64 -o MacOSX-x86-64/ToForm ./FormCalc/ToForm.c
./FormCalc/ToForm.c:72:9: warning: declaration does not declare anything [-Wmissing-declarations]
__attribute__ ((fallthrough));
^
>
1 warning generated.
strip MacOSX-x86-64/ToForm
gcc -O3 -fomit-frame-pointer -ffast-math -Wall -Wextra -m64 -o MacOSX-x86-64/ToFortran ./FormCalc/ToFortran.c
strip MacOSX-x86-64/ToFortran
gcc -O3 -fomit-frame-pointer -ffast-math -Wall -Wextra -m64 -o MacOSX-x86-64/ToC ./FormCalc/ToC.c
strip MacOSX-x86-64/ToC
gcc -O3 -fomit-frame-pointer -ffast-math -Wall -Wextra -m64 -o MacOSX-x86-64/reorder ./tools/reorder.c
strip MacOSX-x86-64/reorder
looking for gcc... /usr/bin/clang
looking for g++... /usr/bin/clang++
looking for fortran... /usr/local/bin/gfortran
extracting the Fortran libraries... ok
does gfortran append underscores... error linking Fortran and C
How can I get more information about the linking error?

Problems compiling Qt with OCI sql plugin on Linux

I am having serious trouble compiling Qt with the OCI plugin.
The Qt version is 5.6.1, and the Oracle instant client version is 12.1.0.2.0. I have installed both the basic and SDK versions, as the Qt online manual asks.
I then try to run the following command:
./configure -I /usr/include/oracle/12.1/client64/ -L /usr/lib/oracle/12.1/client64/lib -prefix /online/daq/antonin/qt_build -plugin-sql-oci -qt-xcb -v
Which produces this output:
+ cd qtbase
+ /online/daq/antonin/qt_source/5.6/Src/qtbase/configure -top-level -I /usr/include/oracle/12.1/client64/ -L /usr/lib/oracle/12.1/client64/lib -prefix /online/daq/antonin/qt_build -plugin-sql-oci -qt-xcb -v
Which edition of Qt do you want to use ?
Type 'c' if you want to use the Commercial Edition.
Type 'o' if you want to use the Open Source Edition.
o
This is the Qt Open Source Edition.
You are licensed to use this software under the terms of
the Lesser GNU General Public License (LGPL) versions 2.1.
You are also licensed to use this software under the terms of
the GNU Lesser General Public License (LGPL) versions 3.
Type '3' to view the GNU Lesser General Public License version 3.
Type 'L' to view the Lesser GNU General Public License version 2.1.
Type 'yes' to accept this license offer.
Type 'no' to decline this license offer.
Do you accept the terms of either license? yes
Running configuration tests (phase 1)...
Precompiled-headers support enabled.
g++ -c -fvisibility=hidden fvisibility.c
Symbol visibility control enabled.
cc1plus: error: unrecognized command line option "-fuse-ld=gold"
g++ -o libtest.so -shared -Wl,-Bsymbolic-functions -fPIC bsymbolic_functions.c
Symbolic function binding enabled.
DEFAULT_INCDIRS="/usr/include/c++/4.4.7
/usr/include/c++/4.4.7/x86_64-redhat-linux
/usr/include/c++/4.4.7/backward
/usr/local/include
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/include
/usr/include
"
DEFAULT_LIBDIRS="/lib64
/usr/lib64
/online/daq/lib
/usr/lib
/lib
/usr/lib/gcc/x86_64-redhat-linux/4.4.7
"
Done running configuration tests.
Creating qmake...
gmake: Nothing to be done for `first'.
Running configuration tests (phase 2)...
Found pkg-config from $PATH: /usr/bin/pkg-config
Determining architecture... ()
g++ -c -pipe -g -std=gnu++0x -Wall -W -fPIC -I. -isystem /usr/include/oracle/12.1/client64 -I../../mkspecs/linux-g++ -o arch.o arch.cpp
g++ -o arch arch.o -L/usr/lib/oracle/12.1/client64/lib
Found architecture in binary
CFG_ARCH="x86_64"
CFG_CPUFEATURES=" mmx sse sse2"
System architecture: 'x86_64'
Host architecture: 'x86_64'
C++11 auto-detection... ()
g++ -c -pipe -O2 -std=gnu++0x -Wall -W -fPIC -I. -isystem /usr/include/oracle/12.1/client64 -I../../../mkspecs/linux-g++ -o c++11.o c++11.cpp
g++ -Wl,-O1 -o c++11 c++11.o -L/usr/lib/oracle/12.1/client64/lib
C++11 enabled.
C++14 auto-detection... ()
g++ -c -pipe -O2 -std=gnu++1y -Wall -W -fPIC -I. -isystem /usr/include/oracle/12.1/client64 -I../../../mkspecs/linux-g++ -o c++14.o c++14.cpp
cc1plus: error: unrecognized command line option "-std=gnu++1y"
gmake: *** [c++14.o] Error 1
C++14 disabled.
default C++ standard edition auto-detection... ()
g++ -pipe -O2 -Wall -W -fPIC -I. -isystem /usr/include/oracle/12.1/client64 -I../../../mkspecs/linux-g++ -o c++default.ii -E c++default.cpp
default C++ standard edition enabled.
64-bit std::atomic auto-detection... ()
g++ -c -pipe -O2 -std=gnu++0x -Wall -W -fPIC -I. -isystem /usr/include/oracle/12.1/client64 -I../../../mkspecs/linux-g++ -o atomic64.o atomic64.cpp
atomic64.cpp:34:18: error: atomic: No such file or directory
atomic64.cpp:37: error: expected unqualified-id before '<' token
atomic64.cpp:37: error: expected ')' before '<' token
atomic64.cpp:37: error: expected initializer before '<' token
gmake: *** [atomic64.o] Error 1
64-bit std::atomic disabled.
64-bit std::atomic in -latomic auto-detection... ()
g++ -c -pipe -O2 -std=gnu++0x -Wall -W -fPIC -I. -isystem /usr/include/oracle/12.1/client64 -I../../../mkspecs/linux-g++ -o atomic64.o atomic64.cpp
atomic64.cpp:34:18: error: atomic: No such file or directory
atomic64.cpp:37: error: expected unqualified-id before '<' token
atomic64.cpp:37: error: expected ')' before '<' token
atomic64.cpp:37: error: expected initializer before '<' token
gmake: *** [atomic64.o] Error 1
64-bit std::atomic in -latomic disabled.
sse2 auto-detection... ()
g++ -c -pipe -msse2 -g -std=gnu++0x -Wall -W -fPIC -I. -isystem /usr/include/oracle/12.1/client64 -I../../../mkspecs/linux-g++ -o sse2.o sse2.cpp
g++ -o sse2 sse2.o -L/usr/lib/oracle/12.1/client64/lib
sse2 enabled.
sse3 auto-detection... ()
g++ -c -pipe -msse3 -g -std=gnu++0x -Wall -W -fPIC -I. -isystem /usr/include/oracle/12.1/client64 -I../../../mkspecs/linux-g++ -o sse3.o sse3.cpp
g++ -o sse3 sse3.o -L/usr/lib/oracle/12.1/client64/lib
sse3 enabled.
ssse3 auto-detection... ()
g++ -c -pipe -mssse3 -g -std=gnu++0x -Wall -W -fPIC -I. -isystem /usr/include/oracle/12.1/client64 -I../../../mkspecs/linux-g++ -o ssse3.o ssse3.cpp
g++ -o ssse3 ssse3.o -L/usr/lib/oracle/12.1/client64/lib
ssse3 enabled.
sse4_1 auto-detection... ()
g++ -c -pipe -msse4.1 -g -std=gnu++0x -Wall -W -fPIC -I. -isystem /usr/include/oracle/12.1/client64 -I../../../mkspecs/linux-g++ -o sse4_1.o sse4_1.cpp
g++ -o sse4_1 sse4_1.o -L/usr/lib/oracle/12.1/client64/lib
sse4_1 enabled.
sse4_2 auto-detection... ()
g++ -c -pipe -msse4.2 -g -std=gnu++0x -Wall -W -fPIC -I. -isystem /usr/include/oracle/12.1/client64 -I../../../mkspecs/linux-g++ -o sse4_2.o sse4_2.cpp
g++ -o sse4_2 sse4_2.o -L/usr/lib/oracle/12.1/client64/lib
sse4_2 enabled.
avx auto-detection... ()
g++ -c -pipe -mavx -g -std=gnu++0x -Wall -W -fPIC -I. -isystem /usr/include/oracle/12.1/client64 -I../../../mkspecs/linux-g++ -o avx.o avx.cpp
g++ -o avx avx.o -L/usr/lib/oracle/12.1/client64/lib
avx enabled.
avx2 auto-detection... ()
g++ -c -pipe -mavx2 -g -std=gnu++0x -Wall -W -fPIC -I. -isystem /usr/include/oracle/12.1/client64 -I../../../mkspecs/linux-g++ -o avx2.o avx2.cpp
cc1plus: error: unrecognized command line option "-mavx2"
gmake: *** [avx2.o] Error 1
avx2 disabled.
ipc_sysv auto-detection... ()
g++ -c -pipe -O2 -std=gnu++0x -Wall -W -fPIC -I. -isystem /usr/include/oracle/12.1/client64 -I../../../mkspecs/linux-g++ -o ipc.o ipc.cpp
g++ -Wl,-O1 -o ipc_sysv ipc.o -L/usr/lib/oracle/12.1/client64/lib
ipc_sysv enabled.
zlib auto-detection... ()
g++ -c -pipe -O2 -std=gnu++0x -Wall -W -fPIC -I. -isystem /usr/include/oracle/12.1/client64 -I../../../mkspecs/linux-g++ -o zlib.o zlib.cpp
g++ -Wl,-O1 -o zlib zlib.o -L/usr/lib/oracle/12.1/client64/lib -lz
zlib enabled.
mtdev auto-detection... ()
Project ERROR: mtdev development package not found
mtdev disabled.
libjpeg auto-detection... ()
g++ -c -pipe -O2 -std=gnu++0x -Wall -W -fPIC -I. -isystem /usr/include/oracle/12.1/client64 -I../../../mkspecs/linux-g++ -o libjpeg.o libjpeg.cpp
libjpeg.cpp: In function 'int main(int, char**)':
libjpeg.cpp:43: warning: 'cinfo' is used uninitialized in this function
g++ -Wl,-O1 -o libjpeg libjpeg.o -L/usr/lib/oracle/12.1/client64/lib -ljpeg
libjpeg enabled.
libpng auto-detection... ()
g++ -c -pipe -O2 -std=gnu++0x -Wall -W -fPIC -I. -isystem /usr/include/oracle/12.1/client64 -I../../../mkspecs/linux-g++ -o libpng.o libpng.cpp
g++ -Wl,-O1 -o libpng libpng.o -L/usr/lib/oracle/12.1/client64/lib -lpng
libpng enabled.
libdl auto-detection... ()
g++ -c -pipe -O2 -std=gnu++0x -Wall -W -fPIC -I. -isystem /usr/include/oracle/12.1/client64 -I../../../mkspecs/linux-g++ -o libdl.o libdl.cpp
g++ -Wl,-O1 -o libdl libdl.o -L/usr/lib/oracle/12.1/client64/lib -ldl
libdl enabled.
DB2 auto-detection... ()
g++ -c -pipe -O2 -std=gnu++0x -Wall -W -fPIC -I. -isystem /usr/include/oracle/12.1/client64 -I../../../mkspecs/linux-g++ -o db2.o db2.cpp
db2.cpp:34:20: error: sqlcli.h: No such file or directory
db2.cpp:35:21: error: sqlcli1.h: No such file or directory
gmake: *** [db2.o] Error 1
DB2 disabled.
InterBase auto-detection... ()
g++ -c -pipe -O2 -std=gnu++0x -Wall -W -fPIC -I. -isystem /usr/include/oracle/12.1/client64 -I../../../mkspecs/linux-g++ -o ibase.o ibase.cpp
ibase.cpp:34:19: error: ibase.h: No such file or directory
gmake: *** [ibase.o] Error 1
InterBase disabled.
MySQL (thread-safe) auto-detection... ()
g++ -c -pipe -O2 -std=gnu++0x -Wall -W -fPIC -I. -isystem /usr/include/oracle/12.1/client64 -isystem /usr/include/mysql -I../../../mkspecs/linux-g++ -o mysql.o ../mysql/mysql.cpp
g++ -Wl,-O1 -o mysql_r mysql.o -L/usr/lib/oracle/12.1/client64/lib -L/usr/lib64/mysql -lz -lcrypt -lnsl -lm -lpthread -lssl -lcrypto -lmysqlclient_r
MySQL (thread-safe) enabled.
OCI auto-detection... ()
g++ -c -pipe -O2 -std=gnu++0x -Wall -W -fPIC -I. -isystem /usr/include/oracle/12.1/client64 -I../../../mkspecs/linux-g++ -o oci.o oci.cpp
g++ -Wl,-O1 -o oci oci.o -L/usr/lib/oracle/12.1/client64/lib -lclntsh
/usr/lib/oracle/12.1/client64/lib/libclntsh.so: undefined reference to `lxXmlCvEsc0'
/usr/lib/oracle/12.1/client64/lib/libclntsh.so: undefined reference to `lxXmlGEntEscImpl'
/usr/lib/oracle/12.1/client64/lib/libclntsh.so: undefined reference to `slnxmul'
/usr/lib/oracle/12.1/client64/lib/libclntsh.so: undefined reference to `zt_init'
/usr/lib/oracle/12.1/client64/lib/libclntsh.so: undefined reference to `slnxadd'
/usr/lib/oracle/12.1/client64/lib/libclntsh.so: undefined reference to `slnxsub'
collect2: ld returned 1 exit status
gmake: *** [oci] Error 1
OCI disabled.
Oracle (OCI) support cannot be enabled due to functionality tests!
Turn on verbose messaging (-v) to /online/daq/antonin/qt_source/5.6/Src/qtbase/configure to see the final report.
If you believe this message is in error you may use the continue
switch (-continue) to /online/daq/antonin/qt_source/5.6/Src/qtbase/configure to continue.
As you can see, there are several undefined references for one of the the OCI .so files. I have tried checking online, but I have found barely any references to these symbols.
Any idea what could be causing this? A missing .so file? Wrong version of the library?

Why does Cygwin's GCC display the first line of every file?

I'm not a regular Cygwin user. I installed Cygwin and Cygwin64 for testing proposed patches.
Here's the output of a typical make:
User#windows-7-x64 ~/cryptopp
$ make
g++ -DNDEBUG -g -O2 -fPIC -march=native -pipe -c shacal2.cpp
shacal2.cpp:1:0: warning: -fPIC ignored for target (all code is position independent)
// shacal2.cpp - by Kevin Springle, 2003
^
g++ -DNDEBUG -g -O2 -fPIC -march=native -pipe -c seed.cpp
seed.cpp:1:0: warning: -fPIC ignored for target (all code is position independent)
// seed.cpp - written and placed in the public domain by Wei Dai
^
g++ -DNDEBUG -g -O2 -fPIC -march=native -pipe -c shark.cpp
shark.cpp:1:0: warning: -fPIC ignored for target (all code is position independent)
// shark.cpp - written and placed in the public domain by Wei Dai
^
...
Cygwin's make displays the first line of every file it compiles.
Why does Cygwin's make display the first line of every file? How can I stop the behavior?
The output is due to the warning about the -fPIC command line option, just as it says. Remove the -fPIC option from your makefile's CXXFLAGS (or wherever) and it will go away.

Negate previous -D[efine] flag for GCC

Under GNUStep on Arch Linux, I'm running into an interesting error on a fresh install.
Using my build system I run
gcc `gnustep-config --debug-flags` [other command line args]
in order to build up the command line per the operating system's necessary flags.
This works fine under Ubuntu, but on Arch Linux I'm getting a rather random error:
/usr/include/features.h:328:4: error: #warning _FORTIFY_SOURCE requires compiling with optimization (-O) [-Werror=cpp]
Well, gnustep-config --debug-flags spits out the following:
-MMD -MP -D_FORTIFY_SOURCE=2 -DGNUSTEP -DGNUSTEP_BASE_LIBRARY=1 -DGNU_GUI_LIBRARY=1 -DGNU_RUNTIME=1 -DGNUSTEP_BASE_LIBRARY=1 -fno-strict-aliasing -pthread -fPIC -g -DDEBUG -fno-omit-frame-pointer -Wall -DGSWARN -DGSDIAGNOSE -Wno-import -march=x86-64 -mtune=generic -pipe -fstack-protector-strong --param=ssp-buffer-size=4 -fgnu-runtime -fconstant-string-class=NSConstantString -fexec-charset=UTF-8 -I. -I/home/qix/GNUstep/Library/Headers -I/usr/include -D_FORTIFY_SOURCE=2 -I/usr/include -I/usr/include -I/usr/include -I/usr/lib/libffi-3.1/include/ -I/usr/lib/libffi-3.1/include -I/usr/include/libxml2 -I/usr/include/p11-kit-1
As well, I wish not to have optimizations on my debug builds (and later on I even override GNUStep's -g parameter to -g2).
Is there a way to explicitly undefine -D_FORTIFY_SOURCE later on in the command line, after the call to gnustep-config?
For example, something like
gcc `gnustep-config --debug-flags` -U_FORTIFY_SOURCE ...
where the -U undefines the previously defined macro?
Something to mention; I have -Werror enabled on purpose, and I'd like to keep it.
For now, using sed to work around this works. It appears this is a known issue with _FORTIFY_SOURCE causing issues, and there isn't a straightforward fix.
`gnustep-config --debug-flags | sed 's/-D_FORTIFY_SOURCE=2//g'`

Error installing mysql2 gem on Ubuntu Server 11.10: /usr/bin/ld: cannot find -lmysqlclient_r

I got the same error on Ubuntu Server 11.10 x64 mentioned in some other posts:
Post #1
Post #2
The mysql2 gem cannot be compiled due "cannot find -lmysqlclient_r "
I'm using:
Ruby v1.8.7
MySQL v5.5.25-1
Rails 3.2.3
Gem 1.8.24
I installed the package libmysqlclient-dev and it still doesn't work.
The files
- libmysqlclient_r.a
- libmysqlclient_r.so
- libmysqlclient_r.so.18
- libmysqlclient_r.so.18.0.0
are located at /usr/lib/x86_64-linux-gnu/
So I created symlinks in /usr/lib/
Ii still doesn't work :(
Any idea??
$ sudo gem install mysql2
Building native extensions. This could take a while...
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
/usr/bin/ruby1.8 extconf.rb
checking for rb_thread_blocking_region()... no
checking for rb_wait_for_single_fd()... no
checking for mysql.h... yes
checking for errmsg.h... yes
checking for mysqld_error.h... yes
creating Makefile
make
gcc -I. -I. -I/usr/lib/ruby/1.8/x86_64-linux -I. -DHAVE_MYSQL_H -DHAVE_ERRMSG_H -DHAVE_MYSQLD_ERROR_H -I/usr/include/mysql -DBIG_JOINS=1 -fno-strict-aliasing -g -fPIC -fno-strict-aliasing -g -g -O2 -fPIC -Wall -funroll-loops -c mysql2_ext.c
./client.h:16:1: warning: ârb_thread_blocking_regionâ defined but not used [-Wunused-function]
gcc -I. -I. -I/usr/lib/ruby/1.8/x86_64-linux -I. -DHAVE_MYSQL_H -DHAVE_ERRMSG_H -DHAVE_MYSQLD_ERROR_H -I/usr/include/mysql -DBIG_JOINS=1 -fno-strict-aliasing -g -fPIC -fno-strict-aliasing -g -g -O2 -fPIC -Wall -funroll-loops -c result.c
result.c: In function ârb_mysql_result_fetch_rowâ:
result.c:258:31: warning: variable âtokensâ set but not used [-Wunused-but-set-variable]
result.c:272:58: warning: variable âtokensâ set but not used [-Wunused-but-set-variable]
result.c:315:33: warning: variable âtokensâ set but not used [-Wunused-but-set-variable]
gcc -I. -I. -I/usr/lib/ruby/1.8/x86_64-linux -I. -DHAVE_MYSQL_H -DHAVE_ERRMSG_H -DHAVE_MYSQLD_ERROR_H -I/usr/include/mysql -DBIG_JOINS=1 -fno-strict-aliasing -g -fPIC -fno-strict-aliasing -g -g -O2 -fPIC -Wall -funroll-loops -c client.c
client.c: In function ârb_mysql_client_infoâ:
client.c:539:3: warning: variable âwrapperâ set but not used [-Wunused-but-set-variable]
gcc -shared -o mysql2.so mysql2_ext.o result.o client.o -L. -L/usr/lib -L. -Wl,-Bsymbolic-functions -rdynamic -Wl,-export-dynamic -Wl,-rpath,/usr/lib/x86_64-linux-gnu -lruby1.8 -L/usr/lib/x86_64-linux-gnu -lmysqlclient_r -lpthread -lz -lm -lrt -ldl -lpthread -lrt -ldl -lcrypt -lm -lc
/usr/bin/ld: cannot find -lmysqlclient_r
collect2: ld returned 1 exit status
make: *** [mysql2.so] Error 1

Resources