Gradle:在单元测试中链接已安装的CUnit版本

时间:2016-02-02 17:44:26

标签: c++ gradle cunit

我已经交换为gradle作为我的C ++新构建系统(虽然我之前使用它与java)。现在,当我尝试使用类似

的构建文件链接CUnit以获取测试用例时
g++ -Wall somefiles.c -o run "-I /full/path/name/name.framework -F /full/path/name/ -framework name"

我仍然从gradle获得以下输出:

apply plugin: 'cpp'
apply plugin: 'cunit'

model {
  platforms {
    x64 {
      architecture "x86_64"
    }
  }
  repositories {
    libs(PrebuiltLibraries) {
      cunit {}
    }
  }
  components {
    smartio(NativeLibrarySpec) {
      targetPlatform "x64"
      sources {
        cpp {
          source {
            srcDir 'src/smartio/cpp'
            include '**/*.cpp'
          }
          exportedHeaders {
            srcDir 'src/smartio/headers'
          }
        }
      }
    }
  }
  binaries {
    all {
      cppCompiler.args "-std=c++1y"
    }
    withType(CUnitTestSuiteBinarySpec) {
      lib library: "cunit", linkage: 'api'
    }
  }
}

基本上这告诉我,gradle似乎无法找到图书馆的cunit,但并不关心告诉我这件事。但是,当我从控制台构建它时,一切正常。我的示例测试文件,没什么特别的:

D:\\devel\\git\\SmartIO\\build\\objs\\smartioTestCUnitExe\\smartioTestCpp\\102afk7z0mm9rbcvlxwqfb3lp\\CUnitMain.obj:CUnitMain.cpp:(.text+0x4b): undefined reference to `CU_assertImplementation'
D:\\devel\\git\\SmartIO\\build\\objs\\smartioTestCUnitExe\\smartioTestCpp\\102afk7z0mm9rbcvlxwqfb3lp\\CUnitMain.obj:CUnitMain.cpp:(.text+0x4b): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `CU_assertImplementation'
// ... omitted for brevity
D:\\devel\\git\\SmartIO\\build\\objs\\smartioTestCUnitExe\\smartioTestCunitLauncher\\e5tc4yn4yrorgux3jajanhtly\\gradle_cunit_main.obj:gradle_cunit_main.c:(.text+0x22): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `CU_get_number_of_failures'
D:\\devel\\git\\SmartIO\\build\\objs\\smartioTestCUnitExe\\smartioTestCunitLauncher\\e5tc4yn4yrorgux3jajanhtly\\gradle_cunit_main.obj:gradle_cunit_main.c:(.text+0x3c): undefined reference to `CU_get_failure_list'

有人可以告诉我我错过了什么,以及我如何能够使用我系统上预装的cunit版本?

0 个答案:

没有答案