Building error in ns3 with exit status 1:

Since you have not mentioned the ns3 and gcc versions. I've had the same issue earlier when I was trying to build an old version of ns3 (ns3.26 on Ubuntu 18) with new gcc compiler. I fixed this issue with the following commands:

CXXFLAGS="-Wall" ./waf configure
./waf -vv

You can find details on this link