0
我想從gradle移動到maven。這是我簡單的hello world示例構建。我的gradle.build如下: -本機構建使用gradle失敗
apply plugin: 'cpp'
model {
components {
main(NativeExecutableSpec) {}
}
}
我有一個cpp文件和一個h文件。目錄結構爲如下: -
src/main/cpp/HelloWorld.cpp
src/main/headers/HelloWorld.h
我的頭文件是爲如下: -
// Hello.h
#if defined(_WIN32) && defined(DLL_EXPORT)
#define LIB_FUNC __declspec(dllexport)
#else
#define LIB_FUNC
#endif
class LIB_FUNC Hello
{
private:
const char * who;
public:
Hello(const char * who);
void sayHello(unsigned n = 1);
};
和我的源代碼如下: -
// main.cpp
#include "Hello.h"
int main(int argc, char ** argv)
{
Hello hello ("Pepito");
hello.sayHello(10);
return 0;
}
當我嘗試運行gradle installMainExecutable出現以下錯誤: -
HelloWorld.obj : error LNK2019: unresolved external symbol "public: __thiscall Hello::Hello(char const *)" ([email protected]@[email protected]@Z) referenced in function _main
HelloWorld.obj : error LNK2019: unresolved external symbol "public: void __thiscall Hello::sayHello(unsigned int)" ([email protected]@@[email protected]) referenced in function _main
我正在使用visual studio 2012,無論cl.exe如何。我讓我的朋友在OSx中用clang ++進行編譯,並且爲他工作。我不知道什麼是錯的。有人可以幫忙嗎?
我gradle這個版本: -
------------------------------------------------------------
Gradle 2.4
------------------------------------------------------------
Build time: 2015-05-05 08:09:24 UTC
Build number: none
Revision: 5c9c3bc20ca1c281ac7972643f1e2d190f2c943c
Groovy: 2.3.10
Ant: Apache Ant(TM) version 1.9.4 compiled on April 29 2014
JVM: 1.8.0_45 (Oracle Corporation 25.45-b02)
OS: Windows 7 6.1 amd64