Thanks for the quick reply John,
Unfortunately, no luck, adding -DBIGENDIAN made no difference. I
already added a SunOSgcc option to the Makefile with the following entry
SunOSgcc:
make all SUF=mexsol CC="gcc -fPIC -O3 -funroll-loops
-DBIGENDIAN" MEX="mex -f ./mexopts.sh"
This enabled me to put a specific mexopts.sh file in the SPM2 directory
to control what mex was doing. I have attached this so you can see the
options I have included. It is basically a slimmed down version of
gccopts.sh for sol2 arch only, with a few extra libraries included in
the LDFLAGS and MLIBS variables. Another useful trick I found was
putting "-n" as an option in the MEX variable of the Makefile to see
what commands were being issued to the compiler.
I also had to edit this line in the Makefile to add "archive" otherwise
it wasn't trying to build spm_vol_utils.mexsol.a before compiling the
rest of the mex files.
all: verb.$(SUF) archive $(SPMMEX)
Many thanks for any further ideas,
Mark
John Ashburner wrote:
>Try changing the Makefile from:
>
>SunOS:
> make all SUF=mexsol CC="cc -xO5" MEX="mex
>COPTIMFLAGS=-xO5"
>
>to:
>
>SunOS:
> make all SUF=mexsol CC="cc -xO5 -DBIGENDIAN"\
> MEX="mex COPTIMFLAGS=-xO5 -DBIGENDIAN"
>SunOS.gcc:
># Assumes that gccopts.sh has been copied to the current directory
> make all SUF=mexsol CC="gcc -O3 -funroll-loops -DBIGENDIAN -fPIC"\
> MEX="mex COPTIMFLAGS='-O3 -funroll-loops -DBIGENDIAN'\
> -f gccopts.sh"
>
>and then compiling using
> make SunOS.gcc
>
>Best regards,
>-John
>
>On Monday 21 February 2005 10:40, Mark Daglish wrote:
>
>
>>Dear All,
>>
>>I have been following the discussions on optimizing and re-compiling the
>>SPM mex routines for faster running. I have run in a number of
>>problems, mainly related to my local configuration I suspect. In
>>particular, the linking stage is issuing many, many errors of the
>>following type:
>>
>>
>> mex -f ./mexopts.sh spm_sample_vol.c spm_vol_utils.mexsol.a
>> Text relocation remains referenced
>> against symbol offset in file
>> <unknown> 0x94
>>spm_vol_utils.mexsol.a(spm_vol_access.mexsol.o)
>> <unknown> 0xa0
>>spm_vol_utils.mexsol.a(spm_vol_access.mexsol.o)
>> <unknown> 0x5f0
>>spm_vol_utils.mexsol.a(spm_vol_access.mexsol.o)
>> <unknown> 0x5fc
>>spm_vol_utils.mexsol.a(spm_vol_access.mexsol.o)
>> <unknown> 0xbac
>>spm_vol_utils.mexsol.a(spm_vol_access.mexsol.o)
>>
>>The system is Matlab 7.01 running on SunSPARC with Solaris9 and gcc 3.3.2.
>>
>>If I do mex -n to see what commands are being issued to gcc I get the
>>following:
>>
>> bash-2.05# mex -n -f ./mexopts.sh spm_sample_vol.c
>>spm_vol_utils.mexsol.a
>> -> gcc -c -I/usr/local/matlab7p1/extern/include
>>-DMATLAB_MEX_FILE -fPIC -fexceptions -O3 -funroll-loops -mcpu=v9
>>-DNDEBUG spm_sample_vol.c
>>
>> -> gcc -c -I/usr/local/matlab7p1/extern/include
>>-DMATLAB_MEX_FILE -fPIC -fexceptions -O3 -funroll-loops -mcpu=v9
>>-DNDEBUG /usr/local/matlab7p1/extern/src/mexversion.c
>>
>> -> gcc -O -shared
>>-Wl,-M,/usr/local/matlab7p1/extern/lib/sol2/mexFunction.map,-R,/usr/local/l
>>ib,-R,/opt/sfw/gcc-3/lib -o spm_sample_vol.mexsol spm_sample_vol.o
>>mexversion.o
>>spm_vol_utils.mexsol.a -L/opt/sfw/gcc-3/lib -L/opt/sfw/gcc-3/lib/gcc-lib
>>-L/usr/local/matlab7p1/bin/sol2 -lg2c -lmx -lmex -lmat -lm -lm
>>
>>This includes all the suggested extra library paths I found by Google
>>searching. If anyone has any extra hints, please could they point me in
>>the right direction.
>>
>>Many thanks in advance,
>>
>>Mark
>>
>>
>
>
>
#
# gccopts.sh Shell script for configuring MEX-file creation script,
# mex. These options were tested with gcc 3.2.3.
#
# usage: Do not call this file directly; it is sourced by the
# mex shell script. Modify only if you don't like the
# defaults after running mex. No spaces are allowed
# around the '=' in the variable assignment.
#
# Note: only the gcc side of this script was tested.
# The FORTRAN variables are lifted directly from
# mexopts.sh; use that file for compiling FORTRAN
# MEX-files.
#
# SELECTION_TAGs occur in template option files and are used by MATLAB
# tools, such as mex and mbuild, to determine the purpose of the contents
# of an option file. These tags are only interpreted when preceded by '#'
# and followed by ':'.
#
#SELECTION_TAG_MEX_OPT: Template Options file for building gcc MEX-files
#
# Copyright 1984-2004 The MathWorks, Inc.
# $Revision: 1.43.4.6 $ $Date: 2004/04/25 21:30:52 $
#----------------------------------------------------------------------------
#
TMW_ROOT="$MATLAB"
MFLAGS=''
if [ "$ENTRYPOINT" = "mexLibrary" ]; then
MLIBS="-L$TMW_ROOT/bin/$Arch -lmx -lmex -lmat -lmwservices -lut -lm"
else
MLIBS="-L/opt/sfw/gcc-3/lib -L/opt/sfw/gcc-3/lib/gcc-lib -L$TMW_ROOT/bin/$Arch -lg2c -lmx -lmex -lmat -lm"
fi
#----------------------------------------------------------------------------
CC='gcc'
GCC_LIBDIR=`$CC -v 2>&1 | sed -n '1s/[^\/]*\(.*\/lib\).*/\1/p'`
EXTRA_LIBDIR="/opt/sfw/gcc-3/lib"
CFLAGS='-fPIC -fexceptions'
CLIBS="$MLIBS -lm"
COPTIMFLAGS='-O3 -funroll-loops -mcpu=v9 -DNDEBUG -DBIGENDIAN'
CDEBUGFLAGS='-g'
CXXDEBUGFLAGS='-g'
#
CXX='g++'
CXXFLAGS='-fPIC'
CXXLIBS="$MLIBS -lm"
CXXOPTIMFLAGS='-O -DNDEBUG'
#
LD="$COMPILER"
LDEXTENSION='.mexsol'
LDFLAGS="-shared -Wl,-M,$TMW_ROOT/extern/lib/$Arch/$MAPFILE,-R,$GCC_LIBDIR,-R,$EXTRA_LIBDIR"
LDOPTIMFLAGS='-O'
LDDEBUGFLAGS='-g'
#
POSTLINK_CMDS=':'
#----------------------------------------------------------------------------
|