I have been working in a solution with Oracle database access and C/C++.
I'm using OCCI but we are in trouble to link in Solaris 11.
Solution works "like a charm" in Linux (OpenSUSE and Mint), but doesn't in Solaris 11.
Here environment informations:
I downloaded instantclient_11_2 (sun sparc version) and unpacked it in a Solaris folder
I created symbolic links to libclntsh.so.11.1 called libclntsh.so, and for libocci.so.11.1 called libocci.so. Bellow a "ls -l" showing files:
-rwxrwxr-x 1 f780333 desenv 23792 Aug 22 2013 adrci
-rw-rw-r-- 1 f780333 desenv 414 Aug 22 2013 BASIC_README
-rwxrwxr-x 1 f780333 desenv 41464 Aug 22 2013 genezi
lrwxrwxrwx 1 f780333 desenv 17 Apr 5 14:21 libclntsh.so -> libclntsh.so.11.1
-rwxrwxr-x 1 f780333 desenv 50268448 Aug 22 2013 libclntsh.so.11.1
-r-xr-xr-x 1 f780333 desenv 8653320 Aug 22 2013 libnnz11.so
lrwxrwxrwx 1 f780333 desenv 15 Apr 5 14:22 libocci.so -> libocci.so.11.1
-rwxrwxr-x 1 f780333 desenv 1545008 Aug 22 2013 libocci.so.11.1
-rwxrwxr-x 1 f780333 desenv 118735824 Aug 22 2013 libociei.so
-r-xr-xr-x 1 f780333 desenv 121800 Aug 22 2013 libocijdbc11.so
-r--r--r-- 1 f780333 desenv 2091135 Aug 22 2013 ojdbc5.jar
-r--r--r-- 1 f780333 desenv 2739616 Aug 22 2013 ojdbc6.jar
drwxrwxr-x 4 f780333 desenv 7 Aug 22 2013 sdk
-rwxrwxr-x 1 f780333 desenv 177680 Aug 22 2013 uidrvci
-rw-rw-r-- 1 f780333 desenv 66779 Aug 22 2013 xstreams.jar
I created another folder that contens symbolic links to important needs libraries from Solaris.I am linking project with options -m64 -lCstd -lrt -lsocket. m64 to force 64bits, it was necessary. Cstd, rt and socket due the fact that these libraries are used indirectly.
I am using Netbeans and compile remotely in Solaris 11
Compilation works fine.
Compilation command patterns is showed bellow:
g++ -m64 -c -g -I/home/f780333/paineldaemon/lib/indra_clib/include -I/home/f780333/paineldaemon/lib/instantclient_11_2/sdk/include -std=c++98 -MMD -MP -MF "build/Debug/GNU-Solaris-Sparc/main.o.d" -o build/Debug/GNU-Solaris-Sparc/main.o main.cpp
/home/f780333/paineldaemon/lib/indra_clib/include is a folder with a static library used by program. This library is mine and is necessary for project.
/home/f780333/paineldaemon/lib/instantclient_11_2/sdk/include is a folder from instantclient sdk, that includes *.h from OCCI.
But when linkage process starts, all head pain starts too:
(first) Linkage command:
g++ -o <all files here> -L/home/f780333/paineldaemon/lib/sun -L/home/f780333/paineldaemon/lib -L/home/f780333/paineldaemon/lib/instantclient_11_2 -R'/home/f780333/paineldaemon/lib/sun' -R'/home/f780333/paineldaemon/lib' -R'/home/f780333/paineldaemon/lib/instantclient_11_2' -lclntsh -locci /home/f780333/paineldaemon/lib/libindra_clib.a -m64 -lCstd -lrt -lsocket
And finally the linker ERROR MESSAGE:
Undefined first referenced
symbol in file
oracle::occi::Date::~Date() build/Debug/GNU-Solaris-Sparc/MessageBuilderATM.o
oracle::occi::Date::Date() build/Debug/GNU-Solaris-Sparc/MessageBuilderATM.o
oracle::occi::Number::operator=(oracle::occi::Number const&) build/Debug/GNU-Solaris-Sparc/MessageBuilderATM.o
oracle::occi::Number::Number(double) build/Debug/GNU-Solaris-Sparc/MessageBuilder.o
oracle::occi::Number::Number(long) build/Debug/GNU-Solaris-Sparc/MessageBuilder.o
oracle::occi::Number::Number() build/Debug/GNU-Solaris-Sparc/MessageBuilderATM.o
oracle::occi::Number::~Number() build/Debug/GNU-Solaris-Sparc/MessageBuilderATM.o
oracle::occi::Environment::createEnvironment(oracle::occi::Environment::Mode, void*, void* (*)(void*, unsigned long), void* (*)(void*, void*, unsigned long), void (*)(void*, void*)) build/Debug/GNU-Solaris-Sparc/DatabaseOperation.o
oracle::occi::Date::operator=(oracle::occi::Date const&) build/Debug/GNU-Solaris-Sparc/MessageBuilderATM.o
oracle::occi::Environment::terminateEnvironment(oracle::occi::Environment*) build/Debug/GNU-Solaris-Sparc/DatabaseOperation.o
oracle::occi::Date::Date(oracle::occi::Environment const*, int, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int) build/Debug/GNU-Solaris-Sparc/MessageBuilder.o
ld: fatal: symbol referencing errors
collect2: error: ld returned 1 exit status
gmake[2]: *** [dist/Debug/GNU-Solaris-Sparc/paineldaemon] Error 1
gmake[2]: Leaving directory `/home/f780333/.netbeans/remote/172.16.160.172/sylvia-Linux-x86_64/home/eduardo/Indra/Cartoes/repo/paineldaemon'
gmake[1]: *** [.build-conf] Error 2
gmake[1]: Leaving directory `/home/f780333/.netbeans/remote/172.16.160.172/sylvia-Linux-x86_64/home/eduardo/Indra/Cartoes/repo/paineldaemon'
gmake: *** [.build-impl] Error 2
I am crazy with this problem, any help will be much apreciate.
In my experience, OCCI has always been built for Solaris by using the Solaris Studio compiler.
You can't link an executable that uses CC-built code using g++, unless you can somehow coerce g++ to link in both the C++ run time libraries libCrun.so and libCstd.so along with the proper C++ run-time startup code, the same as Solaris Studio's CC does. That's probably not impossible, but it would be easier to just invoke ld directly and link the binary yourself.
And you can't compile C++ source code with g++ to match the name-mangling scheme used by Solaris Studio CC. (unless the code was built with a later version of CC and it used command-line arguments to produce g++-compatible name-mangling, among many other compatibility requirements, which in my experience OCCI never has been...)
In short, you need to use Solaris Studio's CC compiler to use OCCI on Solaris.
Related
I tried to build this example and got a linkage error:
hekto#ubuntu:~$ g++ -g -Wall -std=c++11 -pthread -DBOOST_LOG_DYN_LINK -pthread sample.cpp -o sample -lboost_log -lboost_thread -lboost_system
/tmp/cc2EUizv.o: In function `boost::log::v2_mt_posix::basic_formatter<char> boost::log::v2_mt_posix::parse_formatter<char>(char const*)':
/usr/include/boost/log/utility/setup/formatter_parser.hpp:207: undefined reference to `boost::log::v2_mt_posix::basic_formatter<char> boost::log::v2_mt_posix::parse_formatter<char>(char const*, char const*)'
collect2: error: ld returned 1 exit status
How to overcome that?
I'm answering my own question, following the #Praetorian help and suggestion.
The Boost Log relies on two libraries (I thought it was only one):
hekto#ubuntu:~$ ls -l /usr/lib/x86_64-linux-gnu/libboost_log*
-rw-r--r-- 1 root root 3510082 Mar 6 2018 /usr/lib/x86_64-linux-gnu/libboost_log.a
-rw-r--r-- 1 root root 2441460 Mar 6 2018 /usr/lib/x86_64-linux-gnu/libboost_log_setup.a
lrwxrwxrwx 1 root root 28 Mar 6 2018 /usr/lib/x86_64-linux-gnu/libboost_log_setup.so -> libboost_log_setup.so.1.65.1
-rw-r--r-- 1 root root 671944 Mar 6 2018 /usr/lib/x86_64-linux-gnu/libboost_log_setup.so.1.65.1
lrwxrwxrwx 1 root root 22 Mar 6 2018 /usr/lib/x86_64-linux-gnu/libboost_log.so -> libboost_log.so.1.65.1
-rw-r--r-- 1 root root 905752 Mar 6 2018 /usr/lib/x86_64-linux-gnu/libboost_log.so.1.65.1
If you compile and link on Linux, you'll have to provide a list of Boost libraries on the command line. According to an answer to this question, given by the main developer (#AndreySemashev) of the Boost Log, these libraries on the command line should look like this:
-lboost_log_setup -lboost_log
Probably it makes sense to provide two libraries instead of one (for example, when you link statically), but I couldn't find any recommendations about when we should use a single library, and when - both of them.
While compiling few test applications, I get the following error:
g++: error: −lboost_system: No such file or directory
g++: error: −lboost_filesystem: No such file or directory
while running the following command:
g++ -I/usr/include/boost/ -L/usr/lib/x86_64-linux-gnu/ aescuda.cpp -o test.o −lboost_system −lboost_filesystem
The libraries are installed and present in location as shown below:
<prompt>$ ll /usr/lib/x86_64-linux-gnu/libboost_system.*
-rw-r--r-- 1 root root 49178 Jun 20 2014 /usr/lib/x86_64-linux-gnu/libboost_system.a
lrwxrwxrwx 1 root root 25 Jun 20 2014 /usr/lib/x86_64-linux-gnu/libboost_system.so -> libboost_system.so.1.54.0
-rw-r--r-- 1 root root 14536 Jun 20 2014 /usr/lib/x86_64-linux-gnu/libboost_system.so.1.54.0
<prompt>$ ll /usr/lib/x86_64-linux-gnu/libboost_filesystem.*
-rw-r--r-- 1 root root 217628 Jun 20 2014 /usr/lib/x86_64-linux-gnu/libboost_filesystem.a
lrwxrwxrwx 1 root root 29 Jun 20 2014 /usr/lib/x86_64-linux-gnu/libboost_filesystem.so -> libboost_filesystem.so.1.54.0
-rw-r--r-- 1 root root 88936 Jun 20 2014 /usr/lib/x86_64-linux-gnu/libboost_filesystem.so.1.54.0
Can anyone suggest where am I going wrong :(
You have a wrong character in front of the l:
−lboost_system
It should be an ASCII hyphen:
-lboost_system
This causes the compiler driver to treat the whole string as an input file name (which obviously does not exist, hence the No such file or directory error), and not as an option to be passed to the linker.
(Perhaps consider switching the terminal font.)
Trying to compile Qt 4.8.4 with opengl support for installing Visit. I run
./configure -opengl -verbose
The console gives me:
OpenGL auto-detection... ()
g++ -c -m64 -pipe -O2 -Wall -W -I../../../mkspecs/linux-g++-64 -I. -I/usr/include/GL -I/usr/X11R6/include -o opengl.o opengl.cpp
g++ -m64 -Wl,-O1 -o opengl opengl.o -L/usr/lib64/X11 -L/usr/lib64 -lGL -lXext -lX11 -lm
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../libGL.so when searching for -lGL
/usr/bin/ld: skipping incompatible /usr/lib/libGL.so when searching for -lGL
/usr/bin/ld: cannot find -lGL
collect2: ld returned 1 exit status
gmake: *** [opengl] Error 1
OpenGL disabled.
OpenGL ES 2.x auto-detection... ()
g++ -c -m64 -pipe -O2 -Wall -W -I../../../mkspecs/linux-g++-64 -I. -I/usr/X11R6/include -o opengles2.o opengles2.cpp
opengles2.cpp:45:25: error: GLES2/gl2.h: No such file or directory
opengles2.cpp: In function ‘int main(int, char**)’:
opengles2.cpp:50: error: ‘GLfloat’ was not declared in this scope
opengles2.cpp:50: error: ‘glUniform1f’ was not declared in this scope
opengles2.cpp:51: error: ‘GL_COLOR_BUFFER_BIT’ was not declared in this scope
opengles2.cpp:51: error: ‘glClear’ was not declared in this scope
gmake: *** [opengles2.o] Error 1
OpenGL ES 2.x disabled.
OpenGL ES 1.x auto-detection... ()
g++ -c -m64 -pipe -O2 -Wall -W -I../../../mkspecs/linux-g++-64 -I. -I/usr/X11R6/include -o opengles1.o opengles1.cpp
opengles1.cpp:45:23: error: GLES/gl.h: No such file or directory
opengles1.cpp: In function ‘int main(int, char**)’:
opengles1.cpp:50: error: ‘GLfloat’ was not declared in this scope
opengles1.cpp:50: error: expected ‘;’ before ‘a’
opengles1.cpp:51: error: ‘a’ was not declared in this scope
opengles1.cpp:51: error: ‘glColor4f’ was not declared in this scope
opengles1.cpp:52: error: ‘GL_COLOR_BUFFER_BIT’ was not declared in this scope
opengles1.cpp:52: error: ‘glClear’ was not declared in this scope
gmake: *** [opengles1.o] Error 1
OpenGL ES 1.x disabled.
All the OpenGL functionality tests failed!
You might need to modify the include and library search paths by editing
QMAKE_INCDIR_OPENGL, QMAKE_LIBDIR_OPENGL and QMAKE_LIBS_OPENGL in
/home/.../Downloads/qt-everywhere-opensource-src-4.8.3/mkspecs/linux-g++-64.
So, i look inside /mkspecs/linux-g++-64, there's only one file, qmake.conf
#
# qmake configuration for linux-g++
#
# Written for GNU/Linux platforms that have both lib and lib64 directories,
# like the AMD Opteron.
#
MAKEFILE_GENERATOR = UNIX
TARGET_PLATFORM = unix
TEMPLATE = app
CONFIG += qt warn_on release incremental link_prl gdb_dwarf_index
QT += core gui
QMAKE_INCREMENTAL_STYLE = sublib
QMAKE_CFLAGS = -m64
QMAKE_LFLAGS = -m64
include(../common/linux.conf)
include(../common/gcc-base-unix.conf)
include(../common/g++-unix.conf)
QMAKE_LIBDIR_X11 = /usr/X11R6/lib64
QMAKE_LIBDIR_OPENGL = /usr/X11R6/lib64
I don't have a /usr/X11R6 directory, but X_11 reports that everything is OK in the output.
I add the variables:
QMAKE_INCDIR_OPENGL = /usr/include/GL
QMAKE_LIBDIR_OPENGL = /usr/lib64
QMAKE_LIBS_OPENGL = -lGLU -lGL
Contents of /usr/include/GL:
drwxr-xr-x. 3 root root 4.0K Jun 29 14:26 .
drwxr-xr-x. 46 root root 12K Jun 29 16:07 ..
-rw-r--r--. 1 root root 7.7K Nov 12 2010 freeglut_ext.h
-rw-r--r--. 1 root root 681 Nov 12 2010 freeglut.h
-rw-r--r--. 1 root root 26K Nov 12 2010 freeglut_std.h
-rw-r--r--. 1 root root 710K Dec 13 2013 glext.h
-rw-r--r--. 1 root root 83K Dec 13 2013 gl.h
-rw-r--r--. 1 root root 126K Dec 13 2013 gl_mangle.h
-rw-r--r--. 1 root root 17K Dec 13 2013 glu.h
-rw-r--r--. 1 root root 3.3K Dec 13 2013 glu_mangle.h
-rw-r--r--. 1 root root 639 Nov 12 2010 glut.h
-rw-r--r--. 1 root root 44K Dec 13 2013 glxext.h
-rw-r--r--. 1 root root 17K Dec 13 2013 glx.h
-rw-r--r--. 1 root root 4.6K Feb 23 2013 glxint.h
-rw-r--r--. 1 root root 3.4K Dec 13 2013 glx_mangle.h
-rw-r--r--. 1 root root 2.1K Feb 23 2013 glxmd.h
-rw-r--r--. 1 root root 80K Feb 23 2013 glxproto.h
-rw-r--r--. 1 root root 12K Feb 23 2013 glxtokens.h
drwxr-xr-x. 2 root root 4.0K Jun 25 17:20 internal
contents of /usr/lib64
lrwxrwxrwx. 1 root root 15 Jun 25 17:20 libGLU.so -> libGLU.so.1.3.1
lrwxrwxrwx. 1 root root 15 Jun 25 15:59 libGLU.so.1 -> libGLU.so.1.3.1
-rwxr-xr-x. 1 root root 514K Dec 13 2013 libGLU.so.1.3.1
-rw-r--r--. 1 root root 656 Jun 25 16:20 libGL.la
lrwxrwxrwx. 1 root root 14 Jun 25 17:20 libGL.so -> libGL.so.1.2.0
lrwxrwxrwx. 1 root root 15 Jun 25 16:20 libGL.so.1 -> libGL.so.331.79
-rwxr-xr-x. 1 root root 1.2M Jun 25 16:20 libGL.so.331.79
lrwxrwxrwx. 1 root root 15 Jun 25 17:20 libGLU.so -> libGLU.so.1.3.1
lrwxrwxrwx. 1 root root 15 Jun 25 15:59 libGLU.so.1 -> libGLU.so.1.3.1
-rwxr-xr-x. 1 root root 514K Dec 13 2013 libGLU.so.1.3.1
./configure -opengl -verbose gives the same result
in addition
glxgears
works fine.
What am I doing wrong?
I guess you might install mesa driver that provides libGL.so.1.2.0 and changes the libGL.so symbolic link.
libGL.so -> libGL.so.1.2.0
libGL.so.1 -> libGL.so.331.79
libGL.so.331.79
In /usr/lib64,
rm libGL.so
ln -s libGL.so.1 libGL.so
will give you
libGL.so -> libGL.so.1 -> libGL.so.331.79
I am new to using make and I am trying to run the RInside example for Qt density demo given here: http://dirk.eddelbuettel.com/blog/2011/03/25/. I have saved the code into the following files:
main.cpp
Makefile
qtdensity.cpp
include/qtdensity.h
I am running Ubuntu 13.10, I have R, Rcpp and Inside installed. When I go to the terminal and run
> make -f Makefile
I get the error
make: *** No targets. Stop.
Please let me know how to proceed.
Thank you
I can't see how to ask a follow up to the first answer so I have to extend my question:
I have just created the files and was able to run qmake on main.cpp, qtdensity.cpp, qtdensity.h, and qtdensity.pro which worked but when I tried to run make, I get the following errors:
Lots of R - related errors ...
qtdensity.cpp:(.text+0x53a): undefined reference to `Rf_mkString'
qtdensity.cpp:(.text+0x54e): undefined reference to `Rf_install'
qtdensity.cpp:(.text+0x559): undefined reference to `Rf_findVarInFrame'
qtdensity.cpp:(.text+0x560): undefined reference to `R_UnboundValue'
...
qtdensity.cpp:(.text.startup+0x2a5): undefined reference to `R_NaReal'
qtdensity.cpp:(.text.startup+0x2b2): undefined reference to `R_NaN'
main.o: In function `_GLOBAL__sub_I_main':
main.cpp:(.text.startup+0x2a5): undefined reference to `R_NaReal'
main.cpp:(.text.startup+0x2b2): undefined reference to `R_NaN'
main.o: In function `main':
main.cpp:(.text.startup+0x352): undefined reference to `RInside::RInside(int, char const* const*, bool, bool, bool)'
main.cpp:(.text.startup+0x397): undefined reference to `RInside::~RInside()'
main.cpp:(.text.startup+0x3b3): undefined reference to `RInside::~RInside()'
moc_qtdensity.o: In function `_GLOBAL__sub_I__ZN9QtDensity18qt_static_metacallEP7QObjectN11QMetaObject4CallEiPPv':
moc_qtdensity.cpp:(.text.startup+0x2a5): undefined reference to `R_NaReal'
moc_qtdensity.cpp:(.text.startup+0x2b2): undefined reference to `R_NaN'
collect2: error: ld returned 1 exit status
make: *** [qdensity] Error 1
The Qt example is different because it uses Qt. You always need to start by creating the Makefile itself from the .pro file. Witness:
edd#max:~/git/rinside/inst/examples/qt$ ls -l ## no Makefile
total 28
drwxrwxr-x 2 edd edd 4096 Dec 27 18:38 cmake
-rw-rw-r-- 1 edd edd 518 Dec 27 18:38 main.cpp
-rw-rw-r-- 1 edd edd 5953 Dec 27 18:38 qtdensity.cpp
-rw-rw-r-- 1 edd edd 1532 Dec 27 18:38 qtdensity.h
-rw-rw-r-- 1 edd edd 2378 Feb 11 20:14 qtdensity.pro
-rw-rw-r-- 1 edd edd 887 Dec 27 18:38 README
edd#max:~/git/rinside/inst/examples/qt$ qmake ## creates Makefile
edd#max:~/git/rinside/inst/examples/qt$ make
g++ -c -m64 -pipe -I/usr/share/R/include [... lots and lots omitted ...]
g++ -m64 -Wl,-O1 -o qtdensity qtdensity.o main.o moc_qtdensity.o [....]
edd#max:~/git/rinside/inst/examples/qt$ ls -l qtdensity
-rwxrwxr-x 1 edd edd 76666 Feb 14 15:02 qtdensity
edd#max:~/git/rinside/inst/examples/qt$
This is of course also described in the README in this directory...
I am reading the procedure to create and use a dynamic shared library on solaris sparc server.
below are the file i have :
> ls -lrt
total 8
-rw-rw-r-- 1 nobody nobody 848 Nov 22 14:45 badmemlib.hh
-rw-rw-r-- 1 nobody nobody 1924 Nov 22 14:46 badmemlib.cc
-rw-rw-r-- 1 nobody nobody 330 Nov 22 14:49 my_prog.cc
>
in the above files badmemlib.hh is the header file using which i am creating a shared library with the below command following what is mentioned in this link.
> CC -G -o libbad.so -h libbad.so -Kpic badmemlib.cc
after i run the above command i have these below files:
> ls -lrt
total 26
-rw-rw-r-- 1 nobody nobody 848 Nov 22 14:45 badmemlib.hh
-rw-rw-r-- 1 nobody nobody 1924 Nov 22 14:46 badmemlib.cc
-rw-rw-r-- 1 nobody nobody 330 Nov 22 14:49 my_prog.cc
-rwxrwxr-x 1 nobody nobody 8284 Nov 22 15:11 libbad.so*
>
as you can see libbad.so is built without any errors.
Now my main is in the file my_prog.cc
i am compiling the file my_prog.cc as below which following this:
and there were no errors.the binary a.out is built.
> CC -L. -lbad my_prog.cc
> ls -lrt
total 184
-rw-rw-r-- 1 nobody nobody 848 Nov 22 14:45 badmemlib.hh
-rw-rw-r-- 1 nobody nobody 1924 Nov 22 14:46 badmemlib.cc
-rw-rw-r-- 1 nobody nobody 330 Nov 22 14:49 my_prog.cc
-rwxrwxr-x 1 nobody nobody 8284 Nov 22 15:11 libbad.so*
-rwxrwxr-x 1 nobody nobody 80224 Nov 22 15:14 a.out*
>
Now if i run a.out then the error i am facing is :
> ./a.out
ld.so.1: a.out: fatal: libbad.so: open failed: No such file or directory
Killed
It mentions that library is not found but as you can see above the library is in the same directory!
Could anybody pls help me!
content of my_prog.cc.it actually generates a sigsegv and and the badmemlib files has a signal handler.
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <string.h>
#include "badmemlib.hh"
#ifdef SOLARIS /* needed with at least Solaris 8 */
#include <siginfo.h>
#endif
int main(){
char *where=(char *)0x123;
printf( "About to write to %p\n", where);
strcpy(where,"vijay");
return(0);
}
You need to tell your application to find .so file from your current directory:
CC -L. -lbad my_prog.cc -R <your current directory>
http://docs.oracle.com/cd/E18659_01/html/821-1383/bkana.html#bkawi
You can also try setting the LD_LIBRARY_PATH variable.
You should be doing:
export LD_LIBRARY_PATH = $LD_LIBRARY_PATH:<full path where library is present>