LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   Error Message : collect2: ld returned 1 exit status (http://www.linuxquestions.org/questions/programming-9/error-message-collect2-ld-returned-1-exit-status-771629/)

biplabbijay 11-26-2009 12:35 AM

Error Message : collect2: ld returned 1 exit status
 
Hi, I am a trying to run a *.b file which should result an executable file.i have set my environment as follows:




#######################################################
export CPPMAKEOPT="-MM"
export CPPCOMPILE="g++ -c "
export CPPLINK="g++ "
export CPPCOMPILED="g++ -g -c "
export CPPLINKD="g++ -g "
export FORTRAN77="g77"
export ARCOMMAND="ar -rs"
export WCPPLIB=$HOME
export WCPPLIBOBJ=$WCPPLIB/wcpplib
export CERNLIB=/home/hecrrc/cern/pro/lib
export SPACKLIB="-L/home/hecrrc/cern/pro/lib -lpacklib_noshift -lnsl"
export CFLIBSERV="-lg2c"


export USE_HBOOK=1
export USE_SRANLUX=1
export USE_CPP_SRANLUX=1

#FORTRAN LIBRARY SETTINGS
#################################################################################################### ##

export FORTLIBARIES

if [ ! -z"USE_HBOOK" ]; then
echo "Will link with fortran CERN libraries"
export FORTLIBARIES="$SPACKLIB -L$CERNLIB -lkernlib -lmathlib $CFLIBSERV"
fi
#########
if [ ! -z"USE_CPP_SRANLUX" ]; then
echo "Will link with fortran CERN libraries"
export FORTLIBARIES="$WCPPLIBOBJ/ranluxint.o $SPACKLIB -L$CERNLIB -lkernlib -lmathlib $CFLIBSERV"
fi

#################################################################################################### ##

export CLHEP_INCL=$HOME/CLHEP/include

#CLHEP LIBRARY SETTINGS
#################################################################################################### ##

export CLHEPROOT="/home/hecrrc/CLHEP/lib"
export CLHEPLIBNAME="CLHEP"


if [ ! -z"$CLHEP_INCL" ]; then
export ICLHEP_INCL="-l$CLHEP_INCL"
export LCLHEPROOT="-L$CLHEPROOT -l$CLHEPLIBNAME"


else

export ICLHEP_INCL
export LCLHEPROOT
fi

#################################################################################################### ##
if [ ! -z "$LD_LIBRARY_PATH" ]; then
export LD_LIBRARY_PATH=/home/hecrrc/CLHEP/lib:$LD_LIBRARY_PATH
else
export LD_LIBRARY_PATH=home/hecrrc/CLHEP/lib
fi

export HEED_PREF="$HOME"
export HEEDDIR="$HEED_PREF/heed++"
export HEED_DATABASE="$HOME/heed++/database"

export PATH="$PATH:$WCPPLIBOBJ/install"

################################################################





the *.b file is as follows:




##############################################################
setenv FORTLIBARIES

if ( $?USE_HBOOK ) then
echo "Will link with fortran CERN libraries"
setenv FORTLIBARIES "$SPACKLIB -L$CERNLIB -lkernlib -lmathlib $CFLIBSERV"
endif
if ( $?USE_CPP_SRANLUX ) then
else
echo "Will link with fortran CERN libraries"
setenv FORTLIBARIES "$WCPPLIBOBJ/ranluxint.o $SPACKLIB -L$CERNLIB -lkernlib -lmathlib $CFLIBSERV"
endif
#

if ( $?CLHEP_INCL ) then
setenv ICLHEP_INCL -I$CLHEP_INCL
setenv LCLHEPROOT "-L$CLHEPROOT -l$CLHEPLIBNAME"
else
echo "variable CLHEP_INCL which point to CLHEP is not accessible"
echo "setting ICLHEP_INCL to empty"
setenv ICLHEP_INCL
setenv LCLHEPROOT
endif

if ( $?USE_HBOOK ) then
echo "HBOOK will be linked"
setenv USE_GRAPH USE_HBOOK
else if ( $?USE_OPEN_SCIENTIST ) then
echo "OPEN_SCIENTIST will be linked"
setenv USE_GRAPH USE_OPEN_SCIENTIST
else if ( $?USE_GHIST ) then
echo "GHIST will be linked"
setenv USE_GRAPH USE_GHIST
else if ( $?USE_HISTOG ) then
echo "Histog will be linked"
setenv USE_GRAPH USE_HISTOG
endif

if ( $?USE_CPP_SRANLUX ) then
echo "Will compile by case 1: with SRANLUX implemented through cpp"
setenv DUSE_CPP_SRANLUX "-DUSE_CPP_SRANLUX"
else
echo "Will compile by case 2: with SRANLUX implemented in fortran"
setenv DUSE_CPP_SRANLUX
endif

echo run compiler


$CPPLINKD -I$WCPPLIB -I$HEED_PREF \
-DFUNNAMESTACK -DDO_CHECKS -DALR_CHECK_BOUND \
-D$USE_GRAPH \
-DUSE_SRANLUX $DUSE_CPP_SRANLUX $ICLHEP_INCL -DFORT_UNDERSCORES_01 \
-o Spectr_ts.e Spectr_ts.c \
$HEEDDIR/PhotoAbsCSLib.o -L$HEEDDIR -lheed \
$WCPPLIBOBJ/histdef.o \
$WCPPLIBOBJ/math/linexi2.o \
$WCPPLIBOBJ/matrix/inverse.o \
-L$WCPPLIBOBJ -lutil -lstream -lsafetl -lgraph -lmath -lmatrix -lrandom -lmatter -lioniz -lparticle -lgparticle -lgeom \
$LCLHEPROOT
$FORTLIBARIES
############################################################




when i tried to run it using command "./*.b ", it shows an error;



collect2: ld returned 1 exit status
-L/home/hecrrc/cern/pro/lib: Command not found.



i am using suse linux version 11.0 and my login shell is bash shell.should i change all the "setenv" commands in *.b by "export" or is ther any other way to fix the problem without this changing ? Thanks in advance

paulsm4 11-26-2009 06:46 PM

Hi -

It looks like the real problem is that your "*.b" file is using C shell syntax.

Q: Do you have the C shell loaded on your system?
Quote:

whereis csh
Maybe the easiest approach is to a) install csh (if you don't already have it), and b) modify the first line of each of your "*.b" files to invoke the C shell, e.g.{code]
#!/bin/csh
...[/code]

Plan B is to change all of your *.b files to Bourne syntax (including, but not limited to, changing all of your "setenv" commands).

'Hope that helps .. PSM


All times are GMT -5. The time now is 04:16 AM.