Cmake failed in AWS ubuntu 16.04 - recipe for target 'scripting_environment_lua.cpp.o' failed
I ran sudo apt-get already in https://github.com/Project-OSRM/osrm-backend/wiki/Building-on-Ubuntu and it succeed.
ubuntu:~/osrm-backend/build$ cmake --build . Scanning dependencies of target FingerPrintConfigure [ 1%] Configuring revision fingerprint [ 1%] Built target FingerPrintConfigure Scanning dependencies of target UTIL [ 1%] Building CXX object CMakeFiles/UTIL.dir/src/util/name_table.cpp.o [ 3%] Building CXX object CMakeFiles/UTIL.dir/src/util/simple_logger.cpp.o [ 4%] Building CXX object CMakeFiles/UTIL.dir/src/util/coordinate_calculation.cpp.o [ 6%] Building CXX object CMakeFiles/UTIL.dir/src/util/fingerprint.cpp.o [ 6%] Building CXX object CMakeFiles/UTIL.dir/src/util/hilbert_value.cpp.o [ 7%] Building CXX object CMakeFiles/UTIL.dir/src/util/assert.cpp.o [ 9%] Building CXX object CMakeFiles/UTIL.dir/src/util/geojson_debug_policies.cpp.o [ 9%] Building CXX object CMakeFiles/UTIL.dir/src/util/exception.cpp.o [ 10%] Building CXX object CMakeFiles/UTIL.dir/src/util/coordinate.cpp.o [ 12%] Building CXX object CMakeFiles/UTIL.dir/src/util/guidance/turn_bearing.cpp.o [ 13%] Building CXX object CMakeFiles/UTIL.dir/src/util/guidance/entry_class.cpp.o [ 13%] Building CXX object CMakeFiles/UTIL.dir/src/util/guidance/bearing_class.cpp.o [ 15%] Building CXX object CMakeFiles/UTIL.dir/src/util/guidance/turn_lanes.cpp.o [ 15%] Built target UTIL Scanning dependencies of target EXTRACTOR [ 16%] Building CXX object CMakeFiles/EXTRACTOR.dir/src/extractor/raster_source.cpp.o [ 18%] Building CXX object CMakeFiles/EXTRACTOR.dir/src/extractor/edge_based_graph_factory.cpp.o [ 19%] Building CXX object CMakeFiles/EXTRACTOR.dir/src/extractor/extractor_callbacks.cpp.o [ 19%] Building CXX object CMakeFiles/EXTRACTOR.dir/src/extractor/extractor.cpp.o [ 21%] Building CXX object CMakeFiles/EXTRACTOR.dir/src/extractor/scripting_environment_lua.cpp.o c++: internal compiler error: Killed (program cc1plus) Please submit a full bug report, with preprocessed source if appropriate. See file:///usr/share/doc/gcc-5/README.Bugs for instructions. CMakeFiles/EXTRACTOR.dir/build.make:158: recipe for target 'CMakeFiles/EXTRACTOR.dir/src/extractor/scripting_environment_lua.cpp.o' failed make[2]: *** [CMakeFiles/EXTRACTOR.dir/src/extractor/scripting_environment_lua.cpp.o] Error 4 CMakeFiles/Makefile2:214: recipe for target 'CMakeFiles/EXTRACTOR.dir/all' failed make[1]: *** [CMakeFiles/EXTRACTOR.dir/all] Error 2 Makefile:127: recipe for target 'all' failed make: *** [all] Error 2
c++: internal compiler error: Killed (program cc1plus)
Before we try to dig deeper here:
- try to reproduce the problem
- check
dmesgfor out of memory issues (oom-killer, if in doubt upload last ~50 lines) - if the compiler is getting killed by the oom killer, provide a spawfile (similar to what is described here)
I think it's likely the memory issue, will update here once I solve it, thanks!
It's solved by increasing the memory. It was 2GB.
Glad I could help!
Unfortunately there aren't better error messages since the Linux oom-killer does a hard shutdown.
@nnthing were you running a t2.small instance? I am getting the same error so I assume moving up to a medium solved this for you?
Creating a swap file (e.g. as documented here) should help in low-memory situations.
Also link-time optimization (LTO) is quite expensive especially with GCC. You can disable it in case this is causing your box to go oom:
cmake .. -DENABLE_LTO=OFF
I have gotten this same error and am currently on my 5th time trying to make install. I have increased my swap to 4G and ran cmake with the -DENABLE_LTO=OFF switch. Help!!
If you have the message c++: internal compiler error: Killed (program cc1plus) anywhere in your log output, then you do not have enough memory - there is no workaround.
Which log are you referring to? dmesg does not contain this error.
dmesg | grep "program cc1plus"
This is what it looks like currently

@billystalnaker that is not enough information, you've cut off the important bits. Can you copy/paste the complete log please?
@danpat I apologize, it's currently running and that's as far as it has gotten. Truth be told this is the furthest I have gotten so far.
@billystalnaker if you're close to using up all your RAM, then yes, it could stop at any point. If you see the message 'Killed' anywhere in the output of the make command, then this is a good sign that you don't have enough memory.
Compiling C++ projects can require quite a lot of resources. Make sure you're only executing 1 concurrent build command by doing make -j1 - this slows things down, but ensures the build uses the minimum RAM amount.
@danpat Thank you sir, I'm checking my swap file every so often with swapon -s and it has yet to use all of it. So I'll keep an eye on it and look for the "Killed" word anywhere in the output if it dies. Thanks!
@danpat Is there a normal make install time for this project? I'm sitting at 25 minutes so far..
@billystalnaker it depends on your machine capabilities. I build the project regularly on a 2015 Macbook Pro with 16GB of RAM - it takes about 6 minutes with make -j2. Follow-up builds are faster due to caching.
If you've exceeded your real RAM and are using swap, you can expect a rapid decrease in compile performance.
If you're not developing, you can try using the docker images I've been building at hub.docker.com/r/osrm/osrm-backend/
@danpat Thank you for that, I am using a LOT of swap so that would explain the long build time.