CPP - Can I compile without linking?

I would like to have gradle compile my native sources (linux cpp) to create the .o files, but not build an executable or a library. Is there an easy way to achieve this? Or do I need to specify “executable”, but just not have a main() function?

There are a couple of ways you can do this. Although it’s possible to apply just the ‘org.gradle.nativebinaries.plugins.NativeBinariesModelPlugin’ and create and configure a CppCompile task to do just the compilation, it’s not trivial to get an instance of ToolChain and Platform to use.

I would instead recommend defining an executable or library, and simply calling the appropriate compile task(s).