conflict with fortran compiler and c++ libraries - c++

I really need your help, I have been trying to solve this problem for a few days now with no luck. I am compiling with gfortran (as the main program is in fortran) a program which calls for a library installed (lhapdf) in the standard directory, it is actually found but when linking with c++ libraries it appears to have a problem. As I have no familiarity with configure and makefiles I cant figure out what is wrong, this is my configure file:
#! /bin/sh
# configure script for FormCalc
# note: has nothing to do with GNU autoconf
# this file is part of FormCalc
# last modified 30 Aug 14 th
exec 2> ${LOGFILE:-/dev/null} 3>&1
eval ${LOGFILE:+set -x}
LC_ALL=C
export LC_ALL
test=test$$
trap "rm -fr $test*" 0 1 2 3 15
if (echo "test\c"; echo 1,2,3) | grep c > /dev/null ; then
if (echo -n test; echo 1,2,3) | grep n > /dev/null ; then
echo_n=
echo_c='
'
else
echo_n=-n
echo_c=
fi
else
echo_n=
echo_c='\c'
fi
findprog() {
echo $echo_n "looking for $1... $echo_c" 1>&3
shift
test -n "$CONF_TARGET" && for prog in "$#" ; do
full="`which \"$CONF_TARGET-$prog\" 2> /dev/null`"
test -x "$full" && {
echo $full 1>&3
echo $CONF_TARGET-$prog
return 0
}
done
for prog in "$#" ; do
full="`which \"$prog\" 2> /dev/null`"
test -x "$full" && {
echo $full 1>&3
echo $prog
return 0
}
done
echo "no $# in your path" 1>&3
return 1
}
findlib() {
echo $echo_n "looking for $1... $echo_c" 1>&3
file=$2
tag=$3
shift 3
for base in "$#" \
../$tag* \
../../$tag* \
../../../$tag* \
../../../../$tag* \
$HOME/$tag* \
/usr/local/$tag* \
/usr/$tag* \
/usr/local \
/usr
do
for path in \
"${CONF_LIBDIRSUFFIX:+$base/lib$CONF_LIBDIRSUFFIX}" \
"${CONF_LIBDIRSUFFIX:+$base/$CONF_DEFPREFIX/lib$CONF_LIBDIRSUFFIX}" \
"$base/lib" \
"$base/$CONF_DEFPREFIX/lib" \
${CONF_QUAD:+"$base/build-quad"} \
"$base/build" \
"$base/includects" \
"$base/libs" \
"$base/.libs" \
"$base/src" \
"$base/src/.libs" \
"$base"
do
test -f "$path/$file" && {
echo "$path" 1>&3
echo "$path"
return 0
}
done
done
echo "not found" 1>&3
return 1
}
getldflags() {
ldflags="$LDFLAGS"
while read line ; do
set -- `echo $line | tr ':,()' ' '`
case $1 in
*/collect2$CONF_EXE | */ld$CONF_EXE | ld$CONF_EXE) ;;
*) continue ;;
esac
while test $# -gt 1 ; do
shift
case $1 in
# *.o | -lc | -lgcc*)
*.o | -lc)
;;
-l* | -L* | *.a)
ldflags="$ldflags $1" ;;
-Bstatic | -Bdynamic | *.ld)
ldflags="$ldflags -Wl,$1" ;;
/*)
ldflags="$ldflags -L,$1" ;;
-rpath*)
ldflags="$ldflags -Wl,$1,$2"
shift ;;
-dynamic-linker)
shift ;;
esac
done
done
echo $ldflags
}
CONF_SRC=`dirname $0`
CONF_OS=`uname -s`
CONF_OSVER=`uname -r`
CONF_MACH=`uname -m`
CONF_DEFPREFIX="$CONF_MACH-$CONF_OS"
CONF_PREFIX="$CONF_DEFPREFIX"
CONF_TARGET=
CONF_STATIC=
CONF_STATIC_EXT=
CONF_QUAD=
CONF_DEBUG=
CONF_BITS=
# Mma 5.1's mcc needs -lpthread for static linking
CONF_MCLIBS="-lpthread"
CONF_ARCH="-march=native"
CONF_AS=
CONF_EXE=
case "$CONF_OS" in
CYG*) CONF_EXE=.exe ;;
Darwin) CONF_AS="-Wa,-q" ;;
esac
CONF_MAKEARGS=0
for arg in "$#" ; do
case "$arg" in
--prefix=*)
CONF_PREFIX=`expr "$arg" : ".*--prefix=\(.*\)"` ;;
--host=*)
CONF_TARGET=`expr "$arg" : ".*--host=\(.*\)"` ;;
--static)
CONF_STATIC="-static"
case "$CONF_OS" in
# Apple discourages static linking, see
# http://developer.apple.com/qa/qa2001/qa1118.html,
# so we make only libgcc static. For a static libg2c do:
# sudo chmod 000 /usr/local/lib/libg2c.dylib
Darwin | CYG*)
CONF_STATIC_EXT=$CONF_STATIC
CONF_STATIC= ;;
esac ;;
--quad)
CONF_QUAD=1 ;;
--debug)
CONF_DEBUG="-O0 -g" ;;
--32)
CONF_BITS=32 ;;
--64)
CONF_BITS=64 ;;
--generic)
CONF_ARCH=
CONF_AS= ;;
--make*)
CONF_MAKEARGS="`expr "$arg" : "--make=\(.*\)"`" ;;
--help)
cat << _EOF_ 1>&3
$0 configures FormCalc-generated Fortran code, i.e. determines
or guesses the compiler and flags and writes out a makefile.
$0 understands the following options:
--prefix=DIR use DIR as installation directory,
--host=HOST target host triplet, e.g. i386-pc-linux,
--static link the executables statically,
--quad compile with quadruple precision (gfortran 4.6+, ifort and xlf only),
--debug compile without optimization,
--32 force 32-bit compilation,
--64 force 64-bit compilation,
--generic do not specifically target the CPU configure runs on,
--make[=ARGS] immediately continue with "make ARGS" after configure.
_EOF_
exit 1 ;;
-*)
echo "Warning: $arg is not a valid option." 1>&3 ;;
*=*)
eval `echo $arg\" | sed 's/=/="/'` ;;
*)
echo "Warning: $arg is not a valid argument." 1>&3 ;;
esac
done
test "$CONF_OS" = Linux -a "$CONF_BITS" \!= 32 && CONF_LIBDIRSUFFIX=64
CONF_M=${CONF_BITS:+-m$CONF_BITS}
## look for some programs
CONF_MAKE=`findprog make $MAKE gmake Make make` || exit 1
CONF_CC=`findprog gcc $CC clang gcc` || exit 1
CONF_CXX=`findprog g++ $CXX clang++ g++` || exit 1
CONF_FC=`findprog fortran $FC ${CONF_QUAD:+ifort gfortran xlf} ifort pgf90 xlf gfortran g95 f90` || exit 1
CONF_AR=`findprog ar $AR ar`
CONF_RANLIB=`findprog ranlib $RANLIB ranlib`
CONF_NM=`findprog nm $NM nm`
CONF_DLLTOOL=`findprog dlltool $DLLTOOL dlltool`
CONF_DEF="-D"
case "`$CONF_FC --version -c 2>&1`" in
*G95*)
CONF_FFLAGS="$FFLAGS -O0 -g -ffixed-line-length-132 -freal-loops $CONF_M $CONF_STATIC ${CONF_DEBUG:+-Wall}" ;;
*GNU*)
CONF_FFLAGS="$FFLAGS ${CONF_DEBUG:--O3 -g} -lLHAPDF -ffixed-line-length-none $CONF_M $CONF_STATIC ${CONF_DEBUG:+-Wall}"
case "$CONF_FC" in
*gfortran*)
CONF_FFLAGS="$CONF_FFLAGS $CONF_ARCH $CONF_AS ${CONF_DEBUG:+-Wtabs -ffpe-trap=invalid,overflow,zero} -ff2c ${CONF_STATIC_EXT:+-static-libgfortran -static-libgcc} ${CONF_QUAD:+-fdefault-real-8}" ;;
esac ;;
*)
CONF_FFLAGS="${FFLAGS-default}"
test "$CONF_FFLAGS" = default && case "$CONF_FC$CONF_MACH" in
*pgf*)
CONF_FFLAGS="${CONF_DEBUG:--O3 -g} ${CONF_ARCH:+-Mvect=simd} ${CONF_DEBUG:+-Ktrap=fp} -Mextend -Minform=inform -g77libs ${CONF_STATIC:+-Bstatic} $CONF_M" ;;
*ifort*)
CONF_FFLAGS="${CONF_DEBUG:--O3 -g} $CONF_ARCH -extend_source -warn nouncalled -warn truncated_source -assume bscc $CONF_STATIC ${CONF_STATIC_EXT:+-static-intel} ${CONF_QUAD:+-r16 -DDBLE=QEXT -DDIMAG=QIMAG -DDCONJG=QCONJG -DDCMPLX=QCMPLX} $CONF_M" ;;
*alpha)
CONF_FFLAGS="${CONF_DEBUG:--O3 -g3} ${CONF_DEBUG:+-fpe0} -extend_source -warn truncated_source ${CONF_STATIC:+-non_shared}" ;;
*sun* | *sparc*)
CONF_FFLAGS="${CONF_DEBUG:--O3 -g} ${CONF_DEBUG:+-ftrap=common} -e ${CONF_STATIC:+-Bstatic}" ;;
*hp*)
CONF_FFLAGS="${CONF_DEBUG:--O2 -g} ${CONF_DEBUG:++FPVZO} +es +U77 ${CONF_STATIC:+-Wl,-noshared}" ;;
*xlf*)
CONF_FFLAGS="${CONF_DEBUG:--O2 -g} ${CONF_DEBUG:+-qflttrap=enable:invalid:overflow:zerodivide} -qfixed=132 -qmaxmem=-1 -qextname ${CONF_QUAD:+-qautodbl=dbl}"
CONF_DEF="-WF,-D" ;;
*)
CONF_FFLAGS="${CONF_DEBUG:--O -g}" ;;
esac ;;
esac
## find the Fortran libraries
echo $echo_n "extracting the Fortran libraries... $echo_c" 1>&3
rm -fr $test*
cat > $test.f << _EOF_
program dontpanic
print *, "Hi"
end
_EOF_
eval ${LOGFILE:+cat $test.f 1>&2}
CONF_LDFLAGS=`$CONF_FC $CONF_FFLAGS -v -o -lstdc++ $test $test.f 2>&1 | getldflags`
CONF_INCPATH="$INCPATH"
CONF_STDLIBS="$STDLIBS"
case "$CONF_OS$CONF_OSVER" in
Darwin10*) CONF_STDLIBS="${CONF_STDLIBS:+$CONF_STDLIBS }-lSystemStubs" ;;
esac
echo $CONF_LDFLAGS 1>&3
test -z "$CONF_BITS" && case "$CONF_MACH" in
*86*) CONF_BITS=32
case "`file $test`" in
*x86?64*) CONF_BITS=64 ;;
esac
CONF_M="-m$CONF_BITS" ;;
esac
CONF_CFLAGS="${CFLAGS-${CONF_DEBUG:--O3 -g } $CONF_ARCH -std=gnu99 -fomit-frame-pointer -ffast-math} $CONF_M $CONF_STATIC ${CONF_STATIC_EXT:+-static-libgcc}"
CONF_CXXFLAGS="$CXXFLAGS $CONF_M $CONF_STATIC ${CONF_STATIC_EXT:+-static-libstdc++ -static-libgcc}"
## does Fortran need externals for U77 routines?
echo $echo_n "does $CONF_FC need externals for U77 routines... $echo_c" 1>&3
rm -fr $test*
cat > $test.f << _EOF_
program test
implicit none
print *, iargc(), len_trim("Hi")
end
_EOF_
eval ${LOGFILE:+cat $test.f 1>&2}
if $CONF_FC $CONF_FFLAGS -c $test.f 1>&2 ; then
echo "no" 1>&3
CONF_U77EXT=0
else
echo "yes" 1>&3
CONF_U77EXT=1
fi
## does Fortran append underscores to symbols?
echo $echo_n "does $CONF_FC append underscores... $echo_c" 1>&3
rm -fr $test*
echo "void uscore$$_() {}" > $test-c.c
eval ${LOGFILE:+cat $test-c.c 1>&2}
cat > $test.f << _EOF_
program test_uscore
call uscore$$
end
_EOF_
eval ${LOGFILE:+cat $test.f 1>&2}
$CONF_CC $CONF_CFLAGS -c $test-c.c 1>&2
if $CONF_FC $CONF_FFLAGS -o $test $test.f $test-c.o 1>&2 ; then
echo "yes" 1>&3
else
echo "no" 1>&3
CONF_CFLAGS="$CONF_CFLAGS -DNOUNDERSCORE"
fi
## find max SIMD vector length supported by hardware
echo $echo_n "extracting SIMD capabilities of $CONF_FC... $echo_c" 1>&3
cat simd.h - > $test.F << _EOF_ 2> /dev/null
#ifdef GENERIC
#define SIMD2 0
#define PROP "none"
#elif defined __AVX__
#define SIMD2 2
#define PROP "AVX"
#elif defined __SSE3__
#define SIMD2 1
#define PROP "SSE3"
#else
#define SIMD2 0
#define PROP "none"
#endif
program test
print *, PROP
#if defined SIMD && SIMD == SIMD2
#else
print *, SIMD2
#endif
end
_EOF_
eval ${LOGFILE:+cat $test.F 1>&2}
$CONF_FC $CONF_FFLAGS ${CONF_ARCH:-${CONF_DEF}GENERIC} -o $test $test.F 1>&2
set -- `./$test 2>&1`
echo $1 1>&3
case $2 in
0|1|2) cat > simd.h << _EOF_
#if 0
vectorization ability of $CONF_FC on $HOSTNAME
determined by $0 on `date`
#endif
#define SIMD $2
_EOF_
;;
esac
# check for the necessary libraries
CONF_LIBS=
LTLIB=libooptools${CONF_QUAD:+-quad}.a
CONF_LT="`findlib LoopTools $LTLIB LoopTools $LT`" && {
CONF_INCPATH="${CONF_INCPATH:+$CONF_INCPATH:}\$(LT)/../include:\$(LT)"
CONF_LIBS="\$(LT)/$LTLIB"
}
CONF_NINJA="`findlib Ninja libninja.a ninja $NINJA`" && {
echo $echo_n "determining C++ library needed by Ninja... $echo_c" 1>&3
cat > $test.f << _EOF_
program test
call ninjaformcalc
end
_EOF_
eval ${LOGFILE:+cat $test.f 1>&2}
LIBCPP=-lstdc++
$CONF_FC $CONF_FFLAGS -o $test $test.f $CONF_NINJA/libninja.a $CONF_LT/$LTLIB \
$LIBCPP $CONF_STDLIBS 1>&2 || LIBCPP=-lc++
echo "$LIBCPP" 1>&3
CONF_LIBS="\$(NINJA)/libninja.a $LIBCPP${CONF_LIBS:+ $CONF_LIBS}"
}
CONF_SAMURAI="`findlib Samurai libsamurai.a samurai $SAMURAI`" && {
CONF_INCPATH="${CONF_INCPATH:+$CONF_INCPATH:}\$(SAMURAI)/../samurai:\$(SAMURAI)"
CONF_LIBS="\$(SAMURAI)/libsamurai.a \$(SAMURAI)/libqcdloop.a `\$(SAMURAI)/libavh_olo.a${CONF_LIBS:+ $CONF_LIBS}"
}
CONF_CT="`findlib CutTools libcts.a Cuttools $CT`" && {
CONF_INCPATH="${CONF_INCPATH:+$CONF_INCPATH:}\$(CT)"
CONF_LIBS="\$(CT)/libcts.a${CONF_LIBS:+ $CONF_LIBS}"
}
CONF_FH="`findlib FeynHiggs libFH.a FeynHiggs $FH`" && {
CONF_INCPATH="${CONF_INCPATH:+$CONF_INCPATH:}\$(FH)/../include:\$(FH)"
CONF_LIBS="\$(FH)/libFH.a${CONF_LIBS:+ $CONF_LIBS}"
}
CONF_LHAPDF="`findlib LHAPDF libLHAPDF.a lhapdf $LHAPDF`" &&
CONF_LIBS="\$(LHAPDF)/libLHAPDF.a${CONF_LIBS:+ $CONF_LIBS}"
echo "creating makefile" 1>&3
cat - `dirname $0`/makefile.in > makefile << _EOF_
# --- variables defined by configure ---
SRC = $CONF_SRC
PREFIX = $CONF_PREFIX
LIBDIRSUFFIX = $CONF_LIBDIRSUFFIX
EXE = $CONF_EXE
DEF = $CONF_DEF
LT = $CONF_LT
NINJA = $CONF_NINJA
SAMURAI = $CONF_SAMURAI
CT = $CONF_CT
FH = $CONF_FH
LHAPDF = $CONF_LHAPDF
INCPATH = $CONF_INCPATH
STDLIBS = $CONF_LIBS $CONF_STDLIBS
LDFLAGS = $CONF_LDFLAGS
FC = $CONF_FC
FFLAGS = $CONF_FFLAGS \$(DEF)U77EXT=$CONF_U77EXT ${CONF_DEBUG:+\$(DEF)DEBUG}
CC = $CONF_CC
CFLAGS = $CONF_CFLAGS
CXX = $CONF_CXX
CXXFLAGS = $CONF_CXXFLAGS
MCFLAGS = ${CONF_STATIC:+-st} ${CONF_STATIC_EXT:+-st} ${CONF_BITS:+-b$CONF_BITS}
MCLIBS = $CONF_MCLIBS
# --- end defs by configure ---
_EOF_
if test "$CONF_MAKEARGS" = 0 ; then
cat << _EOF_ 1>&3
now you must run $CONF_MAKE
_EOF_
else
$CONF_MAKE $CONF_MAKEARGS 1>&3 2>&3
fi
exit 0
After running make these are the errors:
gfortran -O3 -g -lLHAPDF -ffixed-line-length-none -march=native -ff2c -DU77EXT=0 -I. -I./F -I. -I. -I../../LoopTools/x86_64-Linux/lib64/../include -I../../LoopTools/x86_64-Linux/lib64 -I/usr/local/lib64/../include -I/usr/local/lib64 -Irenconst/ -DPREFIX= -o run run.F renconst.a squaredme.a util.a /usr/local/lib/libLHAPDF.a /usr/local/lib64/libFH.a ../../LoopTools/x86_64-Linux/lib64/libooptools.a
/usr/local/lib/libLHAPDF.a(getdatapath.o): In function `getprefixpath_':
/home/vannia/Documents/lhapdf-5.9.1/src/getdatapath.cc:28: undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)'
/usr/local/lib/libLHAPDF.a(getdatapath.o): In function `operator+<char, std::char_traits<char>, std::allocator<char> >':
/usr/include/c++/4.8/bits/basic_string.h:2405: undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::string const&)'
/usr/local/lib/libLHAPDF.a(getdatapath.o): In function `std::string::append(char const*)':
/usr/include/c++/4.8/bits/basic_string.h:1009: undefined reference to `std::string::append(char const*, unsigned long)'
/usr/local/lib/libLHAPDF.a(getdatapath.o): In function `std::string::_Rep::_M_dispose(std::allocator<char> const&)':
/usr/include/c++/4.8/bits/basic_string.h:240: undefined reference to `std::string::_Rep::_S_empty_rep_storage'
/usr/local/lib/libLHAPDF.a(getdatapath.o): In function `std::string::assign(char const*)':
/usr/include/c++/4.8/bits/basic_string.h:1131: undefined reference to `std::string::assign(char const*, unsigned long)'
/usr/local/lib/libLHAPDF.a(getdatapath.o): In function `~basic_string':
/usr/include/c++/4.8/bits/basic_string.h:539: undefined reference to `std::string::_Rep::_M_dispose(std::allocator<char> const&)'
/usr/include/c++/4.8/bits/basic_string.h:539: undefined reference to `std::string::_Rep::_M_dispose(std::allocator<char> const&)'
/usr/local/lib/libLHAPDF.a(getdatapath.o): In function `std::string::_Rep::_M_dispose(std::allocator<char> const&)':
/usr/include/c++/4.8/bits/basic_string.h:249: undefined reference to `std::string::_Rep::_M_destroy(std::allocator<char> const&)'
/usr/include/c++/4.8/bits/basic_string.h:249: undefined reference to `std::string::_Rep::_M_destroy(std::allocator<char> const&)'
/usr/local/lib/libLHAPDF.a(getdatapath.o): In function `getindexpath_':
/home/vannia/Documents/lhapdf-5.9.1/src/getdatapath.cc:55: undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)'
/home/vannia/Documents/lhapdf-5.9.1/src/getdatapath.cc:55: undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)'
/usr/local/lib/libLHAPDF.a(getdatapath.o): In function `std::string::append(char const*)':
/usr/include/c++/4.8/bits/basic_string.h:1009: undefined reference to `std::string::append(char const*, unsigned long)'
/usr/include/c++/4.8/bits/basic_string.h:1009: undefined reference to `std::string::append(char const*, unsigned long)'
/usr/local/lib/libLHAPDF.a(getdatapath.o): In function `std::string::_Rep::_M_dispose(std::allocator<char> const&)':
/usr/include/c++/4.8/bits/basic_string.h:240: undefined reference to `std::string::_Rep::_S_empty_rep_storage'
/usr/local/lib/libLHAPDF.a(getdatapath.o): In function `~basic_string':
/usr/include/c++/4.8/bits/basic_string.h:539: undefined reference to `std::string::_Rep::_M_dispose(std::allocator<char> const&)'
/usr/local/lib/libLHAPDF.a(getdatapath.o): In function `std::string::_Rep::_M_dispose(std::allocator<char> const&)':
/usr/include/c++/4.8/bits/basic_string.h:249: undefined reference to `std::string::_Rep::_M_destroy(std::allocator<char> const&)'
/usr/include/c++/4.8/bits/basic_string.h:249: undefined reference to `std::string::_Rep::_M_destroy(std::allocator<char> const&)'
/usr/local/lib/libLHAPDF.a(getdatapath.o): In function `~basic_string':
/usr/include/c++/4.8/bits/basic_string.h:539: undefined reference to `std::string::_Rep::_M_dispose(std::allocator<char> const&)'
/usr/local/lib/libLHAPDF.a(getdatapath.o): In function `getdatapath_':
/home/vannia/Documents/lhapdf-5.9.1/src/getdatapath.cc:77: undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)'
/usr/local/lib/libLHAPDF.a(getdatapath.o): In function `operator+<char, std::char_traits<char>, std::allocator<char> >':
/usr/include/c++/4.8/bits/basic_string.h:2405: undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::string const&)'
/usr/local/lib/libLHAPDF.a(getdatapath.o): In function `std::string::append(char const*)':
/usr/include/c++/4.8/bits/basic_string.h:1009: undefined reference to `std::string::append(char const*, unsigned long)'
/usr/local/lib/libLHAPDF.a(getdatapath.o): In function `operator+<char, std::char_traits<char>, std::allocator<char> >':
/usr/include/c++/4.8/bits/basic_string.h:2405: undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::string const&)'
/usr/local/lib/libLHAPDF.a(getdatapath.o): In function `std::string::append(char const*)':
/usr/include/c++/4.8/bits/basic_string.h:1009: undefined reference to `std::string::append(char const*, unsigned long)'
/usr/local/lib/libLHAPDF.a(getdatapath.o): In function `std::string::_Rep::_M_dispose(std::allocator<char> const&)':
/usr/include/c++/4.8/bits/basic_string.h:240: undefined reference to `std::string::_Rep::_S_empty_rep_storage'
/usr/local/lib/libLHAPDF.a(getdatapath.o): In function `getdatapath_':
/home/vannia/Documents/lhapdf-5.9.1/src/getdatapath.cc:82: undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)'
/usr/local/lib/libLHAPDF.a(getdatapath.o): In function `operator+<char, std::char_traits<char>, std::allocator<char> >':
/usr/include/c++/4.8/bits/basic_string.h:2405: undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::string const&)'
/usr/local/lib/libLHAPDF.a(getdatapath.o): In function `std::string::append(char const*)':
/usr/include/c++/4.8/bits/basic_string.h:1009: undefined reference to `std::string::append(char const*, unsigned long)'
/usr/local/lib/libLHAPDF.a(getdatapath.o): In function `std::string::operator=(std::string const&)':
/usr/include/c++/4.8/bits/basic_string.h:547: undefined reference to `std::string::assign(std::string const&)'
/usr/local/lib/libLHAPDF.a(getdatapath.o): In function `std::string::_Rep::_M_dispose(std::allocator<char> const&)':
/usr/include/c++/4.8/bits/basic_string.h:240: undefined reference to `std::string::_Rep::_S_empty_rep_storage'
/usr/include/c++/4.8/bits/basic_string.h:249: undefined reference to `std::string::_Rep::_M_destroy(std::allocator<char> const&)'
/usr/local/lib/libLHAPDF.a(getdatapath.o): In function `~basic_string':
/usr/include/c++/4.8/bits/basic_string.h:539: undefined reference to `std::string::_Rep::_M_dispose(std::allocator<char> const&)'
/usr/include/c++/4.8/bits/basic_string.h:539: undefined reference to `std::string::_Rep::_M_dispose(std::allocator<char> const&)'
/usr/include/c++/4.8/bits/basic_string.h:539: undefined reference to `std::string::_Rep::_M_dispose(std::allocator<char> const&)'
/usr/include/c++/4.8/bits/basic_string.h:539: undefined reference to `std::string::_Rep::_M_dispose(std::allocator<char> const&)'
/usr/include/c++/4.8/bits/basic_string.h:539: undefined reference to `std::string::_Rep::_M_dispose(std::allocator<char> const&)'
/usr/local/lib/libLHAPDF.a(getdatapath.o): In function `std::string::_Rep::_M_dispose(std::allocator<char> const&)':
/usr/include/c++/4.8/bits/basic_string.h:249: undefined reference to `std::string::_Rep::_M_destroy(std::allocator<char> const&)'
/usr/local/lib/libLHAPDF.a(getdatapath.o): In function `operator+<char, std::char_traits<char>, std::allocator<char> >':
/usr/include/c++/4.8/bits/basic_string.h:539: undefined reference to `std::string::_Rep::_M_dispose(std::allocator<char> const&)'
/usr/include/c++/4.8/bits/basic_string.h:539: undefined reference to `std::string::_Rep::_M_dispose(std::allocator<char> const&)'
/usr/local/lib/libLHAPDF.a(getdatapath.o): In function `std::string::_Rep::_M_dispose(std::allocator<char> const&)':
/usr/include/c++/4.8/bits/basic_string.h:249: undefined reference to `std::string::_Rep::_M_destroy(std::allocator<char> const&)'
/usr/include/c++/4.8/bits/basic_string.h:249: undefined reference to `std::string::_Rep::_M_destroy(std::allocator<char> const&)'
/usr/include/c++/4.8/bits/basic_string.h:249: undefined reference to `std::string::_Rep::_M_destroy(std::allocator<char> const&)'
/usr/local/lib/libLHAPDF.a(getdatapath.o): In function `__static_initialization_and_destruction_0':
/usr/include/c++/4.8/iostream:74: undefined reference to `std::ios_base::Init::Init()'
/usr/include/c++/4.8/iostream:74: undefined reference to `std::ios_base::Init::~Init()'
/usr/local/lib/libLHAPDF.a(getdatapath.o):(.data.DW.ref.__gxx_personality_v0[DW.ref.__gxx_personality_v0]+0x0): undefined reference to `__gxx_personality_v0'
/usr/local/lib/libLHAPDF.a(version.o): In function `getlhapdfversion_':
/home/vannia/Documents/lhapdf-5.9.1/src/version.cc:18: undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)'
/usr/local/lib/libLHAPDF.a(version.o): In function `std::string::_Rep::_M_dispose(std::allocator<char> const&)':
/usr/include/c++/4.8/bits/basic_string.h:240: undefined reference to `std::string::_Rep::_S_empty_rep_storage'
/usr/include/c++/4.8/bits/basic_string.h:249: undefined reference to `std::string::_Rep::_M_destroy(std::allocator<char> const&)'
/usr/local/lib/libLHAPDF.a(commoninit.o): In function `commoninit_':
commoninit.f:(.text+0x33): relocation truncated to fit: R_X86_64_PC32 against symbol `lhapdf_' defined in COMMON section in /usr/local/lib/libLHAPDF.a(commoninit.o)
commoninit.f:(.text+0x1d1): relocation truncated to fit: R_X86_64_PC32 against symbol `lhaglsta_' defined in COMMON section in /usr/local/lib/libLHAPDF.a(commoninit.o)
../../LoopTools/x86_64-Linux/lib64/libooptools.a(Aget.o): In function `ljacoeff_':
/home/vannia/.Mathematica/Applications/HighEnergyPhysics/LoopTools-2.9/build/Aget.F:110:(.text+0x1e): relocation truncated to fit: R_X86_64_PC32 against symbol `ltvars_' defined in COMMON section in ../../LoopTools/x86_64-Linux/lib64/libooptools.a(Aget.o)
/home/vannia/.Mathematica/Applications/HighEnergyPhysics/LoopTools-2.9/build/Aget.F:112:(.text+0x27): relocation truncated to fit: R_X86_64_PC32 against symbol `ltvars_' defined in COMMON section in ../../LoopTools/x86_64-Linux/lib64/libooptools.a(Aget.o)
/home/vannia/.Mathematica/Applications/HighEnergyPhysics/LoopTools-2.9/build/Aget.F:112:(.text+0x30): relocation truncated to fit: R_X86_64_PC32 against symbol `ltvars_' defined in COMMON section in ../../LoopTools/x86_64-Linux/lib64/libooptools.a(Aget.o)
/home/vannia/.Mathematica/Applications/HighEnergyPhysics/LoopTools-2.9/build/Aget.F:114:(.text+0x3c): relocation truncated to fit: R_X86_64_PC32 against symbol `ltvars_' defined in COMMON section in ../../LoopTools/x86_64-Linux/lib64/libooptools.a(Aget.o)
/home/vannia/.Mathematica/Applications/HighEnergyPhysics/LoopTools-2.9/build/Aget.F:114:(.text+0x45): relocation truncated to fit: R_X86_64_PC32 against symbol `ltvars_' defined in COMMON section in ../../LoopTools/x86_64-Linux/lib64/libooptools.a(Aget.o)
/home/vannia/.Mathematica/Applications/HighEnergyPhysics/LoopTools-2.9/build/Aget.F:114:(.text+0x4d): relocation truncated to fit: R_X86_64_PC32 against symbol `ltvars_' defined in COMMON section in ../../LoopTools/x86_64-Linux/lib64/libooptools.a(Aget.o)
/home/vannia/.Mathematica/Applications/HighEnergyPhysics/LoopTools-2.9/build/Aget.F:120:(.text+0x84): relocation truncated to fit: R_X86_64_PC32 against symbol `ltvars_' defined in COMMON section in ../../LoopTools/x86_64-Linux/lib64/libooptools.a(Aget.o)
/home/vannia/.Mathematica/Applications/HighEnergyPhysics/LoopTools-2.9/build/Aget.F:125:(.text+0xd3): relocation truncated to fit: R_X86_64_PC32 against symbol `ltregul_' defined in COMMON section in ../../LoopTools/x86_64-Linux/lib64/libooptools.a(Aget.o)
/home/vannia/.Mathematica/Applications/HighEnergyPhysics/LoopTools-2.9/build/Aget.F:125:(.text+0xf0): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
make: *** [run] Error 1

put it in the makefile in the FFLAGS
FC = gfortran
FFLAGS = -O3 -g -ffixed-line-length-none -march=native -ff2c $(DEF)U77EXT=0 -lstdc++

Related

"Configure: Error: Could Not Find a Working Compiler, See config.log For Details"

I have to handle very long numbers in C++. I saw online that the easiest way to do it is install the GMP library, but I have a problem.
When i execute the msys.bat file inside the compiler folder and when i execute the command ./configure --prefix=/d/Libraries_For_C_and_C++/GMP --enable-cxx it gives me an error
configure: error: could not find a working compiler, see config.log for details
I have tried to install the compiler several times but the error message is the same.
The config.log file is:
> This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake.
>
> It was created by GNU MP configure 6.1.2, which was generated by GNU
> Autoconf 2.69. Invocation command line was
>
> $ ./configure --prefix=/d/Libraries_For_C_and_C++/GMP --enable-cxx
>
> ## --------- ##
> ## Platform. ##
> ## --------- ##
>
> hostname = DESKTOP-N92E9KJ uname -m = i686 uname -r = 1.0.19(0.48/3/2)
> uname -s = MINGW32_NT-6.2 uname -v = 2016-07-13 17:45
>
> /usr/bin/uname -p = unknown /bin/uname -X = unknown
>
> /bin/arch = unknown /usr/bin/arch -k = unknown
> /usr/convex/getsysinfo = unknown /usr/bin/hostinfo = unknown
> /bin/machine = unknown /usr/bin/oslevel = unknown
> /bin/universe = unknown
>
> PATH: . PATH: /usr/local/bin PATH: /mingw/bin PATH: /bin PATH:
> /c/Program Files (x86)/Common Files/Oracle/Java/javapath PATH:
> /c/Windows/system32 PATH: /c/Windows PATH: /c/Windows/System32/Wbem
> PATH: /c/Windows/System32/WindowsPowerShell/v1.0/ PATH:
> /c/Windows/System32/OpenSSH/ PATH: /c/Program Files (x86)/NVIDIA
> Corporation/PhysX/Common PATH: /c/Users/Novati
> Giovanni/AppData/Local/Microsoft/WindowsApps PATH: .
>
>
> ## ----------- ##
> ## Core tests. ##
> ## ----------- ##
>
> configure:3055: checking build system type configure:3069: result:
> i686-pc-mingw32 configure:3089: checking host system type
> configure:3102: result: i686-pc-mingw32 configure:3139: checking for a
> BSD-compatible install configure:3207: result: /bin/install -c
> configure:3218: checking whether build environment is sane
> configure:3273: result: yes configure:3424: checking for a thread-safe
> mkdir -p configure:3463: result: /bin/mkdir -p configure:3470:
> checking for gawk configure:3486: found /bin/gawk configure:3497:
> result: gawk configure:3508: checking whether make sets $(MAKE)
> configure:3530: result: yes configure:3559: checking whether make
> supports nested variables configure:3576: result: yes configure:3705:
> checking whether to enable maintainer-specific portions of Makefiles
> configure:3714: result: no User: ABI= CC= CFLAGS=(unset)
> CPPFLAGS=(unset) MPN_PATH= GMP: abilist=32 cclist=gcc icc cc
> configure:5801: gcc 2>&1 | grep xlc >/dev/null configure:5804: $? = 1
> configure:5858: checking compiler gcc -m32 -O2 -pedantic
> -fomit-frame-pointer Test compile: configure:5872: gcc -m32 -O2 -pedantic -fomit-frame-pointer conftest.c >&5 ./configure: line 5873: gcc: command not found configure:5875: $? = 127 failed program was:
>
> int main () { return 0; } configure:6962: result: no configure:5858:
> checking compiler gcc -O2 -pedantic -fomit-frame-pointer Test
> compile: configure:5872: gcc -O2 -pedantic -fomit-frame-pointer
> conftest.c >&5 ./configure: line 5873: gcc: command not found
> configure:5875: $? = 127 failed program was:
>
> int main () { return 0; } configure:6962: result: no configure:5779:
> icc -c conftest.c >&5 ./configure: line 5780: icc: command not found
> configure:5782: $? = 127 configure:5801: icc 2>&1 | grep xlc
> >/dev/null configure:5804: $? = 1 configure:5858: checking compiler icc -no-gcc Test compile: configure:5872: icc -no-gcc conftest.c
> >&5 ./configure: line 5873: icc: command not found configure:5875: $? = 127 failed program was:
>
> int main () { return 0; } configure:6962: result: no configure:5779:
> cc -c conftest.c >&5 ./configure: line 5780: cc: command not found
> configure:5782: $? = 127 configure:5801: cc 2>&1 | grep xlc >/dev/null
> configure:5804: $? = 1 configure:5858: checking compiler cc -O Test
> compile: configure:5872: cc -O conftest.c >&5 ./configure: line
> 5873: cc: command not found configure:5875: $? = 127 failed program
> was:
>
> int main () { return 0; } configure:6962: result: no configure:7200:
> error: could not find a working compiler, see config.log for details
>
> ## ---------------- ##
> ## Cache variables. ##
> ## ---------------- ##
>
> ac_cv_build=i686-pc-mingw32 ac_cv_env_ABI_set= ac_cv_env_ABI_value=
> ac_cv_env_CCC_set= ac_cv_env_CCC_value= ac_cv_env_CC_FOR_BUILD_set=
> ac_cv_env_CC_FOR_BUILD_value= ac_cv_env_CC_set= ac_cv_env_CC_value=
> ac_cv_env_CFLAGS_set= ac_cv_env_CFLAGS_value= ac_cv_env_CPPFLAGS_set=
> ac_cv_env_CPPFLAGS_value= ac_cv_env_CPP_FOR_BUILD_set=
> ac_cv_env_CPP_FOR_BUILD_value= ac_cv_env_CPP_set= ac_cv_env_CPP_value=
> ac_cv_env_CXXCPP_set= ac_cv_env_CXXCPP_value= ac_cv_env_CXXFLAGS_set=
> ac_cv_env_CXXFLAGS_value= ac_cv_env_CXX_set= ac_cv_env_CXX_value=
> ac_cv_env_LDFLAGS_set= ac_cv_env_LDFLAGS_value= ac_cv_env_LIBS_set=
> ac_cv_env_LIBS_value= ac_cv_env_LT_SYS_LIBRARY_PATH_set=
> ac_cv_env_LT_SYS_LIBRARY_PATH_value= ac_cv_env_M4_set=
> ac_cv_env_M4_value= ac_cv_env_YACC_set= ac_cv_env_YACC_value=
> ac_cv_env_YFLAGS_set= ac_cv_env_YFLAGS_value=
> ac_cv_env_build_alias_set= ac_cv_env_build_alias_value=
> ac_cv_env_host_alias_set= ac_cv_env_host_alias_value=
> ac_cv_env_target_alias_set= ac_cv_env_target_alias_value=
> ac_cv_host=i686-pc-mingw32 ac_cv_path_install='/bin/install -c'
> ac_cv_path_mkdir=/bin/mkdir ac_cv_prog_AWK=gawk
> ac_cv_prog_make_make_set=yes am_cv_make_support_nested_variables=yes
>
> ## ----------------- ##
> ## Output variables. ##
> ## ----------------- ##
>
> ABI='' ACLOCAL='${SHELL} /d/Libraries_For_C_and_C++/gmp-6.1.2/missing
> aclocal-1.15' AMTAR='$${TAR-tar}' AM_BACKSLASH='\'
> AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)' AM_DEFAULT_VERBOSITY='1'
> AM_V='$(V)' AR='' AS='' ASMFLAGS='' AUTOCONF='${SHELL}
> /d/Libraries_For_C_and_C++/gmp-6.1.2/missing autoconf'
> AUTOHEADER='${SHELL} /d/Libraries_For_C_and_C++/gmp-6.1.2/missing
> autoheader' AUTOMAKE='${SHELL}
> /d/Libraries_For_C_and_C++/gmp-6.1.2/missing automake-1.15' AWK='gawk'
> CALLING_CONVENTIONS_OBJS='x86call.lo x86check$U.lo' CC='' CCAS=''
> CC_FOR_BUILD='' CFLAGS='' CPP='' CPPFLAGS='' CPP_FOR_BUILD='' CXX=''
> CXXCPP='' CXXFLAGS='' CYGPATH_W='echo' DEFN_LONG_LONG_LIMB='' DEFS=''
> DLLTOOL='' DSYMUTIL='' DUMPBIN='' ECHO_C='' ECHO_N='-n' ECHO_T=''
> EGREP='' ENABLE_STATIC_FALSE='' ENABLE_STATIC_TRUE='' EXEEXT=''
> EXEEXT_FOR_BUILD='' FGREP='' GMP_LDFLAGS='' GMP_LIMB_BITS=''
> GMP_NAIL_BITS='0' GREP='' HAVE_CLOCK_01='' HAVE_CPUTIME_01=''
> HAVE_GETRUSAGE_01='' HAVE_GETTIMEOFDAY_01=''
> HAVE_HOST_CPU_FAMILY_power='0' HAVE_HOST_CPU_FAMILY_powerpc='0'
> HAVE_SIGACTION_01='' HAVE_SIGALTSTACK_01='' HAVE_SIGSTACK_01=''
> HAVE_STACK_T_01='' HAVE_SYS_RESOURCE_H_01='' INSTALL_DATA='${INSTALL}
> -m 644' INSTALL_PROGRAM='${INSTALL}' INSTALL_SCRIPT='${INSTALL}' INSTALL_STRIP_PROGRAM='$(install_sh) -c -s' LD='' LDFLAGS='' LEX=''
> LEXLIB='' LEX_OUTPUT_ROOT='' LIBCURSES='' LIBGMPXX_LDFLAGS=''
> LIBGMP_DLL='' LIBGMP_LDFLAGS='' LIBM='' LIBM_FOR_BUILD='' LIBOBJS=''
> LIBREADLINE='' LIBS='' LIBTOOL='' LIPO='' LN_S='' LTLIBOBJS=''
> LT_SYS_LIBRARY_PATH='' M4='' MAINT='#' MAINTAINER_MODE_FALSE=''
> MAINTAINER_MODE_TRUE='#' MAKEINFO='${SHELL}
> /d/Libraries_For_C_and_C++/gmp-6.1.2/missing makeinfo'
> MANIFEST_TOOL='' MKDIR_P='/bin/mkdir -p' NM='' NMEDIT='' OBJDUMP=''
> OBJEXT='' OTOOL64='' OTOOL='' PACKAGE='gmp'
> PACKAGE_BUGREPORT='gmp-bugs#gmplib.org, see
> https://gmplib.org/manual/Reporting-Bugs.html' PACKAGE_NAME='GNU MP'
> PACKAGE_STRING='GNU MP 6.1.2' PACKAGE_TARNAME='gmp'
> PACKAGE_URL='http://www.gnu.org/software/gmp/' PACKAGE_VERSION='6.1.2'
> PATH_SEPARATOR=':' RANLIB='' SED='' SET_MAKE='' SHELL='/bin/sh'
> SPEED_CYCLECOUNTER_OBJ='pentium.lo' STRIP='' TAL_OBJECT=''
> TUNE_LIBS='' TUNE_SQR_OBJ='' U_FOR_BUILD='' VERSION='6.1.2'
> WANT_CXX_FALSE='' WANT_CXX_TRUE='' WITH_READLINE_01='' YACC=''
> YFLAGS='' ac_ct_AR='' ac_ct_CC='' ac_ct_CXX='' ac_ct_DUMPBIN=''
> am__EXEEXT_FALSE='' am__EXEEXT_TRUE='' am__isrc='' am__leading_dot='.'
> am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'
> bindir='${exec_prefix}/bin' build='i686-pc-mingw32' build_alias=''
> build_cpu='i686' build_os='mingw32' build_vendor='pc'
> datadir='${datarootdir}' datarootdir='${prefix}/share'
> docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' dvidir='${docdir}'
> exec_prefix='NONE' gmp_srclinks='' host='i686-pc-mingw32'
> host_alias='' host_cpu='i686' host_os='mingw32' host_vendor='pc'
> htmldir='${docdir}' includedir='${prefix}/include'
> infodir='${datarootdir}/info' install_sh='${SHELL}
> /d/Libraries_For_C_and_C++/gmp-6.1.2/install-sh'
> libdir='${exec_prefix}/lib' libexecdir='${exec_prefix}/libexec'
> localedir='${datarootdir}/locale' localstatedir='${prefix}/var'
> mandir='${datarootdir}/man' mkdir_p='$(MKDIR_P)' mpn_objects=''
> mpn_objs_in_libgmp='' oldincludedir='/usr/include' pdfdir='${docdir}'
> prefix='/d/Libraries_For_C_and_C++/GMP'
> program_transform_name='s,x,x,' psdir='${docdir}'
> sbindir='${exec_prefix}/sbin' sharedstatedir='${prefix}/com'
> sysconfdir='${prefix}/etc' target_alias=''
>
> ## ----------- ##
> ## confdefs.h. ##
> ## ----------- ##
>
> /* confdefs.h */
> #define PACKAGE_NAME "GNU MP"
> #define PACKAGE_TARNAME "gmp"
> #define PACKAGE_VERSION "6.1.2"
> #define PACKAGE_STRING "GNU MP 6.1.2"
> #define PACKAGE_BUGREPORT "gmp-bugs#gmplib.org, see https://gmplib.org/manual/Reporting-Bugs.html"
> #define PACKAGE_URL "http://www.gnu.org/software/gmp/"
> #define PACKAGE "gmp"
> #define VERSION "6.1.2"
> #define WANT_FFT 1
> #define HAVE_HOST_CPU_i686 1
>
> configure: exit 1
What can I do?
Thanks!
I fixed the error by updating the MinGW compilator.
I also found this guide if someone need it:
https://hyperactve.blogspot.com/2012/04/gmp-c-library-in-windows-mingwmsys.html

