Build C++ project with Gradle

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

BUILD FAILED

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 ?

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) {
            ...

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

Where is your model block?

HI David,

I am trying the below link example

http://carlosvin.github.io/en/posts/gradle-cpp.html

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

Thanks for your Support

Hi! That example url has been changed to http://carlosvin.github.io/posts/gradle-cpp/