C ++与gradle [英] C++ with gradle

查看:613
本文介绍了C ++与gradle的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Gradle 1.10发行说明 http://www.gradle.org/docs/current / release-notes 我看到C ++ build。

In Gradle 1.10 Release notes http://www.gradle.org/docs/current/release-notes I see C++ build mentioned.

如何设置C ++项目用gradle构建? )

How to set up C++ project to build with gradle? (without IDE)

假设我有

ProjectFolder/hello.cpp
ProjectFolder/build.gradle

hello.cpp

#include <stdio.h>
#include <stdlib.h>

int main(void) {
    puts("Hello World!!!");
    return EXIT_SUCCESS;
}

基本 build.gradle be

What should basic build.gradle be for this C++ project?

更新:我已经看过用户指南第72章和提及的2岁的示例。它们不会使它更简单,但更复杂。

UPDATE: I have already looked at Chapter 72 of User Guide and 2 year old examples mentioned. They don't make it simpler but more complicated.

有6个文件示例,有6行。我没有触及C ++ 10年,我只是想快速启动,例如。与GCC。 (尚未找到)

There is 1 file example with 6 lines. I haven't been touching C++ for 10 year and I just wanted quick start e.g. with GCC . (Not yet found)

推荐答案




  1. put this in build.gradle

apply plugin: 'cpp'
executables {
   hello {}
}


  • 将源文件放在src / hello / cpp / say_hello.cpp

  • put your source file in src/hello/cpp/say_hello.cpp

    运行'gradle helloExecutable'

    run 'gradle helloExecutable'

    您的可执行文件应该构建为/ binaries / helloExecutable / hello

    your executable should be built to build/binaries/helloExecutable/hello

    或者,如果您想在src / foo / bar中使用源代码,请添加

    Or, if you want your source in src/foo/bar then add

    sources {
        hello {
          cpp {
            source {
                srcDir "src/foo/bar"
            }
        }
    }
    

    这篇关于C ++与gradle的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