Build Virtuoso (with Mono integration) on Ubuntu: build error on libgc - c++

UPDATE: Okay, I found it on this page: you have to run ./configure with the --enable-mono parameter. Then you'll also find out that some more dependencies are missing that aren't mentioned anywhere.
Sadly, this leaves me with another problem I cannot solve. As we still have the unfinished bounty here, let's ask this.
After doing ./autogen and ./configure --enable_mono (tried it on the code branches develop/6 and develop/7), I get the following error:
libtool: compile: gcc -DHAVE_CONFIG_H -I. -I../../libsrc/Dk -fno-strict-aliasing -O2 -DMONO_USE_EXC_TABLES -fexceptions -D_REENTRANT -D_GNU_SOURCE -Wall -DNDEBUG -DPOINTER_64 -I/usr/local/src/virtuoso-opensource/libsrc/Xml.new -DOPENSSL_NO_KRB5 -Dlinux -D_GNU_SOURCE -DFILE64 -D_LARGEFILE64_SOURCE -I../../binsrc/mono/mono-1.1.7/libgc/include -I../../libsrc -I../../libsrc/Dk -DNO_UDBC_SDK -DUSE_INCLUDED_LIBGC=1 -g -O2 -MT libthrp_gc_la-sched_pthread_gc.lo -MD -MP -MF .deps/libthrp_gc_la-sched_pthread_gc.Tpo -c sched_pthread_gc.c -fPIC -DPIC -o .libs/libthrp_gc_la-sched_pthread_gc.o
sched_pthread_gc.c:42:22: fatal error: gc_typed.h: No such file or directory
compilation terminated.
make[2]: *** [libthrp_gc_la-sched_pthread_gc.lo] Error 1
make[2]: Leaving directory `/usr/local/src/virtuoso-opensource/libsrc/Thread'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/usr/local/src/virtuoso-opensource/libsrc'
make: *** [all-recursive] Error 1
This link has the contents of the problematic file. If I remove the import for gc_typed.h, the next import is not found. I just did sudo apt-get install libgc-dev which worked. Make still gives me the same error. I believe somewhere around this file and this compilation the error is buried, but I can't fix it.
I'm a Linux noob, can somebody give me advice what might be the problem here or how to solve it?
Additional Information:
1. ldconfig -v -p clearly says that libgc.so exists, so why is this make script looking for the header?
...
libgdbm_compat.so.3 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libgdbm_compat.so.3
libgdbm.so.3 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libgdbm.so.3
libgd.so.2 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libgd.so.2
libgcrypt.so.11 (libc6,x86-64) => /lib/x86_64-linux-gnu/libgcrypt.so.11
libgccpp.so.1 (libc6,x86-64) => /usr/lib/libgccpp.so.1
libgccpp.so (libc6,x86-64) => /usr/lib/libgccpp.so
libgcc_s.so.1 (libc6,x86-64) => /lib/x86_64-linux-gnu/libgcc_s.so.1
libgc.so.1 (libc6,x86-64) => /usr/lib/libgc.so.1
libgc.so (libc6,x86-64) => /usr/lib/libgc.so
libgamin-1.so.0 (libc6,x86-64) => /usr/lib/libgamin-1.so.0
libgailutil.so.18 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libgailutil.so.18
libfuse.so.2 (libc6,x86-64) => /lib/libfuse.so.2
...
To install Virtuoso with Mono support, I used the following tutorials:
the README on the Virtuoso GitHub page
I had small problems doing the exports on this Mono-Virtuoso page, might one of those be the problem?
Virtuoso has been working before, I just don't get Virtuoso to build with --enable-mono. Mono works well, can build and execute dlls and exes without a problem.
.
.
.
ORIGINAL QUESTION:
I installed Virtuoso and Mono on a Ubuntu server and using this
tutorial compiled the sanity.cs class to a sanity.dll file. When I
tried importing the 'vector' I got a message:
SQLState: 42001
Message: SR185: Undefined procedure DB.DBA.import_clr.
Does that mean that I put the .dll in the wrong place? Or do I have
the wrong version of Virtuoso installed?
I used apt-get to install Virtuoso and Mono.
UPDATE: Okay, the apt-get version of Virtuoso was waaay too old. The
OpenLink Twitter account told me that the new versions should be built
from the Github account.
Now I built Virtuoso on Ubuntu following the readme on
https://github.com/openlink/virtuoso-opensource, but that doesn't
explain how to integrate Mono in any way.
I already made the sanity.cs Hello World file work, confirming that Mono is setup correctly.
The server runs, but the Mono section in the Virtuoso.ini is empty:
.
[Mono]
;MONO_TRACE = Off
;MONO_PATH = <path_here>
;MONO_ROOT = <path_here>
;MONO_CFG_DIR = <path_here>
;virtclr.dll =
I put the default paths in this file like this:
[Mono]
;MONO_TRACE = Off
;MONO_PATH = /usr/bin/mono
;MONO_ROOT = /usr/lib/mono
;MONO_CFG_DIR = /etc/mono
;virtclr.dll =
I cannot find a virtclr.dll on my system. How can I generate it? Can
someone help me with a link explaining how to integrate Mono in
Virtuoso or tell me how to proceed? Should I have built Virtuoso with
different settings?

It's a bit of a mess. It depends on mono-1.1.7, and it doesn't build it before trying to use items that it depends on; so the build is messy. I would strongly suspect that the developers are not building/testing this aspect of their project.
You need to download mono-1.1.7 manually - this is because the location of the mono tarball is not where they think it is.; e.g. from:
wget -O binsrc/mono/mono-1.1.7.tar.gz ftp://ftp1.freebsd.org/mirror/FreeBSD-Archive/ports/distfiles/mono-1.1.7.tar.gz
if you don't have wget, then you can use curl:
curl -o binsrc/mono/mono-1.1.7.tar.gz ftp://ftp1.freebsd.org/mirror/FreeBSD-Archive/ports/distfiles/mono-1.1.7.tar.gz
run configure:
./configure --enable-mono
Swap the order of the binsrc and libsrc subdirectories in the Makefile:
sed -i 's/libsrc binsrc/binsrc libsrc/' Makefile
run make (use a -j option if you want to make it faster e.g. -j2):
make
The build will fail. Do not panic. Swap binsrc and libsrc again:
sed -i 's/binsrc libsrc/libsrc binsrc/' Makefile
and re-run make:
make
The build should succeed at this point.
Bear in mind, it uses a private copy of mono-1.1.7, and most modern linux distros use 2.0, so there could be some conflicts with this.

Related

Cannot link to existing libopenblas.so.0 DLL

I need to use the libpca in C++, which depends on Armadillo, which in turn requires OpenBlas and lapack.
I got some problems in installing/configuring these dependencies.
I am using Red Hat 4.8.5-16 and wish to write code and call the package in /my/dir/program/. I do NOT have sudo privilege.
All those packages are downloaded and unzipped in /my/dir/
Here is the steps I have followed:
1. to install OpenBlas
/my/dir/OpenBLAS-0.2.20$ make
/my/dir/OpenBLAS-0.2.20$ make PREFIX=/my/dir/program/
<Step 1 is successful>
2. to install lapack
/my/dir/lapack-3.8.0$ mv make.inc.example make.inc
/my/dir/lapack-3.8.0$ make
<Step 2 is successful>
3. to install Armadillo
/my/dir/armadillo-8.500.0$ cmake . -DCMAKE_INSTALL_PREFIX:PATH=/my/dir/pgrogram/
/my/dir/armadillo-8.500.0$ make
/my/dir/armadillo-8.500.0$ make install
<Step 3 is successful>
4. to compile the example code
/my/dir/armadillo-8.500.0$ cp examples/example1.cpp /my/dir/program
/my/dir/program$ export LD_LIBRARY_PATH=/opt/intel/mkl/lib/intel64/:../OpenBLAS-0.2.20/:../armadillo-8.500.0/:./lib/:./lib64/:$LD_LIBRARY_PATH ;
/my/dir/program$ g++ example1.cpp -o example1 -O2 -I./include -L./lib -L./lib64 -L../lapack-3.8.0 -L../OpenBLAS-0.2.20 -larmadillo -lopenblas -llapack ;
<There is no warning or error in compiling>
5. to run the example code
/my/dir/program$ export LD_LIBRARY_PATH=/opt/intel/mkl/lib/intel64/:../OpenBLAS-0.2.20/:../armadillo-8.500.0/:./lib/:./lib64/:$LD_LIBRARY_PATH ;
/my/dir/program$ ./example1
It returns
./example1: error while loading shared libraries: libopenblas.so.0: cannot
open shared object file: No such file or directory
Actually the libopenblas.so.0 dll is located in ./lib/, and I've already added the DLL path.
Since I do not have root privilege, I cannot yum install openblas.x86_64 openblas-devel.x86_64 as suggested by this post.
What should I do?
For g++ / ld to find libmkl_rt.so is one thing.
Running ./example1 is a new situation : The "location information" must be repeated →
export LD_LIBRARY_PATH=/opt/intel.. .. ...:$LD_LIBRARY_PATH && ./example1
Please be aware that the export command is temporary : Valid for the current shell session only. When you exit the shell, the command is cancelled.

When I include a shared library, my executable is looking for two versions of it

When I make my program with -larmadillo, I get an executable which wants two versions of it:
$ ldd ./a.out | grep armadillo
$ libarmadillo.so.7 => /usr/lib/x86_64-linux-gnu/libarmadillo.so.7 (0x00007fd5e29a0000)
$ libarmadillo.so.4 => not found
Can anyone point me in the right direction? This isn't making any sense to me!
Background: I initially installed libarmadillo via sudo apt-get install libarmadillo-dev, then I realised I needed to build it with a specific parameter (64 bit words enabled), so I uninstalled it via sudo apt-get remove libarmadillo-dev then downloaded the latest version, configured and make/make installed it. Presumably I only have one version of libarmadillo on my system - I do not see any old libraries in the usual places.
Thanks
EDIT:
My Makefile is:
CC= g++
CFLAGS= -Lcontrib/armadillo-7.400.1 -L/usr/include -Lcontrib/mlpack-2.0.1/build/lib -fpermissive -std=c++11 -O0 -g -Wall
LDFLAGS= -lmlpack -larmadillo
The verbose output of ldd is interesting, I think?
$ ldd -v ./a.out | grep armadillo
$ libarmadillo.so.7 => /usr/lib/x86_64-linux-gnu/libarmadillo.so.7 (0x00007fd5e29a0000)
$ libarmadillo.so.4 => not found
$ /usr/lib/x86_64-linux-gnu/libarmadillo.so.7:
The latter section (which lists dependences for libarmadillo.so.7) is:
/usr/lib/x86_64-linux-gnu/libarmadillo.so.7:
ld-linux-x86-64.so.2 (GLIBC_2.3) => /lib64/ld-linux-x86-64.so.2
libc.so.6 (GLIBC_2.2.5) => /lib/x86_64-linux-gnu/libc.so.6
There is no mention of the 'missing' libarmadillo.so.4 in the verbose output, which I find quite strange.
I think I've figured it out, but the results aren't particularly comforting.
I reinstalled mlpack which has a dependency into libarmadillo, and then rebuilt, and the requirement for libarmadillo.so.4 is gone.
The process that I think happened is I:
Installed old version of libarmadillo
Installed libmlpack configured with old version
Realised I needed a newer version of libarmadillo, so uninstalled old libarmadillo and installed a new one.
Rebuilt mlpack using cmake / make but did not make install
Made my executable
Now have an executable which is is pointing to mlpack which requires the old libarmadillo, but it also points to the new libarmadillo
Once I make install the rebuilt mlpack, my problems go away. I am surprised that the verbose output of ldd didn't flag any reason as to why it was looking for libarmadillo.so.4 (namely that there was a dependency from libmlpack on the old library) - should ldd be able to do this?
Sometimes linux creates many symbolic link of one dynamic library. I don't know why but no matter as there is no inconvenient for that. So, you can just create a new symbolic link like this : ln -s path_to_my_so_lib/my_lib.so /usr/lib/x86_64-linux-gnu/libarmadillo.so.4

GCC & binutils build - C compiler cannot create executables

I'm trying to build gcc-5.3 and binutils-2.26. I've done it like this:
mkdir gcc; cd gcc
wget http://path/to/gcc-5.3.0.tar.bz2
wget http://path/to/binutils-2.26.tar.bz2
tar xf gcc-5.3.0.tar.bz2
tar xf binutils-2.26.tar.bz2
cd gcc-5.3.0
contrib/download_prerequisites
for file in ../binutils-2.26/*; do ln -s "${file}"; done
cd ..
mkdir build
mkdir dist
cd build
../gcc-5.3.0/configure --prefix=/home/teamcity/gcc/dist --disable-multilib --with-system-zlib --enable-languages=c,c++,fortran --program-suffix=-mine
make
This appears to build the first stage executables okay; prev-gas, prev-gcc, prev-ld are all present with plausible-looking executables in them. But the next stage fails:
Configuring stage 2 in ./intl
configure: loading cache ./config.cache
checking whether make sets $(MAKE)... yes
checking for a BSD-compatible install... /usr/bin/install -c
checking whether NLS is requested... yes
checking for msgfmt... /usr/bin/msgfmt
checking for gmsgfmt... /usr/bin/msgfmt
checking for xgettext... /usr/bin/xgettext
checking for msgmerge... /usr/bin/msgmerge
checking for x86_64-unknown-linux-gnu-gcc... /home/teamcity/gcc/build/./prev-gcc/xgcc -B/home/teamcity/gcc/build/./prev-gcc/ -B/home/teamcity/gcc/dist/x86_64-unknown-linux-gnu/bin/ -B/home/teamcity/gcc/dist/x86_64-unknown-linux-gnu/bin/ -B/home/teamcity/gcc/dist/x86_64-unknown-linux-gnu/lib/ -isystem /home/teamcity/gcc/dist/x86_64-unknown-linux-gnu/include -isystem /home/teamcity/gcc/dist/x86_64-unknown-linux-gnu/sys-include -L/home/teamcity/gcc/build/./ld
checking for C compiler default output file name...
configure: error: in `/home/teamcity/gcc/build/intl':
configure: error: C compiler cannot create executables
See `config.log' for more details.
The relevant bit of config.log appears to be this:
configure:2978: checking for C compiler default output file name
configure:3000: /home/teamcity/gcc/build/./prev-gcc/xgcc -B/home/teamcity/gcc/build/./prev-gcc/ -B/home/teamcity/gcc/dist/x86_64-unknown-linux-gnu/bin/ -B/home/teamcity/gcc/dist/x86_64-unkn
own-linux-gnu/bin/ -B/home/teamcity/gcc/dist/x86_64-unknown-linux-gnu/lib/ -isystem /home/teamcity/gcc/dist/x86_64-unknown-linux-gnu/include -isystem /home/teamcity/gcc/dist/x86_64-unknown-l
inux-gnu/sys-include -L/home/teamcity/gcc/build/./ld -g -O2 -gtoggle -static-libstdc++ -static-libgcc conftest.c >&5
/home/teamcity/gcc/build/./prev-gcc/as: 106: exec: /home/teamcity/gcc/build/./gas/as-new: not found
This looks like prev-gcc's as is expecting to find gas/as-new, when actually it's prev-gas/as-new.
Is there some workaround for this? Is it safe to just ln -s prev-gas gas? I'd sort of expect that to cause problems later on. Is it not possible to build these two versions of gcc and binutils together?
This is my edited answer after trying it on my own on an Ubuntu 14.04 Azure VM.
The following approach worked for me:
Build and install binutils 2.26; for the purposes of this discussion,
let's say it's installed in /opt/gcc-5.3.0.
Configure gcc-5.3.0 in a build directory using /root/objdir/../gcc-5.3.0/configure --prefix=/opt/gcc-5.3.0
--enable-languages=c,c++ --disable-multilib --with-ld=/opt/gcc-5.3.0/bin/ld --with-as=/opt/gcc-5.3.0/bin/as assuming gcc-5.3.0 and the build directory, objdir, are at the same
level.
Do make followed by make install in the objdir build directory.
To verify that the ld used by the newly-built gcc is the one from the new binutils:
/opt/gcc-5.3.0/bin/gcc -print-prog-name=ld
The output should be, in this example:
/opt/gcc-5.3.0/bin/ld
Another test: rename the system ld, in my case /usr/bin/ld; the newly-built gcc should still work.
Of course, this applies to both ld and as.
Setting AS and LD environment variables to point to the newly-built binaries from the binutils package did not work: the -print-prog-name=... still showed default tools, and removing/renaming the default tools caused gcc to fail.
Thus the best way of accomplishing this is to build binutils first and then use the --with-ld and --with-as options to configure. If you also want to ensure that the newly-built binutils are used to build GCC, you may want to put them in the PATH before the system-provided tools, or you can even rename the system-provided tools to keep them out of the picture.
Thank you for checking with another mailing list to verify that building GCC and binutils together doesn't work unless they are pulled from the source control, I guess that option is not applicable when using downloaded tarballs. Overall this was an interesting exercise.

RccpGSL, installing/using GSL from R on windows 7

I'm used to R but I'm a complete beginner in C++. I'm having a hard time installing GSL to use it with RcppGSL in R in order to refine a package comprising C++ code. I downloaded the latest GSL version, unpacked it to C:/GSL, set the environmental variable LIB_GSL to C:/GSL and the PATHtoC:/GSL/bin.
Like I said, I want to refine an existing package. I've forked and pulled the latest version of the package in question from github. My primary goal is simply to be able to use and refine the package. However, when I'm trying to make a source package out of the source files I get the following Error:
Installing to library 'C:/Users/Simon/Documents/R/win-library/3.1'
* installing *source* package 'Rflim' ...
** libs
g++ -m64 -I"C:/PROGRA~1/R/R-31~1.2/include" -DNDEBUG -I"C:/Users/Simon/Documents/R/win-library/3.1/Rcpp/include" -I"d:/RCompile/CRANpkg/extralibs64/local/include" -IC:/Users/Simon/Documents/R/win-library/3.1/Rcpp/include -I/usr/local/include -I C:/Users/Simon/Documents/R/win-library/3.1/RcppGSL/include -O2 -Wall -mtune=core2 -c flim.cpp -o flim.o
In file included from C:/Users/Simon/Documents/R/win-library/3.1/RcppGSL/include/RcppGSL.h:23:0,
from flim.cpp:1:
C:/Users/Simon/Documents/R/win-library/3.1/RcppGSL/include/RcppGSLForward.h:26:29: fatal error: gsl/gsl_vector.h: No such file or directory
compilation terminated.
make: *** [flim.o] Error 1
Warnung: Ausf�hrung von Kommando 'make -f "Makevars" -f "C:/PROGRA~1/R/R-31~1.2/etc/x64/Makeconf" -f "C:/PROGRA~1/R/R-31~1.2/share/make/winshlib.mk" SHLIB_LDFLAGS='$(SHLIB_CXXLDFLAGS)' SHLIB_LD='$(SHLIB_CXXLD)' SHLIB="Rflim.dll" WIN=64 TCLBIN=64 OBJECTS="flim.o"' ergab Status 2
ERROR: compilation failed for package 'Rflim'
* removing 'C:/Users/Simon/Documents/R/win-library/3.1/Rflim'
Exited with status 1.
Sorry, there are a couple of german words in there:
Warnung: Ausf�hrung von Kommando==Warning:executing command
What I realize is that R is trying to access the GSL library via the RcppGSL path. Is that correct? Shouldn't it go directly to C:/GSL instead? I also realized that R is trying to go to paths from both Rcpp as well as RcppGSL and I don't see why...
I would appreciate any clarification or suggestions on how to solve the problem.
Thank you!!!
Please install the prebuild GSL version for R on Windows from the support site provided by Prof Ripley and then set these values accordingly in src/Makevars.win
## This assumes that the LIB_GSL variable points to working GSL libraries
PKG_CPPFLAGS=-I$(LIB_GSL)/include -I../inst/include
PKG_LIBS=-L$(LIB_GSL)/lib -lgsl -lgslcblas
either directly, or set LIB_GSL accordingly.
This is how CRAN builds the package, and it evidently works.

How can one build openssl on ubuntu with a specific version of zlib?

Background
I'd like to build OpenSSL against a specific version of zlib so that all of my code is built by me. I do this for many of the libraries I use so that I don't get different behaviour on different versions of the operating system. I understand that this isn't strictly necessary, but I wanna.
What I've Done
I've built zlib in ~/zlib/zlib-1.2.7, and installed zlib to ~/zlib/lib and ~/zlib/include.
(Note that I've simplified all paths in this post by substituting my working directory for '~')
I've built openssl passing these arguments to ./config
--with-zlib-lib=~/zlib/lib
--with-zlib-include=~/zlib/include
When I build openssl, I can see that the appropriate -I argument is being passed to GCC
./config --prefix=~/openssl --openssldir=openssl/ssl threads zlib-dynamic shared --with-zlib-lib=~/zlib/lib --with-zlib-include=~/zlib/include && make && make install
. . .
...many lines of output...
. . .
gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include -I/home/ubuntu/zlib/include -fPIC -DOPENSSL_PIC -DZLIB_SHARED -DZLIB -DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -Wa,--noexecstack -m64 -DL_ENDIAN -DTERMIO -O3 -Wall -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DMD5_ASM -DAES_ASM -DVPAES_ASM -DBSAES_ASM -DWHIRLPOOL_ASM -DGHASH_ASM -c -o cm_pmeth.o cm_pmeth.c
OpenSSL builds successfully.
The Problem
I check what version of zlib is being linked with the command ldd libssl.so.
ubuntu#lemming012:~/ben/code/optimiser/libs/3rdParty/openssl/lib$ ldd libssl.so
linux-vdso.so.1 => (0x00007fff3e7ff000)
libcrypto.so.1.0.0 => /lib/x86_64-linux-gnu/libcrypto.so.1.0.0 (0x00007f
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f289bcab000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f289baa6000)
libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f289b88f000)
/lib64/ld-linux-x86-64.so.2 (0x00007f289c6c7000)
I expect to see ldd reporting my own libz file in the list.
Instead, ldd reports that libssl is linked to my system installed version of libz. The results are identical if I copy my own version libz.so.1 into the libssl 'lib' directory before running ldd in that same directory.
Question
What have I done wrong? How can I get OpenSSL to link to my version of zlib instead of the version installed on the system?
Environment
uBuntu 13.04 x64
compiling with GCC
building with Make
The answer turns out to be, you need to set an rpath with a syntax similar to the following. I do mine in a Makefile, which is the reason for the double '$'.
LDFLAGS += -Wl,-rpath,'$$ORIGIN/../lib'
Now, I don't necessarily need to do this on the library (openssl) itself. I can do this on the calling executable instead. If the library has no rpath, the rpath on the executable gets used next. In short, I don't need to stress that ldd -r <library> is returning the wrong path, provided that ldd -r <executable> returns the correct path.
I can test by library with the following command:
env LD_LIBRARY_PATH=$PWD ldd -r <library>
And once my executable is compiled, I can verify everything like this:
ldd -r <executable>
Long story short, everything is working just fine, don't get hung up on what ldd -r <library> is returning, just worry about ldd -r <executable>.
./config --prefix=/data/services/openssl-1.0.2g shared zlib -I/data/services/zlib-1.2.7/include -L/data/services/zlib-1.2.7/lib