Menu

Linux Compile Error

2018-02-08
2018-02-11
  • John Fierke

    John Fierke - 2018-02-08

    running make produced the following error.

    $ gcc -Ilib -Iexternals/simplecpp -Iexternals/tinyxml   -include lib/cxx11emu.h -pedantic -Wall -Wextra -Wabi -Wcast-qual -Wfloat-equal -Wmissing-declarations -Wmissing-format-attribute -Wno-long-long -Wpacked -Wredundant-decls -Wshadow -Wno-missing-field-initializers -Wno-missing-braces -Wno-sign-compare -Wno-multichar -D_GLIBCXX_DEBUG -g -std=c++0x  -c -o lib/analyzerinfo.o lib/analyzerinfo.cpp
    In file included from lib/importproject.h:26,
                     from lib/analyzerinfo.h:26,
                     from lib/analyzerinfo.cpp:19:
    lib/utils.h: In function 'bool endsWith(const std::string&, char)':
    lib/utils.h:63: error: 'const struct std::basic_string<char, std::char_traits<char>, std::allocator<char> >' has no member named 'back'
    

    Any suggestions?

    Admittedly, our system is not running all the newest :

    gcc version 4.4.7 20120313 (Red Hat 4.4.7-18) (GCC)

    Is there a workaround? Do I need updated libraries? Updated compiler?

     
  • versat

    versat - 2018-02-09

    From https://github.com/danmar/cppcheck/blob/master/readme.md :
    g++ 4.6 (or later)
    So i would suggest updating gcc/g++ if possible.
    Have you tried g++ instead of gcc? I guess it will not work with g++4.4.7 too, but there some (rather small) differences.

     

    Last edit: versat 2018-02-09
  • Daniel Marjamäki

    I don't guarantee that it works.. but I use this script to compile the democlient:

    echo Get cppcheck
    wget https://github.com/danmar/cppcheck/archive/$1.tar.gz
    rm -rf cppcheck-$1
    tar xzvf $1.tar.gz
    rm $1.tar.gz
    
    echo Tweak code
    cd cppcheck-$1
    sed -i 's/template<typename T>//' lib/token.h
    sed -i 's/T&&/const std::string/' lib/token.h
    #perl -i -pe "s/([_a-zA-Z0-9]+)(\.|->)back\(\)\s*([!=]=)\s*'/\1\2at(\1\2size()-1U)\3'/g" lib/*.cpp
    sed -i 's/return str\.back[(][)]/return !str.empty() \&\& str.at(str.size()-1U)/' lib/utils.h
    perl -i -pe "s/isalnum\(\(unsigned char\)([_a-zA-Z0-9]+)\.back\(\)\)/isalnum\(\(unsigned char\)\1\[\1.size()-1U\]\)/" lib/*.cpp
    perl -i -pe "s/([_a-zA-Z0-9]+)\.back\(\)\s*([=!]=)\s*'/\1\[\1.size()-1U\]\2'/" cli/*.cpp
    sed -i "s/tok->str[(][)]\.back[(][)]/tok->str()[tok->str().length() - 1U]/" lib/*.cpp
    sed -i 's/[(]str[.]front[(][)][)]/(str[0])/' lib/mathlib.cpp
    sed -i 's/std::numeric_limits<MathLib::bigint>::max[(][)]/0x7fffffffffffffffLL/' lib/valueflow.cpp
    sed -i "s/str[(]tok->str[(][)]\[0\][)]/str(tok->str().substr(0,1))/" lib/tokenlist.cpp
    sed -i "s/std::numeric_limits<T>::lowest[()]*/std::min(value1,value2)-1/" lib/checkcondition.cpp 
    sed -i 's/[?][ ]*nullptr[ ]*:[ ]*"/? (const char *)nullptr : "/' lib/*.cpp
    
    echo Build
    nice make
    g++ -O2 -o democlient-$1.cgi -std=c++0x -include lib/cxx11emu.h -Ilib -DNDEBUG democlient/democlient.cpp lib/*.o externals/tinyxml/tinyxml2.o externals/simplecpp/simplecpp.o
    

    The democlient is compiled with the same gcc version that you tried.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.