Can't install ImageMagick on CentOS 7 [magick/magick_libMagickCore_6_Q16_la-distribute-cache.lo] - centos

I am having some issues installing ImageMagick on my CentOS 7 server.
Here is the commands I used:
./configure --without-threads
Everything looks ok.
Option Value
-------------------------------------------------------------------------------
Shared libraries --enable-shared=yesyes
Static libraries --enable-static=yesyes
Module support --with-modules=nono
GNU ld --with-gnu-ld=yesyes
Quantum depth --with-quantum-depth=1616
High Dynamic Range Imagery
--enable-hdri=nono
Install documentation:yes
Delegate Library Configuration:
BZLIB --with-bzlib=yesyes
Autotrace --with-autotrace=nono
DJVU --with-djvu=yesyes
DPS --with-dps=yesno
FFTW --with-fftw=yesno
FlashPIX --with-fpx=yesno
FontConfig --with-fontconfig=yesyes
FreeType --with-freetype=yesyes
Ghostscript lib --with-gslib=nono
Graphviz --with-gvc=no
JBIG --with-jbig=yesno
JPEG v1 --with-jpeg=yesyes
JPEG-2000 --with-jp2=
LCMS v1 --with-lcms=yesno
LCMS v2 --with-lcms2=yesno
LQR --with-lqr=yesno
LTDL --with-ltdl=yesno
LZMA --with-lzma=yesyes
Magick++ --with-magick-plus-plus=yesno (failed tests)
OpenEXR --with-openexr=yesyes
OpenJP2 --with-openjp2=yesno
PANGO --with-pango=yesyes
PERL --with-perl=nono
PNG --with-png=yesyes
RSVG --with-rsvg=nono
TIFF --with-tiff=yesyes
WEBP --with-webp=yesno
WMF --with-wmf=nono
X11 --with-x=yes
XML --with-xml=yesyes
ZLIB --with-zlib=yesyes
Delegate Program Configuration:
GhostPCL Nonepcl6 (unknown)
GhostXPS Nonegxps (unknown)
Ghostscript Nonegs (9.07)
Font Configuration:
Apple fonts --with-apple-font-dir=defaultnone
Dejavu fonts --with-dejavu-font-dir=defaultnone
Ghostscript fonts --with-gs-font-dir=default/usr/share/fonts/default/Type1/
Windows fonts --with-windows-font-dir=defaultnone
X11 Configuration:
X_CFLAGS =
X_PRE_LIBS = -lSM -lICE
X_LIBS =
X_EXTRA_LIBS =
Options used to compile and link:
PREFIX = /usr/local
EXEC-PREFIX = /usr/local
VERSION = 6.9.0
CC = gcc -std=gnu99 -std=gnu99
CFLAGS = -pthread -I/usr/include/OpenEXR -I/usr/include/libdrm -I/usr/include/freetype2 -g -O2 -Wall -march=corei7-avx -fexceptions -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16
CPPFLAGS = -pthread -I/usr/include/pango-1.0 -I/usr/include/cairo -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng15 -I/usr/include/libdrm -I/usr/include/freetype2 -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16 -I/usr/include/libxml2
PCFLAGS =
DEFS = -DHAVE_CONFIG_H
LDFLAGS =
LIBS =
CXX = g++
CXXFLAGS =
FEATURES = DPC
DELEGATES = bzlib djvu mpeg fontconfig freetype jng jpeg lzma openexr pango png ps tiff x xml zlib
Then I do:
make -j16
And I get this:
magick/distribute-cache.c:751:28: warning: 'DistributePixelCacheClient' defined but not used [-Wunused-function]
static HANDLER_RETURN_TYPE DistributePixelCacheClient(void *socket)
^
make[1]: *** [magick/magick_libMagickCore_6_Q16_la-distribute-cache.lo] Error 1
make[1]: *** Waiting for unfinished jobs....
In file included from magick/magick.c:72:0:
./magick/semaphore-private.h:36:3: warning: 'semaphore_mutex' defined but not used [-Wunused-variable]
semaphore_mutex = 0;
^
make[1]: Leaving directory `/usr/local/src/ImageMagick-6.9.0-2'
make: *** [all] Error 2
What am I doing wrong? What am I missing?

Related

ODBM_File.xs: too few arguments to function ‘dbmclose’ while building perl

I have been attempting to install Perl 5-22.0 locally on a server (on SUSE Linux x86_64). I was able to run .configure on the source code, but following the make command, I obtained the following error:
CE=2 -Wall -Werror=declaration-after-statement -Wextra -Wc++-compat -Wwrite-strings -O2 -DVERSION=\"1.12\" -DXS_VERSION=\"1.12\" -fPIC "-I../.." ODBM_File.c
ODBM_File.xs: In function ‘XS_ODBM_File_DESTROY’:
ODBM_File.xs:128: error: too few arguments to function ‘dbmclose’
make[1]: *** [ODBM_File.o] Error 1
make[1]: Leaving directory `/home1/02568/mshpak/perl/perl-5.22.0/ext/ODBM_File'
make[1]: Entering directory `/home1/02568/mshpak/perl/perl-5.22.0/ext/ODBM_File'
cc -c -fwrapv -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2 -Wall -Werror=declaration-after-statement -Wextra -Wc++-compat -Wwrite-strings -O2 -DVERSION=\"1.12\" -DXS_VERSION=\"1.12\" -fPIC "-I../.." ODBM_File.c
ODBM_File.xs: In function ‘XS_ODBM_File_DESTROY’:
ODBM_File.xs:128: error: too few arguments to function ‘dbmclose’
make[1]: *** [ODBM_File.o] Error 1
make[1]: Leaving directory `/home1/02568/mshpak/perl/perl-5.22.0/ext/ODBM_File'
Unsuccessful make(ext/ODBM_File): code=512 at make_ext.pl line 574.
make: *** [lib/auto/ODBM_File/ODBM_File.so] Error 25
What is error code 512, and is there a straightforward way to correct this (presumably something related to the ODBM_File directory's contents)?
Thank you
This is a known issue on SUSE Linux:
error: too few arguments to function 'dbmclose'
Building ODBM_File on some (Open)SUSE distributions might run into this error, as the header file is broken. There are two ways to deal with this
Disable the use of ODBM_FILE
Configure ... -Dnoextensions=ODBM_File
Fix the header file, somewhat like this:
--- a/usr/include/dbm.h 2010-03-24 08:54:59.000000000 +0100
+++ b/usr/include/dbm.h 2010-03-24 08:55:15.000000000 +0100
## -59,4 +59,4 ## extern datum firstkey __P((void));
extern datum nextkey __P((datum key));
-extern int dbmclose __P((DBM *));
+extern int dbmclose __P((void));

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.

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.

SCons: GCC Ignoring -c

I'm using a MinGW-based GCC cross-compiler to compile a project which uses SCons as its build system.
The Python is a native 2.6.2 version, not specifically compiled for MinGW (or Cygwin).
However, I am running into a problem with the build:
F:/pedigree/compilers/bin/i686-elf-gcc -o build\src\user\applications\apptest\ma
in.obj -c -std=gnu99 -march=i486 -fno-builtin -m32 -g0 -O3 -Wno-long-long -Wnest
ed-externs -Wall -Wextra -Wpointer-arith -Wcast-align -Wwrite-strings -Wno-long-
long -Wno-variadic-macros -Wno-unused -Wno-unused-variable -Wno-conversion -Wno-
format -Wno-empty-body -fno-stack-protector -DTHREADS -DDEBUGGER -DDEBUGGER_QWER
TY -DSERIAL_IS_FILE -DECHO_CONSOLE_TO_SERIAL -DKERNEL_NEEDS_ADDRESS_SPACE_SWITCH
-DADDITIONAL_CHECKS -DBITS_32 -DKERNEL_STANDALONE -DVERBOSE_LINKER -DX86 -DX86_
COMMON -DLITTLE_ENDIAN -D__UD_STANDALONE__ -DINSTALLER -Isrc\subsys\posix\includ
e -Ibuild\src\user\applications\apptest -Isrc\user\applications\apptest src\user
\applications\apptest\main.c
f:/pedigree/compilers/bin/../lib/gcc/i686-elf/4.4.1/../../../../i686-elf/bin/ld.
exe: crt0.o: No such file: No such file or directory
If I add -c to the CFLAGS, I get a compiled object called "main.obj -c" (there's a space between obj and -c there).
Does anyone have any idea what's happening? Is there anything I can do to solve this?
The project uses the POSIX platform to enforce progarm and object file extensions, however the POSIX platform in SCons defines a function "escape":
def escape(arg):
"escape shell special characters"
slash = '\\'
special = '"$()'
arg = string.replace(arg, slash, slash+slash)
for c in special:
arg = string.replace(arg, c, slash+c)
return '"' + arg + '"'
When it escapes the backslashes, it wreaks havoc in the Windows environment. Changing to a neutral platform, and specifying the extensions explicitly, fixes the problem.

Cross-compile Autotools-based Libraries for Official iPhone SDK

Background
I am writing a program that targets several different phones, including the iPhone. The program depends on several thirdparty libraries. I am having difficulty cross-compiling these thirdparty libraries for the iPhone and iPhone simulator. The libraries include the Apache Portable Runtime and GNUTLS, as well as their dependencies. I would like the built libraries to end up in the prefixes "/opt/iphone-3.1", "/opt/iphone-3.0", "/opt/iphone-2.2.1", "/opt/iphone-simulator-3.1", and "/opt/iphone-simulator-3.0", respectively.
In order to make the cross-compilation process easily repeatable, I am creating scripts to invoke the "configure" script for each of the target platforms ("iphone3.1-configure", "iphone3.0-configure", "iphone2.2.1-configure", "iphonesim3.1-configure", and "iphonesim3.0-configure"). This is where I am having trouble.
I am using a Mac OS X 10.6 Snow Leopard computer with the official Xcode 3.2 + iPhone SDK 3.1.
Status
I currently have the following "iphone3.1-configure" script:
#! /bin/bash
#
# Program : iphone3.1-configure
# Author : Michael Aaron Safyan
# Synopsis :
# This program runs the "configure" script generated by the
# GNU Autotools in order to cross-compile thirdparty libraries
# for the iPhone 3.1 SDK. Run this script while in a directory
# containing an autotools "configure" script. Once run, this
# you can use "make" and "sudo make install" to build the library.
# An install prefix of "/opt/iphone-3.1/" is used.
#
unset CPATH
unset C_INCLUDE_PATH
unset CPLUS_INCLUDE_PATH
unset OBJC_INCLUDE_PATH
unset LIBS
unset DYLD_FALLBACK_LIBRARY_PATH
unset DYLD_FALLBACK_FRAMEWORK_PATH
export BUILD_DARWIN_VER=`uname -r`
export SDKVER="3.1"
export DEVROOT="/Developer/Platforms/iPhoneOS.platform/Developer"
export SDKROOT="$DEVROOT/SDKs/iPhoneOS$SDKVER.sdk"
export PKG_CONFIG_PATH=/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS$SDKVER.sdk/usr/lib/pkgconfig:/Developer/Platforms/iPhoneOS.platform/Developer/usr/lib/pkgconfig:/opt/iphone-$SDKVER/lib/pkgconfig:/usr/local/iphone-$SDKVER/lib/pkgconfig
export PREFIX="/opt/iphone-$SDKVER"
export AS="$DEVROOT/usr/bin/as"
export ASCPP="$DEVROOT/usr/bin/as"
export AR="$DEVROOT/usr/bin/ar"
export RANLIB="$DEVROOT/usr/bin/ranlib"
export CPPFLAGS="-std=c99 -arch armv6 -pipe -no-cpp-precomp --sysroot='$SDKROOT' -isystem $SDKROOT/usr/include -isystem $DEVROOT/usr/include -isystem /opt/iphone-$SDKVER/include -isystem /usr/local/iphone-$SDKVER/include"
export CFLAGS="-std=c99 -arch armv6 -pipe -no-cpp-precomp --sysroot='$SDKROOT' -isystem $SDKROOT/usr/include -isystem $DEVROOT/usr/include -isystem /opt/iphone-$SDKVER/include -isystem /usr/local/iphone-$SDKVER/include"
export CXXFLAGS="-std=c99 -arch armv6 -pipe -no-cpp-precomp --sysroot='$SDKROOT' -isystem $SDKROOT/usr/include -isystem $DEVROOT/usr/include -isystem /opt/iphone-$SDKVER/include -isystem /usr/local/iphone-$SDKVER/include"
export LDFLAGS="-arch armv6 --sysroot='$SDKROOT' -L$SDKROOT/usr/lib -L$DEVROOT/usr/lib -L/opt/iphone-$SDKVER/lib -L/usr/local/iphone-$SDKVER/lib"
export CPP="$DEVROOT/usr/bin/cpp-4.2"
export CC="$DEVROOT/usr/bin/gcc-4.2"
export CXX="$DEVROOT/usr/bin/g++-4.2"
export LD="$DEVROOT/usr/bin/ld"
if [ ! \( -d "$DEVROOT" \) ] ; then
echo "The iPhone SDK could not be found. Folder \"$DEVROOT\" does not exist."
exit 1
fi
if [ ! \( -d "$SDKROOT" \) ] ; then
echo "The iPhone SDK could not be found. Folder \"$SDKROOT\" does not exist."
exit 1
fi
./configure --prefix="$PREFIX" --build="i386-apple-darwin$BUILD_DARWIN_VER" --host="arm-apple-darwin9" --enable-static --disable-shared $#
In the "apr-1.3.8" folder, I am running "iphone3.1-configure --disable-dso", and am getting:
checking build system type... i386-apple-darwin10.0.0
checking host system type... arm-apple-darwin9
checking target system type... arm-apple-darwin9
Configuring APR library
Platform: arm-apple-darwin9
checking for working mkdir -p... yes
APR Version: 1.3.8
checking for chosen layout... apr
checking for arm-apple-darwin9-gcc... /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc-4.2
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... yes
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc-4.2 accepts -g... yes
checking for /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc-4.2 option to accept ISO C89... unsupported
Applying APR hints file rules for arm-apple-darwin9
adding "-DDARWIN" to CPPFLAGS
adding "-DSIGPROCMASK_SETS_THREAD_MASK" to CPPFLAGS
setting apr_posixsem_is_global to "yes"
setting ac_cv_func_kqueue to "no"
setting ac_cv_func_poll to "no"
(Default will be unix)
checking whether make sets $(MAKE)... yes
checking how to run the C preprocessor... /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/cpp-4.2
configure: error: in `/Users/michaelsafyan/Downloads/apr-1.3.8':
configure: error: C preprocessor "/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/cpp-4.2" fails sanity check
See `config.log' for more details.
The relevant part of "config.log" is:
configure:7710: checking how to run the C preprocessor
configure:7828: result: /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/cpp-4.2
configure:7857: /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/cpp-4.2 -std=c99 -arch armv6 -pipe -no-cpp-precomp --sysroot='/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.1.sdk' -isystem /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.1.sdk/usr/include -isystem /Developer/Platforms/iPhoneOS.platform/Developer/usr/include -isystem /opt/iphone-3.1/include -isystem /usr/local/iphone-3.1/include -DDARWIN -DSIGPROCMASK_SETS_THREAD_MASK conftest.c
cpp-4.2: error trying to exec 'cc1': execvp: No such file or directory
configure:7864: $? = 1
configure: failed program was:
| /* confdefs.h. */
| #define PACKAGE_NAME ""
| #define PACKAGE_TARNAME ""
| #define PACKAGE_VERSION ""
| #define PACKAGE_STRING ""
| #define PACKAGE_BUGREPORT ""
| /* end confdefs.h. */
| #ifdef __STDC__
| # include
| #else
| # include
| #endif
| Syntax error
configure:7857: /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/cpp-4.2 -std=c99 -arch armv6 -pipe -no-cpp-precomp --sysroot='/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.1.sdk' -isystem /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.1.sdk/usr/include -isystem /Developer/Platforms/iPhoneOS.platform/Developer/usr/include -isystem /opt/iphone-3.1/include -isystem /usr/local/iphone-3.1/include -DDARWIN -DSIGPROCMASK_SETS_THREAD_MASK conftest.c
cpp-4.2: error trying to exec 'cc1': execvp: No such file or directory
configure:7864: $? = 1
configure: failed program was:
| /* confdefs.h. */
| #define PACKAGE_NAME ""
| #define PACKAGE_TARNAME ""
| #define PACKAGE_VERSION ""
| #define PACKAGE_STRING ""
| #define PACKAGE_BUGREPORT ""
| /* end confdefs.h. */
| #ifdef __STDC__
| # include
| #else
| # include
| #endif
| Syntax error
configure:7926: error: in `/Users/michaelsafyan/Downloads/apr-1.3.8':
configure:7929: error: C preprocessor "/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/cpp-4.2" fails sanity check
See `config.log' for more details.
Question
How do I fix the "iphone3.1-configure" script? Thanks.
Ok. This still doesn't build, but it gets much further...
The C preprocessor cannot take an architecture.
The C preprocessor does not accept --sysroot or -isystem (just use '-I').
Use "cpp" instead of "cpp-4.2" (the 4.2 version is defective, and since it is the preprocessor, it doesn't matter which version you use, anyway, so you might as well use the one that works.)
The updated version of the iphone3.1-configure script is:
#! /bin/bash
#
# Program : iphone3.1-configure
# Authors : Michael Aaron Safyan (michaelsafyan#gmail.com)
# Synopsis :
# This program runs the "configure" script generated by the
# GNU Autotools in order to cross-compile thirdparty libraries
# for the iPhone 3.1 SDK. Run this script while in a directory
# containing an autotools "configure" script. Once you run this,
# you can use "make" and "sudo make install" to build the library.
# An install prefix of "/opt/iphone-3.1/" is used.
#
unset CPATH
unset C_INCLUDE_PATH
unset CPLUS_INCLUDE_PATH
unset OBJC_INCLUDE_PATH
unset LIBS
unset DYLD_FALLBACK_LIBRARY_PATH
unset DYLD_FALLBACK_FRAMEWORK_PATH
export BUILD_DARWIN_VER=`uname -r`
export SDKVER="3.1"
export DEVROOT="/Developer/Platforms/iPhoneOS.platform/Developer"
export SDKROOT="$DEVROOT/SDKs/iPhoneOS$SDKVER.sdk"
export PKG_CONFIG_PATH=/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS$SDKVER.sdk/usr/lib/pkgconfig:/Developer/Platforms/iPhoneOS.platform/Developer/usr/lib/pkgconfig:/opt/iphone-$SDKVER/lib/pkgconfig:/usr/local/iphone-$SDKVER/lib/pkgconfig
export PREFIX="/opt/iphone-$SDKVER"
export AS="$DEVROOT/usr/bin/as"
export ASCPP="$DEVROOT/usr/bin/as"
export AR="$DEVROOT/usr/bin/ar"
export RANLIB="$DEVROOT/usr/bin/ranlib"
export CPPFLAGS="-pipe -no-cpp-precomp -I$SDKROOT/usr/lib/gcc/arm-apple-darwin9/4.2.1/include/ -I$SDKROOT/usr/include -I$DEVROOT/usr/include -I/opt/iphone-$SDKVER/include -I/usr/local/iphone-$SDKVER/include"
export CFLAGS="-std=c99 -arch armv6 -pipe -no-cpp-precomp --sysroot='$SDKROOT' -isystem $SDKROOT/usr/lib/gcc/arm-apple-darwin9/4.2.1/include/ -isystem $SDKROOT/usr/include -isystem $DEVROOT/usr/include -isystem /opt/iphone-$SDKVER/include -isystem /usr/local/iphone-$SDKVER/include"
export CXXFLAGS="-std=c99 -arch armv6 -pipe -no-cpp-precomp --sysroot='$SDKROOT' -isystem $SDKROOT/usr/lib/gcc/arm-apple-darwin9/4.2.1/include/ -isystem $SDKROOT/usr/include -isystem $DEVROOT/usr/include -isystem /opt/iphone-$SDKVER/include -isystem /usr/local/iphone-$SDKVER/include"
export LDFLAGS="-arch armv6 --sysroot='$SDKROOT' -L$SDKROOT/usr/lib -L$DEVROOT/usr/lib -L/opt/iphone-$SDKVER/lib -L/usr/local/iphone-$SDKVER/lib"
export CPP="$DEVROOT/usr/bin/cpp"
export CXXCPP="$DEVROOT/usr/bin/cpp"
export CC="$DEVROOT/usr/bin/gcc-4.2"
export CXX="$DEVROOT/usr/bin/g++-4.2"
export LD="$DEVROOT/usr/bin/ld"
export STRIP="$DEVROOT/usr/bin/strip"
if [ ! \( -d "$DEVROOT" \) ] ; then
echo "The iPhone SDK could not be found. Folder \"$DEVROOT\" does not exist."
exit 1
fi
if [ ! \( -d "$SDKROOT" \) ] ; then
echo "The iPhone SDK could not be found. Folder \"$SDKROOT\" does not exist."
exit 1
fi
./configure --prefix="$PREFIX" --build="i386-apple-darwin$BUILD_DARWIN_VER" --host="arm-apple-darwin9" --enable-static --disable-shared ac_cv_file__dev_zero=no ac_cv_func_setpgrp_void=yes $#
Also, I am invoking with "--enable-threads --disable-dso", not just "--disable-dso". This still doesn't work... it is failing with:
checking for PTHREAD_PROCESS_SHARED in pthread.h... yes
checking for pthread_mutexattr_setpshared... yes
checking for working PROCESS_SHARED locks... configure: error: in `/Users/michaelsafyan/Downloads/apr-1.3.8':
configure: error: cannot run test program while cross compiling
See `config.log' for more details.
However, this may be a problem with APR's specific tests. I am posting a followup question at the link.
Edit
I have provided a more complete solution at Cross-compiling the Apache Portable Runtime for the iPhone.
Thank you for your script. It did help me a lot. Though I had to make few changes so that the architecture of my built lib is arm and not i386.
First, I had to change the compiler:
# export CC="$DEVROOT/usr/bin/gcc-4.2"
export CC="$DEVROOT/usr/bin/arm-apple-darwin10-gcc-4.2.1"
Then I removed the -arch armv6 option, as this compiler doesn't understand it, from CFLAGS, CXXFLAGS, LDFLAGS
Updated the SDKVER and gcc version and it worked!