gcc notes - rolltolev/SpeedThrill GitHub Wiki

Compiling with GCC

Check your gcc version before installing torcs. If it is gcc-6 or later then the default C++ standard is c++14 and you should be fine building torcs, fuzzylite and car111 without doing any setting for C++ standard (though you would still need to apply patches described in installing torcs wiki page).

For compiling with gcc-5, the default C++ standard is c++98 but you should change the standard to c++11.

gcc-5 with c++11 (or c++14)

Here are some of the notes to keep in mind if you use gcc-5 with c++11 standard :

  • Fuzzylite should compile smoothly as it uses c++11 for its default build.

  • car111 should also compile without error.

  • For compiling torcs, append the c++11 std option while running configure

    ./configure "CXXFLAGS=-std=c++11"
    
  • You will get few more namespace errors for isnan while building torcs (which you do not get in gcc-6 and later versions as there is an additional math.h that fixes this error).

    • Additional files that will have these errors probably would be

      • src/libs/learning/policy.cpp
      • src/drivers/olethros/driver.cpp
    • You can fix the errors by adding patch similar to gcc_isnan patch for src/drivers/olethros/geometry.cpp (by adding std namespace to isnan)

      #if __cplusplus
          using std::isnan;
      #endif
      

gcc-5 with c++98

First of all it is not a recommended setting as car111 is not strictly c++98 compliant. But if you want to use gcc-5 with its default c++98 standard for building all the sources then here are few things to know :

  • For compiling Fuzzylite with c++98 first add a variable FL_CPP98=ON to the shell environment and then run the build script of the Fuzzylite as shown :
export FL_CPP98=ON
cd path/to/fuzzylite
./build.sh release    # for building the release version
  • While compiling car111 with make, pass the preprocessor symbol FL_CPP98 in COMPILFLAGS (this flag is empty here) to let the Fuzzylite header files in car111 use its appropriate macros.
make "COMPILFLAGS=-DFL_CPP98"

You will get few gcc warnings for c++11 syntax here but you will get your binaries.