I have a project that will not compile with gcc, whether or not that’s a good thing…it does compile with g++ and works just fine. I can’t seem to find much info and telling gradle which compiler to use.
What I have tried is putting this in my build.gradle
toolChains {
gcc (Gcc) {
path "/user/bin/g++"
}
}
The result is below, when I type which g++ on the terminal, it points to same path above, but gradle doesn’t like it.
> No tool chain is available to build for platform 'x64': Tool chain 'gcc' (GNU GCC):
- Could not find C++ compiler 'g++'. Searched in: /user/bin/g++
Is using g++ with gradle possible, and if so what am I doing wrong?
Thanks
That configures the C++ compiler to be an executable called “abc” for all platforms. You can target specific ones with target(). See the GCC tool chain documentation. You need to use an action that configures a GccPlatformToolChain.
Yes, toolChains is a container for ToolChains. By default, Gradle will create some tool chains if none are defined.
So we’re adding a ToolChain of type Gcc named ‘gcc’. Then we’re adding a configuration action that will configure each Gcc tool chain for each platform we can build. eachPlatform() gets a type of NativePlatformToolChain, which lets you configure each ‘tool’ (C++ compiler, linker, etc). Some of this is still in flux and will probably change again.
eachPlatform() was added recently, so you won’t be able to use that in 2.1. NativePlatformToolChain is new too, so I’m not sure you can accomplish the same thing in 2.1 with target(). I don’t remember if we expose the name of the executable as a configurable property in 2.1.