Menu

Build cppcheck 2.4 on AIX 7.2

Michael
2021-05-26
2021-06-30
  • Michael

    Michael - 2021-05-26

    There was another build question in 2019 without solution.
    Newest build for AIX is from 2014 (v1.63). Thus I want to build it by my own. But I can't get it working.

    Environment: AIX 7.2, gcc 8.1, g++, gmake 4.2.1, cmake 3.14
    - cmake:

    bash-4.4$ mkdir build
    bash-4.4$ cd build
    bash-4.4$ /opt/freeware/bin/cmake ..
    -- The C compiler identification is GNU 8.1.0
    -- The CXX compiler identification is GNU 8.1.0
    -- Check for working C compiler: /usr/bin/gcc
    -- Check for working C compiler: /usr/bin/gcc -- works
    -- Detecting C compiler ABI info
    -- Detecting C compiler ABI info - done
    -- Detecting C compile features
    -- Detecting C compile features - done
    -- Check for working CXX compiler: /usr/bin/c++
    -- Check for working CXX compiler: /usr/bin/c++ -- works
    -- Detecting CXX compiler ABI info
    -- Detecting CXX compiler ABI info - done
    -- Detecting CXX compile features
    -- Detecting CXX compile features - done
    -- Using bundled version of tinyxml2
    -- ------------------ General configuration for Cppcheck 2.4 -----------------
    -- 
    -- CMake Generator =       Unix Makefiles
    -- Compiler =              GNU
    -- Compiler Version =      8.1.0
    -- Build type =            Debug
    -- CMAKE_INSTALL_PREFIX =  /usr/local
    -- CMAKE_DISABLE_PRECOMPILE_HEADERS = On
    -- C++ flags (General) =   
    -- C++ flags (Release) =   -O3 -DNDEBUG
    -- C++ flags (RelWithDebInfo) = -O2 -g -DNDEBUG
    -- C++ flags (Debug) =     -g
    -- Found Define: _GLIBCXX_DEBUG
    -- Found Define: FILESDIR="/usr/local/share/Cppcheck"
    -- 
    -- ---------------------------------------------------------
    -- ANALYZE_MEMORY =        OFF
    -- ANALYZE_ADDRESS =       OFF
    -- ANALYZE_THREAD =        OFF
    -- ANALYZE_UNDEFINED =     OFF
    -- ANALYZE_DATAFLOW =      OFF
    -- WARNINGS_ARE_ERRORS =   OFF
    -- 
    -- USE_MATCHCOMPILER =     Auto
    -- USE_MATCHCOMPILER_OPT = Off
    -- 
    -- BUILD_SHARED_LIBS =     OFF
    -- LIBXML2_XMLLINT_EXECUTABLE = LIBXML2_XMLLINT_EXECUTABLE-NOTFOUND
    -- BUILD_TESTS =           OFF
    -- ENABLE_CHECK_INTERNAL = OFF
    -- ENABLE_OSS_FUZZ =       ON
    -- 
    -- BUILD_GUI =             OFF
    -- WITH_QCHART =           OFF
    -- 
    -- HAVE_RULES =            OFF
    -- 
    -- USE_Z3 =                OFF
    -- USE_BUNDLED_TINYXML2 =  ON
    -- 
    -- CLANG_TIDY=CLANG_TIDY-NOTFOUND
    -- Configuring done
    -- Generating done
    -- Build files have been written to: /home/ajhmf7y/cppcheck-2.4/build
    
    bash-4.4$ /opt/freeware/bin/cmake --build .
    Scanning dependencies of target tinyxml2_objs
    [  1%] Building CXX object externals/tinyxml2/CMakeFiles/tinyxml2_objs.dir/tinyxml2.cpp.o
    [  1%] Built target tinyxml2_objs
    Scanning dependencies of target simplecpp_objs
    [  3%] Building CXX object externals/simplecpp/CMakeFiles/simplecpp_objs.dir/simplecpp.cpp.o
    /home/ajhmf7y/cppcheck-2.4/externals/simplecpp/simplecpp.cpp: In function 'void simplecpp::preprocess(simplecpp::TokenList&, const simplecpp::TokenList&, std::__debug::vector<std::__cxx11::basic_string<char> >&, std::__debug::map<std::__cxx11::basic_string<char>, simplecpp::TokenList*>&, const simplecpp::DUI&, simplecpp::OutputList*, std::__debug::list<simplecpp::MacroUsage>*)':
    /home/ajhmf7y/cppcheck-2.4/externals/simplecpp/simplecpp.cpp:2604:5: error: expected primary-expression before 'enum'
         enum IfState { TRUE, ELSE_IS_TRUE, ALWAYS_FALSE };
         ^~~~
    /home/ajhmf7y/cppcheck-2.4/externals/simplecpp/simplecpp.cpp:2782:39: error: 'ALWAYS_FALSE' was not declared in this scope
                     if (ifstates.top() == ALWAYS_FALSE || (ifstates.top() == ELSE_IS_TRUE && rawtok->str() != ELIF))
                                           ^~~~~~~~~~~~
    /home/ajhmf7y/cppcheck-2.4/externals/simplecpp/simplecpp.cpp:2782:74: error: 'ELSE_IS_TRUE' was not declared in this scope
                     if (ifstates.top() == ALWAYS_FALSE || (ifstates.top() == ELSE_IS_TRUE && rawtok->str() != ELIF))
                                                                              ^~~~~~~~~~~~
    /home/ajhmf7y/cppcheck-2.4/externals/simplecpp/simplecpp.cpp:2852:39: error: 'ALWAYS_FALSE' was not declared in this scope
                             ifstates.push(ALWAYS_FALSE);
                                           ^~~~~~~~~~~~
    /home/ajhmf7y/cppcheck-2.4/externals/simplecpp/simplecpp.cpp:2854:64: error: 'ELSE_IS_TRUE' was not declared in this scope
                             ifstates.push(conditionIsTrue ? TRUE : ELSE_IS_TRUE);
                                                                    ^~~~~~~~~~~~
    /home/ajhmf7y/cppcheck-2.4/externals/simplecpp/simplecpp.cpp:2856:38: error: 'ALWAYS_FALSE' was not declared in this scope
                         ifstates.top() = ALWAYS_FALSE;
                                          ^~~~~~~~~~~~
    /home/ajhmf7y/cppcheck-2.4/externals/simplecpp/simplecpp.cpp:2857:46: error: 'ELSE_IS_TRUE' was not declared in this scope
                     } else if (ifstates.top() == ELSE_IS_TRUE && conditionIsTrue) {
                                                  ^~~~~~~~~~~~
    /home/ajhmf7y/cppcheck-2.4/externals/simplecpp/simplecpp.cpp:2861:53: error: 'ELSE_IS_TRUE' was not declared in this scope
                     ifstates.top() = (ifstates.top() == ELSE_IS_TRUE) ? TRUE : ALWAYS_FALSE;
                                                         ^~~~~~~~~~~~
    /home/ajhmf7y/cppcheck-2.4/externals/simplecpp/simplecpp.cpp:2861:76: error: 'ALWAYS_FALSE' was not declared in this scope
                     ifstates.top() = (ifstates.top() == ELSE_IS_TRUE) ? TRUE : ALWAYS_FALSE;
                                                                                ^~~~~~~~~~~~
    gmake[2]: *** [externals/simplecpp/CMakeFiles/simplecpp_objs.dir/build.make:63: externals/simplecpp/CMakeFiles/simplecpp_objs.dir/simplecpp.cpp.o] Error 1
    gmake[1]: *** [CMakeFiles/Makefile2:178: externals/simplecpp/CMakeFiles/simplecpp_objs.dir/all] Error 2
    gmake: *** [Makefile:130: all] Error 2
    

    Using g++ directly outputs a hugh error log with messages like not findeing memcpy() and others.

    Any hints how to build it on AIX?

     

    Last edit: Michael 2021-05-26
  • Daniel Marjamäki

    Very strange.

    Do you get the same output if you run g++ directly?

    cd /home/ajhmf7y/cppcheck-2.4
    g++ -fsyntax-only externals/simplecpp/simplecpp.cpp 
    
     
  • Michael

    Michael - 2021-05-27

    Same output:

    bash-4.4$ g++ -fsyntax-only externals/simplecpp/simplecpp.cpp 
    externals/simplecpp/simplecpp.cpp: In function 'void simplecpp::preprocess(simplecpp::TokenList&, const simplecpp::TokenList&, std::vector<std::__cxx11::basic_string<char> >&, std::map<std::__cxx11::basic_string<char>, simplecpp::TokenList*>&, const simplecpp::DUI&, simplecpp::OutputList*, std::__cxx11::list<simplecpp::MacroUsage>*)':
    externals/simplecpp/simplecpp.cpp:2604:5: error: expected primary-expression before 'enum'
         enum IfState { TRUE, ELSE_IS_TRUE, ALWAYS_FALSE };
         ^~~~
    externals/simplecpp/simplecpp.cpp:2782:39: error: 'ALWAYS_FALSE' was not declared in this scope
                     if (ifstates.top() == ALWAYS_FALSE || (ifstates.top() == ELSE_IS_TRUE && rawtok->str() != ELIF))
                                           ^~~~~~~~~~~~
    externals/simplecpp/simplecpp.cpp:2782:74: error: 'ELSE_IS_TRUE' was not declared in this scope
                     if (ifstates.top() == ALWAYS_FALSE || (ifstates.top() == ELSE_IS_TRUE && rawtok->str() != ELIF))
                                                                              ^~~~~~~~~~~~
    externals/simplecpp/simplecpp.cpp:2852:39: error: 'ALWAYS_FALSE' was not declared in this scope
                             ifstates.push(ALWAYS_FALSE);
                                           ^~~~~~~~~~~~
    externals/simplecpp/simplecpp.cpp:2854:64: error: 'ELSE_IS_TRUE' was not declared in this scope
                             ifstates.push(conditionIsTrue ? TRUE : ELSE_IS_TRUE);
                                                                    ^~~~~~~~~~~~
    externals/simplecpp/simplecpp.cpp:2856:38: error: 'ALWAYS_FALSE' was not declared in this scope
                         ifstates.top() = ALWAYS_FALSE;
                                          ^~~~~~~~~~~~
    externals/simplecpp/simplecpp.cpp:2857:46: error: 'ELSE_IS_TRUE' was not declared in this scope
                     } else if (ifstates.top() == ELSE_IS_TRUE && conditionIsTrue) {
                                                  ^~~~~~~~~~~~
    externals/simplecpp/simplecpp.cpp:2861:53: error: 'ELSE_IS_TRUE' was not declared in this scope
                     ifstates.top() = (ifstates.top() == ELSE_IS_TRUE) ? TRUE : ALWAYS_FALSE;
                                                         ^~~~~~~~~~~~
    externals/simplecpp/simplecpp.cpp:2861:76: error: 'ALWAYS_FALSE' was not declared in this scope
                     ifstates.top() = (ifstates.top() == ELSE_IS_TRUE) ? TRUE : ALWAYS_FALSE;
                                                                                ^~~~~~~~~~~~
    
     
  • Michael

    Michael - 2021-05-27

    I'm not a C++ expert. My research leads me to the assumption that TRUE is defined before. I tried something else and this file compiles:

    typedef char IfState;
    #define TRUE 1
    #define ELSE_IS_TRUE 2
    #define ALWAYS_FALSE 3
    
     

    Last edit: Michael 2021-05-27
    • Daniel Marjamäki

      I'm not a C++ expert.

      Great find! You found the problem before I did. I will have to adapt simplecpp because it's pretty common that TRUE is defined like that.

       
  • Michael

    Michael - 2021-05-27

    But the whole project still doesn't build. This is the whole cmake output:
    https://ghostbin.co/paste/49y7uk

     
    • Daniel Marjamäki

      Those error: no match for 'operator==' might perhaps be fixed if you use the match compiler;

      cmake -DUSE_MATCHCOMPILER=yes ..
      
       
      • Michael

        Michael - 2021-05-27

        With this flag and the IfState change it looks better now. Still some errors. Output attached.

         

        Last edit: Michael 2021-05-27
      • Michael

        Michael - 2021-06-16

        I tried to analyze the error:
        lib/standards.h:42:17: error: field 'stdValue' has incomplete type 'std::__cxx11::string' {aka 'std::__cxx 11::basic_string<char>'} std::string stdValue;

        I think it must be a configuration problem. A simple program #include <string> and std::string test; compiles without problems. Maybe the Makefile has to do something special on AIX?</string>

         
        • Daniel Marjamäki

          strange!
          standards.h does have a #include <string>.
          do you use some different compiler or compile flags then when you compile your little test program?
          do you get some interesting output when you try this command: g++ -fsyntax-only lib/standards.h.
          have you tried the Makefile in the root folder? what problems do you get with that?

           
          • Michael

            Michael - 2021-06-29

            Nothing special:

            bash-4.4$ git log -1 --oneline --no-color|cat
            b01c9267f 2.4.1: Set version
            bash-4.4$ g++ -fsyntax-only lib/standards.h
            bash-4.4$ 
            

            And my test program:

            bash-4.4$ cat test.cpp
            #include <string>
            #include <iostream>
            
            int main() {
                    std::string test;
                    test = "bla";
                    std::cout << test << std::endl;
                    return 0;
            }
            bash-4.4$ g++ test.cpp -o test
            bash-4.4$ ./test
            bla
            
             
            • Daniel Marjamäki

              so what g++ command generate that compiler error?

              lib/standards.h:42:17: error: field 'stdValue' has incomplete type 'std::__cxx11::string' {aka 'std::__cxx 11::basic_string<char>'} std::string stdValue;</char>

               
              • Michael

                Michael - 2021-06-29

                I can use the command from the build.log.

                g++ -Ilib -isystem externals -isystem externals/picojson -isystem externals/simplecpp -isystem externals/tinyxml2  -DFILESDIR=\"/usr/share/cppcheck\" -std=c++11 -O2 -DNDEBUG -Wall -Wno-sign-compare -std=c++11  -c -o build/analyzerinfo.o build/analyzerinfo.cpp
                
                In file included from /opt/freeware/lib/gcc/powerpc-ibm-aix7.2.0.0/8/include-fixed/wchar.h:44,
                                 from /opt/freeware/lib/gcc/powerpc-ibm-aix7.2.0.0/8/include/c++/cwchar:44,
                                 from /opt/freeware/lib/gcc/powerpc-ibm-aix7.2.0.0/8/include/c++/bits/postypes.h:40,
                                 from /opt/freeware/lib/gcc/powerpc-ibm-aix7.2.0.0/8/include/c++/bits/char_traits.h:40,
                                 from /opt/freeware/lib/gcc/powerpc-ibm-aix7.2.0.0/8/include/c++/string:40,
                                 from lib/config.h:60,
                                 from lib/analyzerinfo.h:24,
                                 from build/analyzerinfo.cpp:19:
                lib/standards.h:42:17: error: field 'stdValue' has incomplete type 'std::__cxx11::string' {aka 'std::__cxx11::basic_stri
                ng<char>'}
                     std::string stdValue;
                                 ^~~~~~~~
                In file included from /opt/freeware/lib/gcc/powerpc-ibm-aix7.2.0.0/8/include/c++/string:39,
                                 from lib/config.h:60,
                                 from lib/analyzerinfo.h:24,
                                 from build/analyzerinfo.cpp:19:
                /opt/freeware/lib/gcc/powerpc-ibm-aix7.2.0.0/8/include/c++/bits/stringfwd.h:71:11: note: declaration of 'std::__cxx11::s
                tring' {aka 'class std::__cxx11::basic_string<char>'}
                     class basic_string;
                           ^~~~~~~~~~~~
                [...]
                

                I also tried to use -std=c++x9, -std=c++17 and other flags but it didn't help.
                This command doesn't work too:

                g++ -Ilib -isystem externals -isystem externals/picojson -isystem externals/simplecpp -isystem externals/tinyxml2  -DFILESDIR=\"/usr/share/cppcheck\" -DNDEBUG -c -o build/analyzerinfo.o build/analyzerinfo.cpp
                
                 

                Last edit: Michael 2021-06-29
                • Daniel Marjamäki

                  ok I think this command will work better:

                  g++ -isystem externals -isystem externals/picojson -isystem externals/simplecpp -isystem externals/tinyxml2  -DFILESDIR=\"/usr/share/cppcheck\" -std=c++11 -O2 -DNDEBUG -Wall -Wno-sign-compare -std=c++11 -c lib/analyzerinfo.cpp
                  

                  Your error output:

                  In file included from /opt/freeware/lib/gcc/powerpc-ibm-aix7.2.0.0/8/include-fixed/wchar.h:44
                  

                  I guess that your wchar.h:44 includes a file "standards.h" and the wrong file is included.

                  Maybe it will be necessary to avoid the -Ilib completely when compiling cppcheck.. if you copy all source files in cli and lib to the same folder that should work. Something like:

                  python3 tools/matchcompiler.py
                  cp cli/* build/
                  cp lib/*.h build/
                  g++ -isystem externals -isystem externals/picojson -isystem externals/simplecpp -isystem externals/tinyxml2  -DFILESDIR=\"/usr/share/cppcheck\" -std=c++11 -O2 -DNDEBUG -Wall -Wno-sign-compare -std=c++11 build/*.cpp externals/tinyxml2/tinyxml2.cpp externals/simplecpp/simplecpp.cpp -o cppcheck
                  
                   

                  Last edit: Daniel Marjamäki 2021-06-29
                  • Michael

                    Michael - 2021-06-30

                    Thanks for that, Daniel. You're right. The wchar.h includes <standards.h>.
                    I copied all files that way and tried again.</standards.h>

                    At first, the build of analyzerinfo.cpp using your command doesn't have the string error anymore but another one:

                    In file included from lib/analyzerinfo.cpp:25:
                    externals/tinyxml2/tinyxml2.h:195:1: error: template with C linkage
                     template <class T, int INITIAL_SIZE>
                     ^~~~~~~~
                    externals/tinyxml2/tinyxml2.h:337:1: error: template with C linkage
                     template< int ITEM_SIZE >
                     ^~~~~~~~
                    externals/tinyxml2/tinyxml2.h:1896:5: error: template with C linkage
                         template<class NodeType, int PoolElementSize>
                         ^~~~~~~~
                    externals/tinyxml2/tinyxml2.h:1900:1: error: template with C linkage
                     template<class NodeType, int PoolElementSize>
                     ^~~~~~~~
                    

                    Using your last g++ command, this error came up multiple times on other files too. The TRUE enum error is there too. I assume this could be fixed easily. But the linkage error is in tinyxml2.h and picojson.h.
                    Attached is the whole build log using your last g++ command.

                     
  • Daniel Marjamäki

    Strange. Could you compress your folder /opt/freeware/lib/gcc/powerpc-ibm-aix7.2.0.0/8.1.0 and provide that?

     
    • Daniel Marjamäki

      I only need the include folders..

      /opt/freeware/lib/gcc/powerpc-ibm-aix7.2.0.0/8.1.0/include

      and

      /opt/freeware/lib/gcc/powerpc-ibm-aix7.2.0.0/8.1.0/include-fixed

       

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.