Difference between revisions of "HOWTO build old versions of ns-3 on newer compilers"

From Nsnam
Jump to: navigation, search
(update)
(update for CMake)
Line 1: Line 1:
 
{{TOC}}
 
{{TOC}}
  
ns-3 builds with the following flags by default"-Wall -Werror". This causes build warnings to trigger an error and stop the build.  This causes problems when trying to build older versions of ns-3 on newer systems with newer compilers, since over time, gcc gets more strict.
+
The build system was changed from Waf to CMake as of ns-3.36 release, and the behavior changed slightly with respect to this HOWTO, so two versions are provided below1) Waf-based builds (ns-3.35 and earlier) and 2) CMake-based builds (ns-3.36 and later)
  
To disable warnings from breaking your build, do the following:
+
== Waf-based builds ==
  
  CXXFLAGS="-Wall" ./waf configure
+
ns-3 with Waf builds with the following flags by default:  "-Wall -Werror". This causes build warnings to trigger an error and stop the build. This causes problems when trying to build older versions of ns-3 on newer systems with newer compilers, since over time, gcc and clang get more strict.
  ./waf -vv
+
  
Now you will observe that all files are built with -Wall and not -Werror; e.g.
+
Since ns-3.29 release, Waf included a configure option to disable the "Werror" flag; in this case, warnings will be emitted but they will not stop the build.
 +
 
 +
For ns-3.29 through ns-3.35 release, to disable warnings from breaking your build, do the following:
 +
 
 +
  ./waf configure --disable-werror ...(remainder of your configuration options, if any)
 +
  ./waf build
 +
 
 +
For ns-3 releases prior to ns-3.29, to disable warnings from breaking your build, do the following:
 +
 
 +
  CXXFLAGS="-Wall" ./waf configure ...(remainder of your configuration options, if any)
 +
  ./waf build
 +
 
 +
If you build with the "-vv" option you will observe that all files are built with -Wall and not -Werror; e.g.
  
 
   14:16:16 runner system command -> ['/bin/g++', '-Wall', '-fPIC', '-DPIC', '-Idebug', '-I..', '-DNS3_ASSERT_ENABLE',  
 
   14:16:16 runner system command -> ['/bin/g++', '-Wall', '-fPIC', '-DPIC', '-Idebug', '-I..', '-DNS3_ASSERT_ENABLE',  
Line 26: Line 37:
 
[http://code.google.com/p/waf/wiki/EnvironmentVariables This page] describes other tricks to configure how waf builds things.  Pass these flags at 'waf configure' time.
 
[http://code.google.com/p/waf/wiki/EnvironmentVariables This page] describes other tricks to configure how waf builds things.  Pass these flags at 'waf configure' time.
  
== Specific tips ==
+
== CMake-based builds ==
 +
 
 +
For CMake, there are three build profiles supported: 'optimized', 'default', and 'debug'.  Only the 'debug' build profile enables -Werror; therefore, for ns-3.36 and later releases, there should be fewer compilation blockers for users who use the 'default' or 'optimized' build profiles.
 +
 
 +
For the 'debug' build profile, the "--disable-werror" configuration argument is still available:
  
If there is a specific tip for getting past one of these types of issues, please enter it below:
+
  ./ns3 configure -d debug --disable-werror ...(remainder of your configuration options, if any)
 +
  ./ns3 build

Revision as of 20:09, 27 August 2022

Main Page - Current Development - Developer FAQ - Tools - Related Projects - Project Ideas - Summer Projects

Installation - Troubleshooting - User FAQ - HOWTOs - Samples - Models - Education - Contributed Code - Papers

The build system was changed from Waf to CMake as of ns-3.36 release, and the behavior changed slightly with respect to this HOWTO, so two versions are provided below: 1) Waf-based builds (ns-3.35 and earlier) and 2) CMake-based builds (ns-3.36 and later)

Waf-based builds

ns-3 with Waf builds with the following flags by default: "-Wall -Werror". This causes build warnings to trigger an error and stop the build. This causes problems when trying to build older versions of ns-3 on newer systems with newer compilers, since over time, gcc and clang get more strict.

Since ns-3.29 release, Waf included a configure option to disable the "Werror" flag; in this case, warnings will be emitted but they will not stop the build.

For ns-3.29 through ns-3.35 release, to disable warnings from breaking your build, do the following:

 ./waf configure --disable-werror ...(remainder of your configuration options, if any)
 ./waf build

For ns-3 releases prior to ns-3.29, to disable warnings from breaking your build, do the following:

 CXXFLAGS="-Wall" ./waf configure ...(remainder of your configuration options, if any)
 ./waf build

If you build with the "-vv" option you will observe that all files are built with -Wall and not -Werror; e.g.

 14:16:16 runner system command -> ['/bin/g++', '-Wall', '-fPIC', '-DPIC', '-Idebug', '-I..', '-DNS3_ASSERT_ENABLE', 
 '-DNS3_LOG_ENABLE', '-DNETWORK_SIMULATION_CRADLE', '-DNS3_MODULE_COMPILATION', '../src/common/spectrum-model.cc', 
 '-c', '-o', 'debug/src/common/spectrum-model_1.o']

You may run into other issues (such as missing header files) in trying to build on newer platforms. e.g.

 14:16:16 runner system command -> ['/bin/g++', '-Wall', '-fPIC', '-DPIC', '-Idebug', '-I..', '-DNS3_ASSERT_ENABLE', 
 '-DNS3_LOG_ENABLE', '-DNETWORK_SIMULATION_CRADLE', '-DNS3_MODULE_COMPILATION', '../src/common/spectrum-model.cc', '-c', 
 '-o', 'debug/src/common/spectrum-model_1.o']
 In file included from ../src/common/spectrum-model.cc:22:0:
 debug/ns3/spectrum-model.h:91:3: error: ‘size_t’ does not name a type

This particular error is due to a change in C++ STL; the STL headers no longer incorporate c-style headers, so one must include <cstddef> explicitly.

This page describes other tricks to configure how waf builds things. Pass these flags at 'waf configure' time.

CMake-based builds

For CMake, there are three build profiles supported: 'optimized', 'default', and 'debug'. Only the 'debug' build profile enables -Werror; therefore, for ns-3.36 and later releases, there should be fewer compilation blockers for users who use the 'default' or 'optimized' build profiles.

For the 'debug' build profile, the "--disable-werror" configuration argument is still available:

 ./ns3 configure -d debug --disable-werror ...(remainder of your configuration options, if any)
 ./ns3 build