boost::program_options positional options

I have a positional option (a file name), and I want it to be the very last option. The user can pass in a bunch of stuff on the command line, and also use -F for the file name. However, I want the user also to have the ability to place the file name at the end.
For example:
./program --var 3 /path/to/file
The code I currently have implemented allows the caller to place the file name wherever in the command line. Is there any way to force the positional arguments to always come after the "regular" ones?
Here's how I set-up the positional argument:
pos_opts_desc.add("filename", -1);
And to parse the command line:
store(
command_line_parser(argc, argv).options(opts_desc).positional(pos_opts_desc).run(),
opts_var_map);
Thanks in advance for the help.
Edited to add:
I'm perfectly OK with -F being specified anywhere in the command line. However, if the setting was done via the positional option, I want to ensure that the positional option is at the very end.
The run() member function gives you back an instance of type parsed_options. The simple usage is to never actually look at this object and pass it directly into store(), as in your example:
po::store(
po::command_line_parser(argc, argv).options(opts_desc).positional(pos_opts_desc).run(),
opts_var_map);
But we can hold onto it and examine its contents:
auto parsed = po::command_line_parser(argc, argv)
.options(opts_desc)
.positional(pos_opts_desc)
.run();
po::store(parsed, opts_var_map);
The parsed_options class has a member options which has an ordered list of all the options (unlike the variable map, which is ordered by option name - since it's a std::map). So you can look up the "filename" argument and check its position_key member. We want either: position_key == -1 (which means it provided with -F) or position_key == 0 and it being the last element in the options list (it was a positional argument that was the last argument):
auto it = std::find_if(parsed.options.begin(),
parsed.options.end(),
[](po::option const& o) {
return o.string_key == "filename";
});
if (it == parsed.options.end()) {
// fail: missing filename);
}
if (it->position_key != -1 && it != std::prev(parsed.options.end())) {
// fail: filename was positional but wasn't last
}
variables_map is as the name suggests a std::map, which allows us to use regular STL functions on it.
if ( vm.count("filename") ) {
if ( vm.find("filename") != std::prev(vm.rbegin()).base() ) {
std::cout << "filename must go at the end.";
}
}
Test cases:
g++ -std=c++14 -O2 -Wall -pedantic -pthread main.cpp -lboost_system -lboost_program_options \
&& echo -n "Case 1 " && ./a.out asdf --foo=12 && echo \
&& echo -n "Case 2 " && ./a.out --foo=12 asdf && echo \
&& echo -n "Case 3 " && ./a.out asdf && echo \
&& echo -n "Case 4 " && ./a.out --foo=12 && echo \
&& echo -n "Case 5 " && ./a.out && echo \
&& echo -n "Case 6 " && ./a.out --foo=12 asdf asdf
Result:
Case 1 filename must go at the end.
Case 2
Case 3
Case 4
Case 5
Case 6 option '--filename' cannot be specified more than once

Dynamic Parallelism Invalid File Format

I am facing a problem in correctly compiling CUDA code containing dynamic parallelism.
The problem is that compilation and linking show no error, but the generated file is invalid executable.
Configuration:
Tesla K40, Ubuntu 14.04 LTS, CUDA 7.5
Compilation Command:
nvcc -o cdp -rdc=true -dc -dlink -arch=sm_35 cdp.cu -lcudadevrt
Code:
#include <iostream>
#include <cuda_runtime.h>
using namespace std;
__global__ void kernel_find(int* data, int count, int value, int* index)
{
int idx = blockIdx.x * blockDim.x + threadIdx.x;
if(idx<count)
{
bool exists = (data[idx] == value);
if(exists)
atomicMin(index, idx);
}
}
__host__ __device__ int find_device(int* data, int count, int value)
{
int* idx = new int;
(*idx) = count;
dim3 block(8);
dim3 grid((count + block.x - 1)/block.x);
kernel_find<<<grid, block>>>(data, count, value, idx);
cudaDeviceSynchronize();
int retval = *idx;
delete idx;
return retval;
}
__global__ void kernel_find_bulk(int* data, int count, const int* toFind, int* foundIndices, int toFindCount)
{
int idx = blockIdx.x * blockDim.x + threadIdx.x;
if(idx<toFindCount)
{
int val = toFind[idx];
int foundIndex = find_device(data, count, val);
foundIndices[idx] = foundIndex;
}
}
int main()
{
const int count = 100, toFindCount = 10;
int *data, *toFind, *foundIndices;
cudaMallocManaged(&data, count * sizeof(int));
cudaMallocManaged(&toFind, toFindCount * sizeof(int));
cudaMallocManaged(&foundIndices, toFindCount * sizeof(int));
for(int i=0; i<count; i++)
{
data[i] = rand() % 30;
}
for(int i=0; i<toFindCount; i++)
{
toFind[i] = i;
}
dim3 block(8);
dim3 grid((toFindCount + block.x - 1)/block.x);
kernel_find_bulk<<<grid, block>>>(data, count, toFind, foundIndices, toFindCount);
cudaDeviceSynchronize();
for(int i=0; i<toFindCount; i++)
{
if(foundIndices[i] < count)
{
cout<<toFind[i]<<" found at index "<<foundIndices[i]<<endl;
}
else
{
cout<<toFind[i]<<" not found"<<endl;
}
}
return 0;
}
If I try to run the executable, I get Permission denied error. If permissions are changed forcefully using chmod, the error changes to cannot execute binary file: Exec format error.
I can't figure out the solution, as CUDA dynamic parallelism samples are running fine and CUDA programs without Dynamic Parallelism are also working fine. Any help would be appreciated.
Output of file command:
cdp: ELF 64-bit LSB relocatable, x86-64, version 1 (SYSV), not
stripped
Output of objdump -f command:
cdp: file format elf64-x86-64
architecture: i386:x86-64, flags 0x00000011:
HAS_RELOC, HAS_SYMS
start address 0x0000000000000000
If you run your compile command with the --dryrun option:
$ nvcc --dryrun -o cdp -rdc=true -dc -dlink -arch=sm_35 cdp.cu -lcudadevrt
#$ _SPACE_=
#$ _CUDART_=cudart
#$ _HERE_=/opt/cuda-7.5/bin
#$ _THERE_=/opt/cuda-7.5/bin
#$ _TARGET_SIZE_=
#$ _TARGET_DIR_=
#$ _TARGET_SIZE_=64
#$ TOP=/opt/cuda-7.5/bin/..
#$ NVVMIR_LIBRARY_DIR=/opt/cuda-7.5/bin/../nvvm/libdevice
#$ LD_LIBRARY_PATH=/opt/cuda-7.5/bin/../lib:/opt/cuda-7.5/lib64
#$ PATH=/opt/cuda-7.5/bin/../open64/bin:/opt/cuda-7.5/bin/../nvvm/bin:/opt/cuda-7.5/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/opt/cuda-7.5/bin
#$ INCLUDES="-I/opt/cuda-7.5/bin/..//include"
#$ LIBRARIES= "-L/opt/cuda-7.5/bin/..//lib64/stubs" "-L/opt/cuda-7.5/bin/..//lib64"
#$ CUDAFE_FLAGS=
#$ PTXAS_FLAGS=
#$ gcc -D__CUDA_ARCH__=350 -E -x c++ -DCUDA_DOUBLE_MATH_FUNCTIONS -D__CUDACC__ -D__NVCC__ -D__CUDACC_RDC__ "-I/opt/cuda-7.5/bin/..//include" -D"__CUDACC_VER__=70517" -D"__CUDACC_VER_BUILD__=17" -D"__CUDACC_VER_MINOR__=5" -D"__CUDACC_VER_MAJOR__=7" -include "cuda_runtime.h" -m64 "cdp.cu" > "/tmp/tmpxft_000022ba_00000000-7_cdp.cpp1.ii"
#$ cudafe --allow_managed --m64 --gnu_version=40603 -tused --no_remove_unneeded_entities --device-c --gen_c_file_name "/tmp/tmpxft_000022ba_00000000-4_cdp.cudafe1.c" --stub_file_name "/tmp/tmpxft_000022ba_00000000-4_cdp.cudafe1.stub.c" --gen_device_file_name "/tmp/tmpxft_000022ba_00000000-4_cdp.cudafe1.gpu" --nv_arch "compute_35" --gen_module_id_file --module_id_file_name "/tmp/tmpxft_000022ba_00000000-3_cdp.module_id" --include_file_name "tmpxft_000022ba_00000000-2_cdp.fatbin.c" "/tmp/tmpxft_000022ba_00000000-7_cdp.cpp1.ii"
#$ gcc -D__CUDA_ARCH__=350 -E -x c -DCUDA_DOUBLE_MATH_FUNCTIONS -D__CUDACC__ -D__NVCC__ -D__CUDACC_RDC__ -D__CUDANVVM__ -D__CUDA_PREC_DIV -D__CUDA_PREC_SQRT "-I/opt/cuda-7.5/bin/..//include" -m64 "/tmp/tmpxft_000022ba_00000000-4_cdp.cudafe1.gpu" > "/tmp/tmpxft_000022ba_00000000-8_cdp.cpp2.i"
#$ cudafe -w --allow_managed --m64 --gnu_version=40603 --c --device-c --gen_c_file_name "/tmp/tmpxft_000022ba_00000000-9_cdp.cudafe2.c" --stub_file_name "/tmp/tmpxft_000022ba_00000000-9_cdp.cudafe2.stub.c" --gen_device_file_name "/tmp/tmpxft_000022ba_00000000-9_cdp.cudafe2.gpu" --nv_arch "compute_35" --module_id_file_name "/tmp/tmpxft_000022ba_00000000-3_cdp.module_id" --include_file_name "tmpxft_000022ba_00000000-2_cdp.fatbin.c" "/tmp/tmpxft_000022ba_00000000-8_cdp.cpp2.i"
#$ gcc -D__CUDA_ARCH__=350 -E -x c -DCUDA_DOUBLE_MATH_FUNCTIONS -D__CUDABE__ -D__CUDANVVM__ -D__CUDA_PREC_DIV -D__CUDA_PREC_SQRT "-I/opt/cuda-7.5/bin/..//include" -m64 "/tmp/tmpxft_000022ba_00000000-9_cdp.cudafe2.gpu" > "/tmp/tmpxft_000022ba_00000000-10_cdp.cpp3.i"
#$ filehash -s "--compile-only " "/tmp/tmpxft_000022ba_00000000-10_cdp.cpp3.i" > "/tmp/tmpxft_000022ba_00000000-11_cdp.hash"
#$ gcc -E -x c++ -D__CUDACC__ -D__NVCC__ -D__CUDACC_RDC__ "-I/opt/cuda-7.5/bin/..//include" -D"__CUDACC_VER__=70517" -D"__CUDACC_VER_BUILD__=17" -D"__CUDACC_VER_MINOR__=5" -D"__CUDACC_VER_MAJOR__=7" -include "cuda_runtime.h" -m64 "cdp.cu" > "/tmp/tmpxft_000022ba_00000000-5_cdp.cpp4.ii"
#$ cudafe++ --allow_managed --m64 --gnu_version=40603 --parse_templates --device-c --gen_c_file_name "/tmp/tmpxft_000022ba_00000000-4_cdp.cudafe1.cpp" --stub_file_name "tmpxft_000022ba_00000000-4_cdp.cudafe1.stub.c" --module_id_file_name "/tmp/tmpxft_000022ba_00000000-3_cdp.module_id" "/tmp/tmpxft_000022ba_00000000-5_cdp.cpp4.ii"
#$ cicc -arch compute_35 -m64 -ftz=0 -prec_div=1 -prec_sqrt=1 -fmad=1 -nvvmir-library "/opt/cuda-7.5/bin/../nvvm/libdevice/libdevice.compute_35.10.bc" --device-c --orig_src_file_name "cdp.cu" "/tmp/tmpxft_000022ba_00000000-10_cdp.cpp3.i" -o "/tmp/tmpxft_000022ba_00000000-6_cdp.ptx"
#$ ptxas -arch=sm_35 -m64 --compile-only "/tmp/tmpxft_000022ba_00000000-6_cdp.ptx" -o "/tmp/tmpxft_000022ba_00000000-13_cdp.sm_35.cubin"
#$ fatbinary --create="/tmp/tmpxft_000022ba_00000000-2_cdp.fatbin" -64 --key="xxxxxxxxxx" --cmdline="--compile-only " "--image=profile=sm_35,file=/tmp/tmpxft_000022ba_00000000-13_cdp.sm_35.cubin" "--image=profile=compute_35,file=/tmp/tmpxft_000022ba_00000000-6_cdp.ptx" --embedded-fatbin="/tmp/tmpxft_000022ba_00000000-2_cdp.fatbin.c" --cuda --device-c
#$ rm /tmp/tmpxft_000022ba_00000000-2_cdp.fatbin
#$ gcc -D__CUDA_ARCH__=350 -E -x c++ -DCUDA_DOUBLE_MATH_FUNCTIONS -D__CUDA_PREC_DIV -D__CUDA_PREC_SQRT "-I/opt/cuda-7.5/bin/..//include" -m64 "/tmp/tmpxft_000022ba_00000000-4_cdp.cudafe1.cpp" > "/tmp/tmpxft_000022ba_00000000-14_cdp.ii"
#$ gcc -c -x c++ "-I/opt/cuda-7.5/bin/..//include" -fpreprocessed -m64 -o "cdp" "/tmp/tmpxft_000022ba_00000000-14_cdp.ii"
it becomes obvious that this has only emitted a host object file with an embedded cubin payload. There is no host code compilation or linking to an executable, which is confirmed by the output of objdump posted in an edit to your question.
The complicating factor here is that you must perform device independent compilation to use dynamic parallelism and then link the device code, but you only have a single source file, so the conventional build approach (device compile, device link, host compile) would fail with duplicate symbols.
The solution seems to be this:
$ nvcc --dryrun -o cdp -rdc=true -arch=sm_35 cdp.cu
#$ _SPACE_=
#$ _CUDART_=cudart
#$ _HERE_=/opt/cuda-7.5/bin
#$ _THERE_=/opt/cuda-7.5/bin
#$ _TARGET_SIZE_=
#$ _TARGET_DIR_=
#$ _TARGET_SIZE_=64
#$ TOP=/opt/cuda-7.5/bin/..
#$ NVVMIR_LIBRARY_DIR=/opt/cuda-7.5/bin/../nvvm/libdevice
#$ LD_LIBRARY_PATH=/opt/cuda-7.5/bin/../lib:/opt/cuda-7.5/lib64
#$ PATH=/opt/cuda-7.5/bin/../open64/bin:/opt/cuda-7.5/bin/../nvvm/bin:/opt/cuda-7.5/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/opt/cuda-7.5/bin
#$ INCLUDES="-I/opt/cuda-7.5/bin/..//include"
#$ LIBRARIES= "-L/opt/cuda-7.5/bin/..//lib64/stubs" "-L/opt/cuda-7.5/bin/..//lib64"
#$ CUDAFE_FLAGS=
#$ PTXAS_FLAGS=
#$ gcc -D__CUDA_ARCH__=350 -E -x c++ -DCUDA_DOUBLE_MATH_FUNCTIONS -D__CUDACC__ -D__NVCC__ -D__CUDACC_RDC__ "-I/opt/cuda-7.5/bin/..//include" -D"__CUDACC_VER__=70517" -D"__CUDACC_VER_BUILD__=17" -D"__CUDACC_VER_MINOR__=5" -D"__CUDACC_VER_MAJOR__=7" -include "cuda_runtime.h" -m64 "cdp.cu" > "/tmp/tmpxft_00002454_00000000-9_cdp.cpp1.ii"
#$ cudafe --allow_managed --m64 --gnu_version=40603 -tused --no_remove_unneeded_entities --device-c --gen_c_file_name "/tmp/tmpxft_00002454_00000000-4_cdp.cudafe1.c" --stub_file_name "/tmp/tmpxft_00002454_00000000-4_cdp.cudafe1.stub.c" --gen_device_file_name "/tmp/tmpxft_00002454_00000000-4_cdp.cudafe1.gpu" --nv_arch "compute_35" --gen_module_id_file --module_id_file_name "/tmp/tmpxft_00002454_00000000-3_cdp.module_id" --include_file_name "tmpxft_00002454_00000000-2_cdp.fatbin.c" "/tmp/tmpxft_00002454_00000000-9_cdp.cpp1.ii"
#$ gcc -D__CUDA_ARCH__=350 -E -x c -DCUDA_DOUBLE_MATH_FUNCTIONS -D__CUDACC__ -D__NVCC__ -D__CUDACC_RDC__ -D__CUDANVVM__ -D__CUDA_PREC_DIV -D__CUDA_PREC_SQRT "-I/opt/cuda-7.5/bin/..//include" -m64 "/tmp/tmpxft_00002454_00000000-4_cdp.cudafe1.gpu" > "/tmp/tmpxft_00002454_00000000-10_cdp.cpp2.i"
#$ cudafe -w --allow_managed --m64 --gnu_version=40603 --c --device-c --gen_c_file_name "/tmp/tmpxft_00002454_00000000-11_cdp.cudafe2.c" --stub_file_name "/tmp/tmpxft_00002454_00000000-11_cdp.cudafe2.stub.c" --gen_device_file_name "/tmp/tmpxft_00002454_00000000-11_cdp.cudafe2.gpu" --nv_arch "compute_35" --module_id_file_name "/tmp/tmpxft_00002454_00000000-3_cdp.module_id" --include_file_name "tmpxft_00002454_00000000-2_cdp.fatbin.c" "/tmp/tmpxft_00002454_00000000-10_cdp.cpp2.i"
#$ gcc -D__CUDA_ARCH__=350 -E -x c -DCUDA_DOUBLE_MATH_FUNCTIONS -D__CUDABE__ -D__CUDANVVM__ -D__CUDA_PREC_DIV -D__CUDA_PREC_SQRT "-I/opt/cuda-7.5/bin/..//include" -m64 "/tmp/tmpxft_00002454_00000000-11_cdp.cudafe2.gpu" > "/tmp/tmpxft_00002454_00000000-12_cdp.cpp3.i"
#$ filehash -s "--compile-only " "/tmp/tmpxft_00002454_00000000-12_cdp.cpp3.i" > "/tmp/tmpxft_00002454_00000000-13_cdp.hash"
#$ gcc -E -x c++ -D__CUDACC__ -D__NVCC__ -D__CUDACC_RDC__ "-I/opt/cuda-7.5/bin/..//include" -D"__CUDACC_VER__=70517" -D"__CUDACC_VER_BUILD__=17" -D"__CUDACC_VER_MINOR__=5" -D"__CUDACC_VER_MAJOR__=7" -include "cuda_runtime.h" -m64 "cdp.cu" > "/tmp/tmpxft_00002454_00000000-5_cdp.cpp4.ii"
#$ cudafe++ --allow_managed --m64 --gnu_version=40603 --parse_templates --device-c --gen_c_file_name "/tmp/tmpxft_00002454_00000000-4_cdp.cudafe1.cpp" --stub_file_name "tmpxft_00002454_00000000-4_cdp.cudafe1.stub.c" --module_id_file_name "/tmp/tmpxft_00002454_00000000-3_cdp.module_id" "/tmp/tmpxft_00002454_00000000-5_cdp.cpp4.ii"
#$ cicc -arch compute_35 -m64 -ftz=0 -prec_div=1 -prec_sqrt=1 -fmad=1 -nvvmir-library "/opt/cuda-7.5/bin/../nvvm/libdevice/libdevice.compute_35.10.bc" --device-c --orig_src_file_name "cdp.cu" "/tmp/tmpxft_00002454_00000000-12_cdp.cpp3.i" -o "/tmp/tmpxft_00002454_00000000-6_cdp.ptx"
#$ ptxas -arch=sm_35 -m64 --compile-only "/tmp/tmpxft_00002454_00000000-6_cdp.ptx" -o "/tmp/tmpxft_00002454_00000000-15_cdp.sm_35.cubin"
#$ fatbinary --create="/tmp/tmpxft_00002454_00000000-2_cdp.fatbin" -64 --key="xxxxxxxxxx" --cmdline="--compile-only " "--image=profile=sm_35,file=/tmp/tmpxft_00002454_00000000-15_cdp.sm_35.cubin" "--image=profile=compute_35,file=/tmp/tmpxft_00002454_00000000-6_cdp.ptx" --embedded-fatbin="/tmp/tmpxft_00002454_00000000-2_cdp.fatbin.c" --cuda --device-c
#$ rm /tmp/tmpxft_00002454_00000000-2_cdp.fatbin
#$ gcc -D__CUDA_ARCH__=350 -E -x c++ -DCUDA_DOUBLE_MATH_FUNCTIONS -D__CUDA_PREC_DIV -D__CUDA_PREC_SQRT "-I/opt/cuda-7.5/bin/..//include" -m64 "/tmp/tmpxft_00002454_00000000-4_cdp.cudafe1.cpp" > "/tmp/tmpxft_00002454_00000000-16_cdp.ii"
#$ gcc -c -x c++ "-I/opt/cuda-7.5/bin/..//include" -fpreprocessed -m64 -o "/tmp/tmpxft_00002454_00000000-17_cdp.o" "/tmp/tmpxft_00002454_00000000-16_cdp.ii"
#$ nvlink --arch=sm_35 --register-link-binaries="/tmp/tmpxft_00002454_00000000-7_cdp_dlink.reg.c" -m64 "-L/opt/cuda-7.5/bin/..//lib64/stubs" "-L/opt/cuda-7.5/bin/..//lib64" -cpu-arch=X86_64 "/tmp/tmpxft_00002454_00000000-17_cdp.o" -lcudadevrt -o "/tmp/tmpxft_00002454_00000000-18_cdp_dlink.sm_35.cubin"
#$ fatbinary --create="/tmp/tmpxft_00002454_00000000-8_cdp_dlink.fatbin" -64 --key="cdp_dlink" --cmdline="--compile-only " -link "--image=profile=sm_35,file=/tmp/tmpxft_00002454_00000000-18_cdp_dlink.sm_35.cubin" --embedded-fatbin="/tmp/tmpxft_00002454_00000000-8_cdp_dlink.fatbin.c"
#$ rm /tmp/tmpxft_00002454_00000000-8_cdp_dlink.fatbin
#$ gcc -c -x c++ -DFATBINFILE="\"/tmp/tmpxft_00002454_00000000-8_cdp_dlink.fatbin.c\"" -DREGISTERLINKBINARYFILE="\"/tmp/tmpxft_00002454_00000000-7_cdp_dlink.reg.c\"" -I. "-I/opt/cuda-7.5/bin/..//include" -D"__CUDACC_VER__=70517" -D"__CUDACC_VER_BUILD__=17" -D"__CUDACC_VER_MINOR__=5" -D"__CUDACC_VER_MAJOR__=7" -m64 -o "/tmp/tmpxft_00002454_00000000-19_cdp_dlink.o" "/opt/cuda-7.5/bin/crt/link.stub"
#$ g++ -m64 -o "cdp" -Wl,--start-group "/tmp/tmpxft_00002454_00000000-19_cdp_dlink.o" "/tmp/tmpxft_00002454_00000000-17_cdp.o" "-L/opt/cuda-7.5/bin/..//lib64/stubs" "-L/opt/cuda-7.5/bin/..//lib64" -lcudadevrt -lcudart_static -lrt -lpthread -ldl -Wl,--end-group
i.e. just pass -rdc=true. It seems for the single source file case, the necessary device link stage in implicitly performed, and the result is an executable which should work:
$ nvcc -o cdp -rdc=true -arch=sm_35 cdp.cu
$ file cdp
cdp: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=0xdcd6119fb9e2efdf2759093e8e9b762d0a55ddfd, not stripped
Note that I haven't run this because I am doing the build on a system with a GPU without dynamic parallelism support.

Bash script: require each option parameter to occur at most once

I am writing a script in unix, which will take options as parameter as shown:
./command -pers
The options allowed are p, e, r, s and can be in any order and are optional also. Example, these are correct syntax: ./command -e, ./command -sr, ./command -pes, but this one is incorrect ./command -pep, ./command -ssr. Repetition of option is not allowed, but atleast one option is required.
For the same I have used regular expression, but it is not avoiding repetition.
But it is allowing repetition. Please tell what is wring with the expression.
[[ $1 =~ ^-[p{0,1}r{0,1}s{0,1}e{0,1}]{1,4}$ ]] || { echo "$MSG_INCORRECT_USAGE"; }
You can use a script opt.sh like this to avoid processing each passed option more than once:
#!/bin/bash
while getopts "pers" opt; do
[[ -n ${!opt} ]] && { echo "Error: $opt already processed"; exit 1; } || declare $opt=1
case $opt in
p) echo "processing p!" ;;
e) echo "processing e!" ;;
r) echo "processing r!" ;;
s) echo "processing s!" ;;
\?) echo "Invalid option: -$OPTARG" ;;
esac
done
Testing:
bash ./opt.sh -srr
processing s!
processing r!
Error: r already processed
bash ./opt.sh -pep
processing p!
processing e!
Error: p already processed
bash ./opt.sh -pers
processing p!
processing e!
processing r!
processing s!
#!/bin/bash
while getopts "pers" OPTION; do
echo $OPTION
done
Results:
$ bash test.sh -pers
p
e
r
s
Replace echo $OPTION with a case statement and report errors if an option appears twice. Example:
#!/bin/bash
unset OPT_P OPT_E OPT_R OPT_S
while getopts "pers" OPTION; do
case $OPTION in
p)
if [ $OPT_P ]; then
echo "-p appeared twice"
exit 64
else
OPT_P="true"
fi
;;
#... and so on ...
\?)
echo "Unrecognized option $OPTION"
exit 64
;;
done
arg0=$(basename $0 .sh)
error() { echo "$arg0: $*" >&2; exit 1; }
usage() { echo "Usage: $arg0 [-pers]" >&2; exit 1; }
p_flag=
e_flag=
r_flag=
s_flag=
while getopts pers arg
do
case "$arg" in
(e) [ -z "$e_flag" ] || error "-e flag repeated"
e_flag=1;;
(p) [ -z "$p_flag" ] || error "-p flag repeated"
p_flag=1;;
(r) [ -z "$r_flag" ] || error "-r flag repeated"
r_flag=1;;
(s) [ -z "$s_flag" ] || error "-s flag repeated"
s_flag=1;;
(*) usage;;
esac
done
shift $(($OPTIND - 1))
[ -z "$e_flag$p_flag$r_flag$s_flag" ] && error "You must specify one of -e, -p, -r, -s"
[ $# = 0 ] || error "You may not specify any non-option arguments"
…process the code for each option that was set…
If you need to process the options in the sequence they're given, then you need to record the order in which they arrive. Use an array:
flags=()
before the loop, and
flags+=("$arg")
after the esac. The processing can then process each element of the $flags in sequence.
for flag in "${flags[#]}"
do
…processing for the particular flag…
done

Compile a project with C and C++ files separately using gcc and g++?

I have a project that contains C and C++ files and I created a Makefile to compile this project.
Is it possible to have a Makefile that will "separate" the C and C++ files, the C files will be compile with gcc and the C++ files with g++ and create one binary ?
This is the Makefile I created:
TECHAUDIO_ROOT = ../../../../../../..
TECHAUDIO_GENERIC = $(TECHAUDIO_ROOT)/Generic
TECHAUDIO_MALLOC_3DSL = $(TECHAUDIO_ROOT)/Tools/Malloc_3DSL
TECHAUDIO_SIGPROC_COMMON_SRC = ../../../../SignalProcessing/RefFT/Common/src
TECHAUDIO_SIGPROC_SRC = ../../../../SignalProcessing/RefFT/Float/src
TECHAUDIO_LIMOTOR_SRC = ../../../RefFT/Float/src
TECHAUDIO_LIMOTOR_COMMON_SRC = ../../../RefFT/Common/src/API
INCLUDES += -I$(TECHAUDIO_GENERIC)/Common/Include \
-I$(TECHAUDIO_GENERIC)/X86/Include \
-I$(TECHAUDIO_MALLOC_3DSL)/RefFT/Common/Include \
-I$(TECHAUDIO_SIGPROC_COMMON_SRC) \
-I$(TECHAUDIO_SIGPROC_SRC)/Math \
-I$(TECHAUDIO_SIGPROC_SRC)/Transform \
-I$(TECHAUDIO_SIGPROC_SRC)/Filter \
-I$(TECHAUDIO_SIGPROC_SRC)/Vector \
-I$(TECHAUDIO_SIGPROC_SRC)/SSTP \
-I$(TECHAUDIO_LIMOTOR_SRC)/API \
-I$(TECHAUDIO_LIMOTOR_COMMON_SRC) \
-I$(TECHAUDIO_LIMOTOR_SRC)
SRCS = $(TECHAUDIO_LIMOTOR_SRC)/LIMITOR_main_32f.c \
$(TECHAUDIO_LIMOTOR_SRC)/API/LIMITOR_API_32f.c \
$(TECHAUDIO_LIMOTOR_SRC)/API/LIMITOR_API_coordinate_32f.c
SRCSCPP = $(TECHAUDIO_LIMOTOR_SRC)/Test/LIMITOR_TEST_example_32f.cpp
# $(TECHAUDIO_LIMOTOR_SRC)/VST/LIMITOR_VST_audioEffect_32f.cpp \
# $(TECHAUDIO_LIMOTOR_SRC)/VST/LIMITOR_VST_main_32f.cpp
NAME = Bonjour
CC = gcc
CPP = g++
CFLAGS += $(INCLUDES)
CFLAGS += -D_X86_GCC_4_1_1_TARGET_
#CFLAGS +=-D_X86_VC8_TARGET_
RM = rm -f
OBJ= $(SRCS:.c=.o)
OBJCPP= $(SRCSCPP:.cpp=.o)
all: $(NAME)
$(NAME): $(OBJ)
$(CC) $(CFLAGS) $(OBJ) -o $(NAME) -lm
$(OBJCPP)
$(CPP) $(CFLAGS) $(OBJCPP) -o $(NAME) -lm
clean:
$(RM) $(OBJ) $(OBJCPP)
fclean: clean
$(RM) $(NAME)
re: fclean all
EDIT
Below is an updated version of the Makefile:
TECHAUDIO_ROOT = ../../../../../../..
TECHAUDIO_GENERIC = $(TECHAUDIO_ROOT)/Generic
TECHAUDIO_MALLOC_3DSL = $(TECHAUDIO_ROOT)/Tools/Malloc_3DSL
TECHAUDIO_SIGPROC_COMMON_SRC = ../../../../SignalProcessing/RefFT/Common/src
TECHAUDIO_SIGPROC_SRC = ../../../../SignalProcessing/RefFT/Float/src
TECHAUDIO_LIMOTOR_SRC = ../../../RefFT/Float/src
TECHAUDIO_LIMOTOR_COMMON_SRC = ../../../RefFT/Common/src/API
INCLUDES += -I$(TECHAUDIO_GENERIC)/Common/Include \
-I$(TECHAUDIO_GENERIC)/X86/Include \
-I$(TECHAUDIO_MALLOC_3DSL)/RefFT/Common/Include \
-I$(TECHAUDIO_SIGPROC_COMMON_SRC) \
-I$(TECHAUDIO_SIGPROC_SRC)/Math \
-I$(TECHAUDIO_SIGPROC_SRC)/Transform \
-I$(TECHAUDIO_SIGPROC_SRC)/Filter \
-I$(TECHAUDIO_SIGPROC_SRC)/Vector \
-I$(TECHAUDIO_SIGPROC_SRC)/SSTP \
-I$(TECHAUDIO_LIMOTOR_SRC)/API \
-I$(TECHAUDIO_LIMOTOR_COMMON_SRC) \
-I$(TECHAUDIO_LIMOTOR_SRC)
SRCS = $(TECHAUDIO_LIMOTOR_SRC)/LIMITOR_main_32f.c \
$(TECHAUDIO_LIMOTOR_SRC)/API/LIMITOR_API_32f.c \
$(TECHAUDIO_LIMOTOR_SRC)/API/LIMITOR_API_coordinate_32f.c
SRCSCPP = $(TECHAUDIO_LIMOTOR_SRC)/Test/LIMITOR_TEST_example_32f.cpp
# $(TECHAUDIO_LIMOTOR_SRC)/VST/LIMITOR_VST_audioEffect_32f.cpp \
# $(TECHAUDIO_LIMOTOR_SRC)/VST/LIMITOR_VST_main_32f.cpp
NAME = Bonjour
CC = gcc
CPP = g++
CFLAGS += $(INCLUDES)
CFLAGS += -D_X86_GCC_4_1_1_TARGET_
#CFLAGS +=-D_X86_VC8_TARGET_
RM = rm -f
OBJ= $(SRCS:.c=.o)
OBJCPP= $(SRCSCPP:.cpp=.o)
%.o: %.c
$(CC) $(CFLAGS) $<
%.o: %.cpp
$(CPP) $(CFLAGS) $<
all: $(NAME)
$(NAME): $(OBJ) $(OBJCPP)
$(LD) $^ -o $# $(LDFLAGS)
clean:
$(RM) $(OBJ) $(OBJCPP)
fclean: clean
$(RM) $(NAME)
re: fclean all
These are the errors I receive when I execute make:
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): réadressage 20 a un index de symbole 13 invalide
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): réadressage 21 a un index de symbole 22 invalide
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_line): réadressage 0 a un index de symbole 2 invalide
/usr/lib/gcc/i686-linux-gnu/4.8/../../../i386-linux-gnu/crt1.o: dans la fonction « _start »:
(.text+0x18): référence indéfinie vers « main »
/tmp/ccvLa3z6.o: dans la fonction « LIMITOR_3DSL_getStatusSize_32f »:
LIMITOR_main_32f.c:(.text+0x1e): référence indéfinie vers « MALLOC_3DSL_compute_memory_size_align_heap »
Try adding these rules:
%.o: %.c
$(CC) $(CFLAGS) $<
%.o: %.cpp
$(CPP) $(CFLAGS) $<
And changing your main line to:
$(NAME): $(OBJ) $(OBJCPP)
$(LD) $^ -o $# $(LDFLAGS)
EDIT:
Here is an attempt to integrate this in your code. I did not run this, though.
TECHAUDIO_ROOT = ../../../../../../..
TECHAUDIO_GENERIC = $(TECHAUDIO_ROOT)/Generic
TECHAUDIO_MALLOC_3DSL = $(TECHAUDIO_ROOT)/Tools/Malloc_3DSL
TECHAUDIO_SIGPROC_COMMON_SRC = ../../../../SignalProcessing/RefFT/Common/src
TECHAUDIO_SIGPROC_SRC = ../../../../SignalProcessing/RefFT/Float/src
TECHAUDIO_LIMOTOR_SRC = ../../../RefFT/Float/src
TECHAUDIO_LIMOTOR_COMMON_SRC = ../../../RefFT/Common/src/API
INCLUDES += -I$(TECHAUDIO_GENERIC)/Common/Include \
-I$(TECHAUDIO_GENERIC)/X86/Include \
-I$(TECHAUDIO_MALLOC_3DSL)/RefFT/Common/Include \
-I$(TECHAUDIO_SIGPROC_COMMON_SRC) \
-I$(TECHAUDIO_SIGPROC_SRC)/Math \
-I$(TECHAUDIO_SIGPROC_SRC)/Transform \
-I$(TECHAUDIO_SIGPROC_SRC)/Filter \
-I$(TECHAUDIO_SIGPROC_SRC)/Vector \
-I$(TECHAUDIO_SIGPROC_SRC)/SSTP \
-I$(TECHAUDIO_LIMOTOR_SRC)/API \
-I$(TECHAUDIO_LIMOTOR_COMMON_SRC) \
-I$(TECHAUDIO_LIMOTOR_SRC)
SRCS = $(TECHAUDIO_LIMOTOR_SRC)/LIMITOR_main_32f.c \
$(TECHAUDIO_LIMOTOR_SRC)/API/LIMITOR_API_32f.c \
$(TECHAUDIO_LIMOTOR_SRC)/API/LIMITOR_API_coordinate_32f.c
SRCSCPP = $(TECHAUDIO_LIMOTOR_SRC)/Test/LIMITOR_TEST_example_32f.cpp
# $(TECHAUDIO_LIMOTOR_SRC)/VST/LIMITOR_VST_audioEffect_32f.cpp \
# $(TECHAUDIO_LIMOTOR_SRC)/VST/LIMITOR_VST_main_32f.cpp
NAME = Bonjour
CC = gcc -c
CPP = g++ -c
LD = g++ -o
CFLAGS += $(INCLUDES)
CFLAGS += -D_X86_GCC_4_1_1_TARGET_
#CFLAGS +=-D_X86_VC8_TARGET_
RM = rm -f
OBJ= $(SRCS:.c=.o)
OBJCPP= $(SRCSCPP:.cpp=.o)
%.o: %.c
$(CC) $< -o $# $(CFLAGS)
%.o: %.cpp
$(CPP) $< -o $# $(CFLAGS)
all: $(NAME)
$(NAME): $(OBJ) $(OBJCPP)
$(LD) $# $^ -lm
clean:
$(RM) $(OBJ) $(OBJCPP)
fclean: clean
$(RM) $(NAME)
re: fclean all