Build C++ project with Gradle

(Rajeesh Rarankurissi) #1

I am trying to do C++ example in gradle
I am getting error as below


Total time: 2.896 secs
[thinkpalm@localhost gradle-cpp]$ gradle task

FAILURE: Build failed with an exception.

  • Where:
    Build file ‘/home/thinkpalm/Desktop/Gradle/gRADleC/gradle-cpp/build.gradle’ line: 4

  • What went wrong:
    A problem occurred evaluating root project ‘gradle-cpp’.

Could not find method libs() for arguments [build_5wi0mgh6d37hsdz5jn6d51naw$_run_closure1@71e26d] on root project ‘gradle-cpp’.

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

What might be reason ?? Any Idea ?

(David Cowden) #2

Based on the line number, I’m guessing your script looks something like:

apply plugin: 'cpp'
model {
    repositories {
        libs {

If that is the case you need to add the type of repository you’re trying to create e.g. PrebuiltLibraries as the first parameter:

apply plugin: 'cpp'
model {
    repositories {
        libs(PrebuiltLibraries) {

(Rajeesh Rarankurissi) #3

My build.gradle is as below

// build.gradle
apply plugin: ‘cpp’

libs {
hello {}
executables {
main {
binaries.all {
lib libraries.hello.shared
I tried your suggesion still have problem with
some functions as below
Could not find method executables()

Thanks in advance

(David Cowden) #4

Where is your model block?

(Rajeesh Rarankurissi) #5

HI David,

I am trying the below link example

(Rajeesh Rarankurissi) #6

It worked for me … Issue was with my Gcc++

Thanks for your Support

(Carlos) #7

Hi! That example url has been changed to