cortex-m3 fpu instruction hard fault - stm32

My firmware for stm32f103 results in hard fault.
Here is the line of code that crash execution:
float shuntResistance = p[SHUNT_RESISTANCE];
where p - is global array of floats:
float p[CONFIG_NUM_PARAMS];
There is dissaembly while debugging:
0800177c: ldr r3, [pc, #332] ; (0x80018cc <adcSetConstants+336>)
0800177e: vldr s10, [r3, #48] ; 0x30 ; on that instruction program results in hard fault
Here is compiler flags:
-c -fmessage-length=0 -mthumb -mcpu=cortex-m3 -mfloat-abi=softfp -ffunction-sections -fdata-sections -fsingle-precision-constant
Linker flags:
-Wl,--static,--gc-sections,-Map=${ProjName}.map,-T../stm32_flash.ld -fmessage-length=0 -mthumb -mcpu=cortex-m3 -ffunction-sections -fdata-sections -fsingle-precision-constant -Dprintf=iprintf -u _printf_float -lc -lnosys -lc
Used compiler is launchpad's arm-none-eabi-gcc.
Used IDE is eclipse.
What is the cause?

Here is compiler flags:
-c -fmessage-length=0 -mthumb -mcpu=cortex-m3 -mfloat-abi=softfp
Your MCU is a Cortex M3, which has no FPU. You need to use -mfloat-abi=soft. The "softfp" option uses FPU instructions which will not work for you.

Related

How to get a clean CDT Build Console Output?

I'm working with STM32CubeIDE using gcc compiler. In the build output I have to search for warnings and errors in a hundred lines of compiler-output infos. I'm explicitly interested in all warnings and errors! But I do not need something like this as there isn't any warning or error:
(Useful information)
arm-none-eabi-gcc "../gmem/wdog.c"
(followed by 912 useless bytes)
-mcpu=cortex-m4 -std=gnu11 -g3 -DDEBUG -DNUCLEO -DUSE_HAL_DRIVER -DSTM32F446xx -DUSE_FULL_LL_DRIVER -c -I"E:/STM32CubeIDE_11/fatl22_lcd/Ampel" -I../Core/Inc -I"E:/STM32CubeIDE_11/fatl22_lcd/lcd" -I"E:/STM32CubeIDE_11/fatl22_lcd/rtc" -I"E:/STM32CubeIDE_11/fatl22_lcd/so" -I"E:/STM32CubeIDE_11/fatl22_lcd/uart" -I"E:/STM32CubeIDE_11/fatl22_lcd/interrupts" -I"E:/STM32CubeIDE_11/fatl22_lcd/gmem" -I../Drivers/STM32F4xx_HAL_Driver/Inc -I"E:/STM32CubeIDE_11/fatl22_lcd/debugpins" -I"E:/STM32CubeIDE_11/fatl22_lcd/funk" -I"E:/STM32CubeIDE_11/fatl22_lcd/kabel" -I"E:/STM32CubeIDE_11/fatl22_lcd/scheduler" -I../Drivers/STM32F4xx_HAL_Driver/Inc/Legacy -I../Drivers/CMSIS/Device/ST/STM32F4xx/Include -I../Drivers/CMSIS/Include -O0 -ffunction-sections -fdata-sections -Wall -Wconversion -fstack-usage -MMD -MP -MF"gmem/wdog.d" -MT"gmem/wdog.o" --specs=nano.specs -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mthumb -o "gmem/wdog.o"
How can I get rid of this crap ?
I searched for gcc option help files and some "how to increase verbosity" hoping to find the contrary ;-) .
I found explicit help for reducing warnings, which is not my intention.

Cannot compile Nim file using GTK+ 3

I 'm newbie.(And I cannot speak English better.)
I'm trying compile Nim code using gtk
{.push header:"<gtk/gtk.h>",varargs.}
proc gtk_init(argc,argv:pointer=nil)
proc gtk_window_new(typ:int):pointer
proc gtk_main_quit
proc gtk_widget_show(win:pointer)
proc gtk_main
{.pop.}
var maindow:pointer
gtk_init()
maindow=gtk_window_new(0)
maindow.gtk_widget_set_size_request(300,200)
maindow.gtk_widget_show()
gtk_main()
I'm using this command ->
nim c -r test
However,It couldn't succeed.
fatal error: gtk/gtk.h: No such file or directory
#include <gtk/gtk.h>
^~~~~~~~~~~
compilation terminated.
I already installed libgtk-3-dev ,but didn't solved the problem.
(so I don't know that syntax of the code is correct.)
What should I do for compile it?
When you use GTK from a C program, you have to pass the correct include directories with -I and the correct linked libraries with -l. Usually, these are obtained by calling pkg-config:
$ pkg-config --cflags gtk+-3.0
-pthread -I/usr/include/gtk-3.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0 -I/usr/include/dbus-1.0 -I/usr/lib/x86_64-linux-gnu/dbus-1.0/include -I/usr/include/gtk-3.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng16 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include
$ pkg-config --libs gtk+-3.0
-lgtk-3 -lgdk-3 -lpangocairo-1.0 -lpango-1.0 -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0
Thus, to tell Nim to pass the right flags to the C compiler and linker, you can do the following:
{.passc: staticExec("pkg-config --cflags gtk+-3.0").}
{.passl: staticExec("pkg-config --libs gtk+-3.0").}
{.push header:"<gtk/gtk.h>",varargs.}
proc gtk_init(argc,argv:pointer=nil)
proc gtk_window_new(typ:int):pointer
proc gtk_main_quit
proc gtk_widget_show(win:pointer)
proc gtk_main
{.pop.}
var maindow:pointer
gtk_init()
...
Such usage of GTK wouldn't be very typical though. You may find it easeir to just use an existing wrapper such as nim-gtk3.

Linking OpenMP with Matlab mex files [duplicate]

I've written a program of the following form:
#include "stuff_I_need.h"
int main(){
construct_array(); // uses OpenMP pragma's
print_array();
return(0);
}
that compiles, links, and runs correctly with the following command:
`gcc44 -I/home/matteson/sundials/include/ main.c -lm -L/home/matteson/sundials/lib -lsundials_cvode -lsundials_nvecserial -fopenmp -o /home/matteson/MPI_test/CVODE_test/main_test`
"gcc44" is simply gcc version 4.4 and is named like this because it's being compiled on a cluster that maintains several versions of gcc. The libraries sundials_cvode and sundials_nvecserial are used in the solving of several differential equations during the construction of the array.
Now when I want to transfer over to Matlab and try to compile the mex file of the form:
#include "stuff_I_need.h"
void mexFunction(int nlhs,mxArray* plhs[], int nrhs, const mxArray* prhs[]){
construct_array(); // uses OpenMP pragma's
print_array();
}
and try to compile with the following command in Matlab:
>> mex -v CC="gcc44" CFLAGS="\$CFLAGS -I/home/matteson/sundials/include/ -fopenmp" LDFLAGS="\$LDFLAGS -fopenmp -L/home/matteson/sundials/lib -lsundials_cvode -lsundials_nvecserial" mex_cvode.c
I get the following messages culminating in a link error:
-> mexopts.sh sourced from directory (DIR = $HOME/.matlab/$REL_VERSION)
FILE = /home/matteson/.matlab/R2010b/mexopts.sh
----------------------------------------------------------------
-> MATLAB = /misc/linux/64/opt/pkg/matlab/R2010b
-> CC = gcc44
-> CC flags:
CFLAGS = -ansi -D_GNU_SOURCE -fexceptions -fPIC -fno-omit-frame-pointer -pthread -I/home/matteson/sundials/include/ -L/home/matteson/sundials/lib -lsundials_cvode -L/home/matteson/sundials/lib -lsundials_nvecserial
CDEBUGFLAGS = -g
COPTIMFLAGS = -O -DNDEBUG
CLIBS = -Wl,-rpath-link,/misc/linux/64/opt/pkg/matlab/R2010b/bin/glnxa64 -L/misc/linux/64/opt/pkg/matlab/R2010b/bin/glnxa64 -lmx -lmex -lmat -lm -lstdc++
arguments = -DMX_COMPAT_32
-> CXX = g++
-> CXX flags:
CXXFLAGS = -ansi -D_GNU_SOURCE -fPIC -fno-omit-frame-pointer -pthread
CXXDEBUGFLAGS = -g
CXXOPTIMFLAGS = -O -DNDEBUG
CXXLIBS = -Wl,-rpath-link,/misc/linux/64/opt/pkg/matlab/R2010b/bin/glnxa64 -L/misc/linux/64/opt/pkg/matlab/R2010b/bin/glnxa64 -lmx -lmex -lmat -lm
arguments = -DMX_COMPAT_32
-> FC = g95
-> FC flags:
FFLAGS = -fexceptions -fPIC -fno-omit-frame-pointer
FDEBUGFLAGS = -g
FOPTIMFLAGS = -O
FLIBS = -Wl,-rpath-link,/misc/linux/64/opt/pkg/matlab/R2010b/bin/glnxa64 -L/misc/linux/64/opt/pkg/matlab/R2010b/bin/glnxa64 -lmx -lmex -lmat -lm
arguments = -DMX_COMPAT_32
-> LD = gcc44
-> Link flags:
LDFLAGS = -pthread -shared -Wl,--version-script,/misc/linux/64/opt/pkg/matlab/R2010b/extern/lib/glnxa64/mexFunction.map -Wl,--no-undefined -fopenmpofopenmp
LDDEBUGFLAGS = -g
LDOPTIMFLAGS = -O
LDEXTENSION = .mexa64
arguments =
-> LDCXX =
-> Link flags:
LDCXXFLAGS =
LDCXXDEBUGFLAGS =
LDCXXOPTIMFLAGS =
LDCXXEXTENSION =
arguments =
----------------------------------------------------------------
Warning: You are using gcc version "4.4.4". The version
currently supported with MEX is "4.3.4".
For a list of currently supported compilers see:
http://www.mathworks.com/support/compilers/current_release/
-> gcc44 -c -I/misc/linux/64/opt/pkg/matlab/R2010b/extern/include -I/misc/linux/64/opt/pkg/matlab/R2010b/simulink/include -DMATLAB_MEX_FILE -ansi -D_GNU_SOURCE -fexceptions -fPIC -fno-omit-frame-pointer -pthread -I/home/matteson/sundials/include/ -L/home/matteson/sundials/lib -lsundials_cvode -L/home/matteson/sundials/lib -lsundials_nvecserial -DMX_COMPAT_32 -O -DNDEBUG "mex_cvode.c"
-> gcc44 -O -pthread -shared -Wl,--version-script,/misc/linux/64/opt/pkg/matlab/R2010b/extern/lib/glnxa64/mexFunction.map -Wl,--no-undefined -fopenmpofopenmp -o "mex_cvode.mexa64" mex_cvode.o -Wl,-rpath-link,/misc/linux/64/opt/pkg/matlab/R2010b/bin/glnxa64 -L/misc/linux/64/opt/pkg/matlab/R2010b/bin/glnxa64 -lmx -lmex -lmat -lm -lstdc++
mex_cvode.o: In function `mexFunction':
mex_cvode.c:(.text+0x2b2): undefined reference to `N_VNew_Serial'
mex_cvode.c:(.text+0x2db): undefined reference to `N_VNew_Serial'
mex_cvode.c:(.text+0x35b): undefined reference to `CVodeCreate'
mex_cvode.c:(.text+0x39c): undefined reference to `CVodeInit'
mex_cvode.c:(.text+0x3dd): undefined reference to `CVodeSVtolerances'
mex_cvode.c:(.text+0x412): undefined reference to `CVodeSetUserData'
mex_cvode.c:(.text+0x449): undefined reference to `CVDense'
mex_cvode.c:(.text+0x482): undefined reference to `CVDlsSetDenseJacFn'
mex_cvode.c:(.text+0x50c): undefined reference to `CVode'
mex_cvode.c:(.text+0x5b4): undefined reference to `N_VDestroy_Serial'
mex_cvode.c:(.text+0x5c0): undefined reference to `N_VDestroy_Serial'
mex_cvode.c:(.text+0x5cc): undefined reference to `CVodeFree'
collect2: ld returned 1 exit status
mex: link of ' "mex_cvode.mexa64"' failed.
??? Error using ==> mex at 208
Unable to complete successfully.
Somehow, I'm not giving the correct flags to link appropriately. As I get the same set of errors (plus a few more) if I remove the commands to link in the gcc44 command, I'm pretty sure that I'm not getting the compiler to "see" the libraries.
My questions are :
If my analysis of the error is correct, what flags do I need to pass to the mex compilation command to successfully link?
Alternatively, what are the gcc flags to compile and link outside of the Matlab environment to compile a .mex64 executable?
If my analysis is wrong, where to go from here?
I think I've ruled out the unsupported compiler warning since I've been able to compile simple mex with OpenMP programs using gcc 4.4, but these did not have to link against anything except the math library. Also, if I compile with version gcc version 4.1.2 or 4.3.4 with or without the "-fopenmp" flags I get the same error.
In the end I do need version 4.4 because of certain OpenMP support that did not appear in prior versions.
Thanks in advance for the help.
--Andrew
Edits: (#KWATFORD)
So I tried the command with the statements outside the the quotes, and got the error:
-> gcc44 -c -I/home/matteson/sundials/include/ -I/misc/linux/64/opt/pkg/matlab/R2010b/extern/include -I/misc/linux/64/opt/pkg/matlab/R2010b/simulink/include -DMATLAB_MEX_FILE -ansi -D_GNU_SOURCE -fexceptions -fPIC -fno-omit-frame-pointer -pthread -fopenmp -DMX_COMPAT_32 -O -DNDEBUG "mex_cvode.c"
-> gcc44 -O -pthread -shared -Wl,--version-script,/misc/linux/64/opt/pkg/matlab/R2010b/extern/lib/glnxa64/mexFunction.map -Wl,--no-undefined -fopenmp -o "mex_cvode.mexa64" mex_cvode.o -L/home/matteson/sundials/lib -lsundials_cvode -lsundials_nvecserial -Wl,-rpath-link,/misc/linux/64/opt/pkg/matlab/R2010b/bin/glnxa64 -L/misc/linux/64/opt/pkg/matlab/R2010b/bin/glnxa64 -lmx -lmex -lmat -lm -lstdc++
/usr/bin/ld: /home/matteson/sundials/lib/libsundials_cvode.a(cvode.o): relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile with -fPIC
/home/matteson/sundials/lib/libsundials_cvode.a: could not read symbols: Bad value
collect2: ld returned 1 exit status
mex: link of ' "mex_cvode.mexa64"' failed.
??? Error using ==> mex at 208
Unable to complete successfully.
I'm a bit confused about the suggestion to recompile with "-fPIC" because when I look at the gcc44 command I see the -fPIC as an option.
Are they saying to recompile the library with -fPIC?
I don't have the source for the library, if the suggestion is to recompile the library is there a workaround?
What does "relocation against local object" mean?
My continued thanks.
Try not putting the -l, -L, or -I arguments in those environment variables. The mex function will handle those types of arguments directly. So perhaps something like:
mex -v CC="gcc44" CFLAGS="\$CFLAGS -fopenmp" LDFLAGS="\$LDFLAGS -fopenmp" -I/home/matteson/sundials/include/ -L/home/matteson/sundials/lib -lsundials_cvode -lsundials_nvecserial mex_cvode.c
Kwatford put me on the right track with the second question. I was able to get the mex command to work by rebuilding the sundials solver with shared libraries. Specifically, I built with:
% make distclean
% ./configure --prefix=/home/matteson/sundials --enable-shared
% make
% make install
Also, thanks to kwatford for the fix to the original by calling:
mex -v CC="gcc44" CFLAGS="\$CFLAGS -fopenmp" LDFLAGS="\$LDFLAGS -fopenmp" -I/home/matteson/sundials/include/ -L/home/matteson/sundials/lib -lsundials_cvode -lsundials_nvecserial mex_cvode.c
since mex knows how to handle the -L and -I.
Matlab uses its own libstdc and libstdc++.
The shortcut would be to do a symbolink to those libraries to the gcc44 libraries that you want to use.
But this may not be the desired way to go. You could try compiling outside matlab prompt and see if it still fails compilation first.

perl-DBI / perl-DBD-oracle installation

What I want to do is connecting and retrieving data from oracle database through perl.
What i did(as oracle account) is like below.....
$ rpm -qa|grep DBI
perl-DBI-1.52-2.el5
$ wget http://search.cpan.org/CPAN/authors/id/P/PY/PYTHIAN/DBD-Oracle-1.17.tar.gz
$ tar -zxf DBD-Oracle-1.17.tar.gz
$ cd DBD-Oracle-1.17
$ perl Makefile.PL
Using DBI 1.52 (for perl 5.008008 on x86_64-linux-thread-multi) installed in /usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi/auto/DBI/
Configuring DBD::Oracle for perl 5.008008 on linux (x86_64-linux-thread-multi)
Remember to actually *READ* the README file! Especially if you have any problems.
Using Oracle in /sw/oracle/app/oracle/product/102
DEFINE _SQLPLUS_RELEASE = "1002000500" (CHAR)
Oracle version 10.2.0.5 (10.2)
Found /sw/oracle/app/oracle/product/102/rdbms/demo/demo_rdbms.mk
Using /sw/oracle/app/oracle/product/102/rdbms/demo/demo_rdbms.mk
Your LD_LIBRARY_PATH env var is set to '/sw/oracle/app/oracle/product/102/lib:/usr/lib:/sw/oracle/app/oracle/product/102/lib32:.'
Reading /sw/oracle/app/oracle/product/102/rdbms/demo/demo_rdbms.mk
Reading /sw/oracle/app/oracle/product/102/rdbms/lib/env_rdbms.mk
Attempting to discover Oracle OCI build rules
gcc -c -o DBD_ORA_OBJ.o DBD_ORA_OBJ.c
by executing: [make -f /sw/oracle/app/oracle/product/102/rdbms/demo/demo_rdbms.mk build ECHODO=echo ECHO=echo GENCLNTSH='echo genclntsh' CC=true OPTIMIZE= CCFLAGS= EXE=DBD_ORA_EXE OBJS=DBD_ORA_OBJ.o]
Oracle oci build command:
[true -L/sw/oracle/app/oracle/product/102/lib/ -L/sw/oracle/app/oracle/product/102/rdbms/lib/ -o DBD_ORA_EXE DBD_ORA_OBJ.o -lclntsh `cat /sw/oracle/app/oracle/product/102/lib/sysliblist` -ldl -lm -lpthread]
Found header files in /sw/oracle/app/oracle/product/102/rdbms/public.
Checking for functioning wait.ph
Constant subroutine __USE_POSIX undefined at /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/features.ph line 8.
Constant subroutine __USE_POSIX2 undefined at /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/features.ph line 9.
Constant subroutine __USE_POSIX199309 undefined at /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/features.ph line 10.
Constant subroutine __USE_POSIX199506 undefined at /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/features.ph line 11.
Constant subroutine __USE_XOPEN undefined at /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/features.ph line 12.
Constant subroutine __USE_XOPEN_EXTENDED undefined at /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/features.ph line 13.
Constant subroutine __USE_UNIX98 undefined at /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/features.ph line 14.
Constant subroutine __USE_LARGEFILE undefined at /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/features.ph line 16.
Constant subroutine __USE_LARGEFILE64 undefined at /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/features.ph line 17.
Constant subroutine __USE_FILE_OFFSET64 undefined at /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/features.ph line 18.
Constant subroutine __USE_BSD undefined at /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/features.ph line 19.
Constant subroutine __USE_SVID undefined at /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/features.ph line 20.
Constant subroutine __USE_MISC undefined at /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/features.ph line 21.
Constant subroutine __USE_GNU undefined at /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/features.ph line 23.
Constant subroutine __USE_REENTRANT undefined at /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/features.ph line 24.
Constant subroutine _POSIX_SOURCE undefined at /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/features.ph line 49.
Constant subroutine _POSIX_C_SOURCE undefined at /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/features.ph line 51.
Constant subroutine _XOPEN_SOURCE undefined at /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/features.ph line 53.
Constant subroutine _XOPEN_SOURCE_EXTENDED undefined at /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/features.ph line 55.
Constant subroutine _LARGEFILE64_SOURCE undefined at /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/features.ph line 57.
Constant subroutine _LARGEFILE_SOURCE undefined at /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/features.ph line 104.
Constant subroutine __USE_ISOC99 undefined at /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/features.ph line 108.
Constant subroutine __GNU_LIBRARY__ undefined at /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/features.ph line 156.
Operator or semicolon missing before &__inline at (eval 167) line 1.
Ambiguous use of & resolved as operator & at (eval 167) line 1.
Constant subroutine __need_size_t undefined at /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/stddef.ph line 148.
Scalar found where operator expected at (eval 241) line 1, near "'int' $__val"
(Missing operator before $__val?)
Number found where operator expected at (eval 245) line 1, near ") 0"
(Missing operator before 0?)
Number found where operator expected at (eval 246) line 1, near ") 1"
(Missing operator before 1?)
Number found where operator expected at (eval 247) line 1, near ") 2"
(Missing operator before 2?)
Constant subroutine __need_timespec undefined at /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/time.ph line 49.
Hexadecimal number > 0xffffffff non-portable at (eval 447) line 1.
Hexadecimal number > 0xffffffff non-portable at (eval 448) line 1.
Constant subroutine __need_timeval undefined at /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/bits/time.ph line 23.
System: perl5.008008 linux builder10.centos.org 2.6.18-53.el5 #1 smp mon nov 12 02:14:55 est 2007 x86_64 x86_64 x86_64 gnulinux
Compiler: gcc -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -Wdeclaration-after-statement -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm
Linker: /usr/bin/ld
Sysliblist: -ldl -lm -lpthread -lnsl -lirc
Oracle makefiles would have used these definitions but we override them:
CC: $(COMPDIR)/bin/gcc
CFLAGS: $(GFLAG) $(OPTIMIZE) $(CDEBUG) $(CCFLAGS) $(PFLAGS)\
$(SHARED_CFLAG) $(USRFLAGS)
[$(GFLAG) -O3 $(CDEBUG) -m32 -trigraphs -fPIC -I/sw/oracle/app/oracle/product/102/rdbms/demo -I/sw/oracle/app/oracle/product/102/rdbms/public -I/sw/oracle/app/oracle/product/102/plsql/public -I/sw/oracle/app/oracle/product/102/network/public -DLINUX -D_GNU_SOURCE -D_LARGEFILE64_SOURCE=1 -D_LARGEFILE_SOURCE=1 -DSLTS_ENABLE -DSLMXMX_ENABLE -D_REENTRANT -DNS_THREADS -fno-strict-aliasing $(LPFLAGS) $(USRFLAGS)]
LDFLAGS: $(LDFLAGS32)
[-m32 -o $# -L/sw/oracle/app/oracle/product/102/rdbms//lib32/ -L/sw/oracle/app/oracle/product/102/lib32/ -L/sw/oracle/app/oracle/product/102/lib32/stubs/]
Linking with OTHERLDFLAGS = -L/sw/oracle/app/oracle/product/102/lib/ -L/sw/oracle/app/oracle/product/102/rdbms/lib/ -lclntsh `cat /sw/oracle/app/oracle/product/102/lib/sysliblist` -ldl -lm -lpthread [from 'build' rule]
Checking if your kit is complete...
Looks good
LD_RUN_PATH=/sw/oracle/app/oracle/product/102/lib:/sw/oracle/app/oracle/product/102/rdbms/lib
Using DBD::Oracle 1.17.
Using DBD::Oracle 1.17.
Using DBI 1.52 (for perl 5.008008 on x86_64-linux-thread-multi) installed in /usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi/auto/DBI/
Writing Makefile for DBD::Oracle
*** If you have problems...
read all the log printed above, and the README and README.help.txt files.
(Of course, you have read README by now anyway, haven't you?)
$ make
cp Oracle.pm blib/lib/DBD/Oracle.pm
cp oraperl.ph blib/lib/oraperl.ph
cp dbdimp.h blib/arch/auto/DBD/Oracle/dbdimp.h
cp ocitrace.h blib/arch/auto/DBD/Oracle/ocitrace.h
cp Oraperl.pm blib/lib/Oraperl.pm
cp Oracle.h blib/arch/auto/DBD/Oracle/Oracle.h
cp lib/DBD/Oracle/GetInfo.pm blib/lib/DBD/Oracle/GetInfo.pm
cp mk.pm blib/arch/auto/DBD/Oracle/mk.pm
/usr/bin/perl -p -e "s/~DRIVER~/Oracle/g" /usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi/auto/DBI/Driver.xst > Oracle.xsi
/usr/bin/perl /usr/lib/perl5/5.8.8/ExtUtils/xsubpp -typemap /usr/lib/perl5/5.8.8/ExtUtils/typemap -typemap typemap Oracle.xs > Oracle.xsc && mv Oracle.xsc Oracle.c
gcc -c -I/sw/oracle/app/oracle/product/102/rdbms/public -I/sw/oracle/app/oracle/product/102/rdbms/demo -I/sw/oracle/app/oracle/product/102/rdbms/public -I/sw/oracle/app/oracle/product/102/plsql/public -I/sw/oracle/app/oracle/product/102/network/public -I/usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi/auto/DBI -D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -Wdeclaration-after-statement -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -DVERSION=\"1.17\" -DXS_VERSION=\"1.17\" -fPIC "-I/usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/CORE" -Wall -Wno-comment -DUTF8_SUPPORT -DNEW_OCI_INIT -DORA_OCI_VERSION=\"10.2.0.5\" Oracle.c
Oracle.c: In function 'XS_DBD__Oracle__db_ora_lob_append':
Oracle.xs:201: warning: unused variable 'startp'
gcc -c -I/sw/oracle/app/oracle/product/102/rdbms/public -I/sw/oracle/app/oracle/product/102/rdbms/demo -I/sw/oracle/app/oracle/product/102/rdbms/public -I/sw/oracle/app/oracle/product/102/plsql/public -I/sw/oracle/app/oracle/product/102/network/public -I/usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi/auto/DBI -D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -Wdeclaration-after-statement -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -DVERSION=\"1.17\" -DXS_VERSION=\"1.17\" -fPIC "-I/usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/CORE" -Wall -Wno-comment -DUTF8_SUPPORT -DNEW_OCI_INIT -DORA_OCI_VERSION=\"10.2.0.5\" dbdimp.c
dbdimp.c: In function 'ora_db_login6':
dbdimp.c:652: warning: value computed is not used
dbdimp.c: In function 'dbd_rebind_ph_char':
dbdimp.c:1052: warning: value computed is not used
gcc -c -I/sw/oracle/app/oracle/product/102/rdbms/public -I/sw/oracle/app/oracle/product/102/rdbms/demo -I/sw/oracle/app/oracle/product/102/rdbms/public -I/sw/oracle/app/oracle/product/102/plsql/public -I/sw/oracle/app/oracle/product/102/network/public -I/usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi/auto/DBI -D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -Wdeclaration-after-statement -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -DVERSION=\"1.17\" -DXS_VERSION=\"1.17\" -fPIC "-I/usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/CORE" -Wall -Wno-comment -DUTF8_SUPPORT -DNEW_OCI_INIT -DORA_OCI_VERSION=\"10.2.0.5\" oci8.c
oci8.c: In function 'fetch_func_rset':
oci8.c:626: warning: value computed is not used
oci8.c: In function 'dbd_rebind_ph_lob':
oci8.c:711: warning: value computed is not used
oci8.c: In function 'ora_blob_read_mb_piece':
oci8.c:778: warning: comparison is always false due to limited range of data type
oci8.c: In function 'ora_describe':
oci8.c:1267: warning: comparison is always false due to limited range of data type
oci8.c: In function 'post_execute_lobs':
oci8.c:2118: warning: value computed is not used
oci8.c: At top level:
oci8.c:563: warning: 'fetch_func_nty' defined but not used
Running Mkbootstrap for DBD::Oracle ()
chmod 644 Oracle.bs
rm -f blib/arch/auto/DBD/Oracle/Oracle.so
gcc -shared -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic Oracle.o dbdimp.o oci8.o -L/sw/oracle/app/oracle/product/102/lib/ -L/sw/oracle/app/oracle/product/102/rdbms/lib/ -lclntsh `cat /sw/oracle/app/oracle/product/102/lib/sysliblist` -ldl -lm -lpthread -o blib/arch/auto/DBD/Oracle/Oracle.so \
\
chmod 755 blib/arch/auto/DBD/Oracle/Oracle.so
cp Oracle.bs blib/arch/auto/DBD/Oracle/Oracle.bs
chmod 644 blib/arch/auto/DBD/Oracle/Oracle.bs
/usr/bin/perl "-Iblib/arch" "-Iblib/lib" ora_explain.PL ora_explain
Extracted ora_explain from ora_explain.PL with variable substitutions.
cp ora_explain blib/script/ora_explain
/usr/bin/perl "-MExtUtils::MY" -e "MY->fixin(shift)" blib/script/ora_explain
Manifying blib/man1/ora_explain.1
Manifying blib/man3/DBD::Oracle.3pm
Manifying blib/man3/DBD::Oraperl.3pm
$ make install
Warning: You do not have permissions to install into /usr/share/man/man1 at /usr/lib/perl5/5.8.8/ExtUtils/Install.pm line 114.
Files found in blib/arch: installing files in blib/lib into architecture dependent library tree
Writing /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi/auto/DBD/Oracle/.packlist
Appending installation info to /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/perllocal.pod
$ sudo - chmod 777 /usr/share/man
Warning: You do not have permissions to install into /usr/bin at /usr/lib/perl5/5.8.8/ExtUtils/Install.pm line 114.
Files found in blib/arch: installing files in blib/lib into architecture dependent library tree
Writing /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi/auto/DBD/Oracle/.packlist
Appending installation info to /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/perllocal.pod
$ sudo - chmod 777 /usr/bin
Files found in blib/arch: installing files in blib/lib into architecture dependent library tree
Writing /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi/auto/DBD/Oracle/.packlist
Appending installation info to /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/perllocal.pod
$ perl -e 'use DBD::Oracle'
install_driver(Oracle) failed: Can't load '/usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi/auto/DBD/Oracle/Oracle.so' for module DBD::Oracle: /sw/oracle/app/oracle/product/102/lib/libnnz10.so: cannot restore segment prot after reloc: Permission denied at /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/DynaLoader.pm line 230.
at (eval 3) line 3
Compilation failed in require at (eval 3) line 3.
Perhaps a required shared library or dll isn't installed where expected
at ./ora_dump.pl line 7
I've checked permission of /sw/oracle/app/oracle/product/102/lib/libnnz10.so.
My machine is on CentOS release 5.5 and 10g Enterprise Edition Release 10.2.0.5.0...
What am I missing?
Sounds like an issue with SELinux. Try disabling it and see if this resolves your problem:
http://www.crypt.gen.nz/selinux/disable_selinux.html
I do not know what you are missing and where you are going wrong. But I always follow below method and it has worked 100% times for me. Try this method and if it does not work, then I can definitely make it work for you....
One thing I notice in your post is that you are getting permissions issues. Try running these steps as root.
My environment: Oracle 11G running on remote box
My desktop: ubunt/fedora/RHEL/CenOS
I have implemented this on all above 4 flavors of Linux and they all work perfectly.
Here are the steps (Follow 'em the sequence given):
Install Perl DBI module
install below 3 rpm for oracle instant client from http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html
oracle-instantclient11.2-basic-11.2.0.3.0-1
oracle-instantclient11.2-devel-11.2.0.3.0-1
oracle-instantclient11.2-sqlplus-11.2.0.3.0-1
I am using 64 bit linux box, so choose your RPM accordingly.
set below variables:
LD_LIBRARY_PATH=/usr/lib/oracle/11.2/client64/lib
ORACLE_HOME=/usr/lib/oracle/11.2/client64
also add ORACLE_HOME to your PATH variable
download DBD::Oracle ver 1.44 from CPAN.
untar the module and run below commands in given sequence:
perl Makefile.PL
make make
install
DONE !!!

How to link during Matlab's MEX compilation

I've written a program of the following form:
#include "stuff_I_need.h"
int main(){
construct_array(); // uses OpenMP pragma's
print_array();
return(0);
}
that compiles, links, and runs correctly with the following command:
`gcc44 -I/home/matteson/sundials/include/ main.c -lm -L/home/matteson/sundials/lib -lsundials_cvode -lsundials_nvecserial -fopenmp -o /home/matteson/MPI_test/CVODE_test/main_test`
"gcc44" is simply gcc version 4.4 and is named like this because it's being compiled on a cluster that maintains several versions of gcc. The libraries sundials_cvode and sundials_nvecserial are used in the solving of several differential equations during the construction of the array.
Now when I want to transfer over to Matlab and try to compile the mex file of the form:
#include "stuff_I_need.h"
void mexFunction(int nlhs,mxArray* plhs[], int nrhs, const mxArray* prhs[]){
construct_array(); // uses OpenMP pragma's
print_array();
}
and try to compile with the following command in Matlab:
>> mex -v CC="gcc44" CFLAGS="\$CFLAGS -I/home/matteson/sundials/include/ -fopenmp" LDFLAGS="\$LDFLAGS -fopenmp -L/home/matteson/sundials/lib -lsundials_cvode -lsundials_nvecserial" mex_cvode.c
I get the following messages culminating in a link error:
-> mexopts.sh sourced from directory (DIR = $HOME/.matlab/$REL_VERSION)
FILE = /home/matteson/.matlab/R2010b/mexopts.sh
----------------------------------------------------------------
-> MATLAB = /misc/linux/64/opt/pkg/matlab/R2010b
-> CC = gcc44
-> CC flags:
CFLAGS = -ansi -D_GNU_SOURCE -fexceptions -fPIC -fno-omit-frame-pointer -pthread -I/home/matteson/sundials/include/ -L/home/matteson/sundials/lib -lsundials_cvode -L/home/matteson/sundials/lib -lsundials_nvecserial
CDEBUGFLAGS = -g
COPTIMFLAGS = -O -DNDEBUG
CLIBS = -Wl,-rpath-link,/misc/linux/64/opt/pkg/matlab/R2010b/bin/glnxa64 -L/misc/linux/64/opt/pkg/matlab/R2010b/bin/glnxa64 -lmx -lmex -lmat -lm -lstdc++
arguments = -DMX_COMPAT_32
-> CXX = g++
-> CXX flags:
CXXFLAGS = -ansi -D_GNU_SOURCE -fPIC -fno-omit-frame-pointer -pthread
CXXDEBUGFLAGS = -g
CXXOPTIMFLAGS = -O -DNDEBUG
CXXLIBS = -Wl,-rpath-link,/misc/linux/64/opt/pkg/matlab/R2010b/bin/glnxa64 -L/misc/linux/64/opt/pkg/matlab/R2010b/bin/glnxa64 -lmx -lmex -lmat -lm
arguments = -DMX_COMPAT_32
-> FC = g95
-> FC flags:
FFLAGS = -fexceptions -fPIC -fno-omit-frame-pointer
FDEBUGFLAGS = -g
FOPTIMFLAGS = -O
FLIBS = -Wl,-rpath-link,/misc/linux/64/opt/pkg/matlab/R2010b/bin/glnxa64 -L/misc/linux/64/opt/pkg/matlab/R2010b/bin/glnxa64 -lmx -lmex -lmat -lm
arguments = -DMX_COMPAT_32
-> LD = gcc44
-> Link flags:
LDFLAGS = -pthread -shared -Wl,--version-script,/misc/linux/64/opt/pkg/matlab/R2010b/extern/lib/glnxa64/mexFunction.map -Wl,--no-undefined -fopenmpofopenmp
LDDEBUGFLAGS = -g
LDOPTIMFLAGS = -O
LDEXTENSION = .mexa64
arguments =
-> LDCXX =
-> Link flags:
LDCXXFLAGS =
LDCXXDEBUGFLAGS =
LDCXXOPTIMFLAGS =
LDCXXEXTENSION =
arguments =
----------------------------------------------------------------
Warning: You are using gcc version "4.4.4". The version
currently supported with MEX is "4.3.4".
For a list of currently supported compilers see:
http://www.mathworks.com/support/compilers/current_release/
-> gcc44 -c -I/misc/linux/64/opt/pkg/matlab/R2010b/extern/include -I/misc/linux/64/opt/pkg/matlab/R2010b/simulink/include -DMATLAB_MEX_FILE -ansi -D_GNU_SOURCE -fexceptions -fPIC -fno-omit-frame-pointer -pthread -I/home/matteson/sundials/include/ -L/home/matteson/sundials/lib -lsundials_cvode -L/home/matteson/sundials/lib -lsundials_nvecserial -DMX_COMPAT_32 -O -DNDEBUG "mex_cvode.c"
-> gcc44 -O -pthread -shared -Wl,--version-script,/misc/linux/64/opt/pkg/matlab/R2010b/extern/lib/glnxa64/mexFunction.map -Wl,--no-undefined -fopenmpofopenmp -o "mex_cvode.mexa64" mex_cvode.o -Wl,-rpath-link,/misc/linux/64/opt/pkg/matlab/R2010b/bin/glnxa64 -L/misc/linux/64/opt/pkg/matlab/R2010b/bin/glnxa64 -lmx -lmex -lmat -lm -lstdc++
mex_cvode.o: In function `mexFunction':
mex_cvode.c:(.text+0x2b2): undefined reference to `N_VNew_Serial'
mex_cvode.c:(.text+0x2db): undefined reference to `N_VNew_Serial'
mex_cvode.c:(.text+0x35b): undefined reference to `CVodeCreate'
mex_cvode.c:(.text+0x39c): undefined reference to `CVodeInit'
mex_cvode.c:(.text+0x3dd): undefined reference to `CVodeSVtolerances'
mex_cvode.c:(.text+0x412): undefined reference to `CVodeSetUserData'
mex_cvode.c:(.text+0x449): undefined reference to `CVDense'
mex_cvode.c:(.text+0x482): undefined reference to `CVDlsSetDenseJacFn'
mex_cvode.c:(.text+0x50c): undefined reference to `CVode'
mex_cvode.c:(.text+0x5b4): undefined reference to `N_VDestroy_Serial'
mex_cvode.c:(.text+0x5c0): undefined reference to `N_VDestroy_Serial'
mex_cvode.c:(.text+0x5cc): undefined reference to `CVodeFree'
collect2: ld returned 1 exit status
mex: link of ' "mex_cvode.mexa64"' failed.
??? Error using ==> mex at 208
Unable to complete successfully.
Somehow, I'm not giving the correct flags to link appropriately. As I get the same set of errors (plus a few more) if I remove the commands to link in the gcc44 command, I'm pretty sure that I'm not getting the compiler to "see" the libraries.
My questions are :
If my analysis of the error is correct, what flags do I need to pass to the mex compilation command to successfully link?
Alternatively, what are the gcc flags to compile and link outside of the Matlab environment to compile a .mex64 executable?
If my analysis is wrong, where to go from here?
I think I've ruled out the unsupported compiler warning since I've been able to compile simple mex with OpenMP programs using gcc 4.4, but these did not have to link against anything except the math library. Also, if I compile with version gcc version 4.1.2 or 4.3.4 with or without the "-fopenmp" flags I get the same error.
In the end I do need version 4.4 because of certain OpenMP support that did not appear in prior versions.
Thanks in advance for the help.
--Andrew
Edits: (#KWATFORD)
So I tried the command with the statements outside the the quotes, and got the error:
-> gcc44 -c -I/home/matteson/sundials/include/ -I/misc/linux/64/opt/pkg/matlab/R2010b/extern/include -I/misc/linux/64/opt/pkg/matlab/R2010b/simulink/include -DMATLAB_MEX_FILE -ansi -D_GNU_SOURCE -fexceptions -fPIC -fno-omit-frame-pointer -pthread -fopenmp -DMX_COMPAT_32 -O -DNDEBUG "mex_cvode.c"
-> gcc44 -O -pthread -shared -Wl,--version-script,/misc/linux/64/opt/pkg/matlab/R2010b/extern/lib/glnxa64/mexFunction.map -Wl,--no-undefined -fopenmp -o "mex_cvode.mexa64" mex_cvode.o -L/home/matteson/sundials/lib -lsundials_cvode -lsundials_nvecserial -Wl,-rpath-link,/misc/linux/64/opt/pkg/matlab/R2010b/bin/glnxa64 -L/misc/linux/64/opt/pkg/matlab/R2010b/bin/glnxa64 -lmx -lmex -lmat -lm -lstdc++
/usr/bin/ld: /home/matteson/sundials/lib/libsundials_cvode.a(cvode.o): relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile with -fPIC
/home/matteson/sundials/lib/libsundials_cvode.a: could not read symbols: Bad value
collect2: ld returned 1 exit status
mex: link of ' "mex_cvode.mexa64"' failed.
??? Error using ==> mex at 208
Unable to complete successfully.
I'm a bit confused about the suggestion to recompile with "-fPIC" because when I look at the gcc44 command I see the -fPIC as an option.
Are they saying to recompile the library with -fPIC?
I don't have the source for the library, if the suggestion is to recompile the library is there a workaround?
What does "relocation against local object" mean?
My continued thanks.
Try not putting the -l, -L, or -I arguments in those environment variables. The mex function will handle those types of arguments directly. So perhaps something like:
mex -v CC="gcc44" CFLAGS="\$CFLAGS -fopenmp" LDFLAGS="\$LDFLAGS -fopenmp" -I/home/matteson/sundials/include/ -L/home/matteson/sundials/lib -lsundials_cvode -lsundials_nvecserial mex_cvode.c
Kwatford put me on the right track with the second question. I was able to get the mex command to work by rebuilding the sundials solver with shared libraries. Specifically, I built with:
% make distclean
% ./configure --prefix=/home/matteson/sundials --enable-shared
% make
% make install
Also, thanks to kwatford for the fix to the original by calling:
mex -v CC="gcc44" CFLAGS="\$CFLAGS -fopenmp" LDFLAGS="\$LDFLAGS -fopenmp" -I/home/matteson/sundials/include/ -L/home/matteson/sundials/lib -lsundials_cvode -lsundials_nvecserial mex_cvode.c
since mex knows how to handle the -L and -I.
Matlab uses its own libstdc and libstdc++.
The shortcut would be to do a symbolink to those libraries to the gcc44 libraries that you want to use.
But this may not be the desired way to go. You could try compiling outside matlab prompt and see if it still fails compilation first.