Any tips on how to reduce the building/linking time on Linux?


I am learning Cinder by modifying the BasicApp example, but find it took about 10 seconds for this minimum example. After doing some research into the cmake files, I found the bottleneck seemed to be the library linking part.

INTERFACE_LINK_LIBRARIES "/usr/lib/x86_64-linux-gnu/;/usr/lib/x86_64-linux-gnu/;/usr/lib/x86_64-linux-gnu/;/usr/lib/x86_64-linux-gnu/;/usr/lib/x86_64-linux-gnu/;/usr/lib/x86_64-linux-gnu/;Xcursor;Xinerama;Xrandr;Xi;/usr/lib/x86_64-linux-gnu/;/usr/lib/x86_64-linux-gnu/;/usr/lib/x86_64-linux-gnu/;/usr/lib/x86_64-linux-gnu/;/usr/lib/x86_64-linux-gnu/;/usr/lib/x86_64-linux-gnu/;/usr/lib/x86_64-linux-gnu/;/usr/lib/x86_64-linux-gnu/;/usr/lib/x86_64-linux-gnu/;/usr/lib/x86_64-linux-gnu/;/usr/lib/x86_64-linux-gnu/;/usr/lib/x86_64-linux-gnu/;/usr/lib/x86_64-linux-gnu/;/home/yulong/Downloads/Cinder/lib/linux/x86_64//libboost_system.a;/home/yulong/Downloads/Cinder/lib/linux/x86_64//libboost_filesystem.a;dl;pthread"

It links to a bunch of libraries. Any good ideas to optimize the building time?



10 secs sounds quite a lot. Even on Xubuntu VM running on my MBP BasicApp takes less than that. What kind of system / hardware are you using?

There are a couple of things to try in case you haven’t yet. First would be to try clang++ as your compiler backend since it is faster than gcc. You can control this with the following cmake option -DCMAKE_CXX_COMPILER=clang++ Of course you will need to have clang installed for this to work.

Another option would be to try the Ninja backend. You can think Ninja as a faster replacement for the traditional Make. CMake can generate Ninja files for you. You will need to download Ninja, unzip it and move it under /usr/local/bin . Once you have done this you can build Cinder and samples by running cmake .. -G Ninja && ninja -j4 . This command asks CMake to generate the Ninja files and then it builds the project with ninja using 4 cores.

For the linking process specifically you could try out the gold linker. I haven’t tried it in quite some time now but I remember it being quite faster than the default GNU linker but with some shortcomings at that point.



Thank you Petros, I will follow your advice and have a try. I am running it on a 2011 laptop, i7 2600, nvidia g550m, with ubuntu 1604. even my 2014 13’’ i5 ultrabook outperforms its cpu. But it has a dedicate gpu I can play with.