私はライブラリを作成したり作成したりするのが初めてです。実行可能ファイルを作成中にlibを作成して後でリンクしようとしています。具体的には、構築システムを行うにはgradleを見てください。 私は、プロジェクトのフォルダ構造の下`WinMain @ 16 'エラーへの未定義の参照を避ける
NativeGradle(root folder)
src
build.gradle
(.h files are at)
NativeGradle\src\include -> includes (call.h and main.h)
source files (c files are at)
NativeGradle\src\atlas\call.c
NativeGradle\src\one\main.c
call.c:
#include "main.h"
#include "call.h"
void createSum()
{
printf("Sum is %d\n", sumMe(5,4));
}
main.c
#include <stdio.h>
#include <windows.h>
#include <stdlib.h>
#include "call.h"
int sumMe(int a, int b)
{
return (a+b);
}
int main()
{
printf("Hellow world !!\n");
createSum();
return 0;
}
call.h
#include <stdio.h>
#include "main.h"
void createSum(void);
main.h
#include <stdio.h>
int sumMe(int , int);
を持っていますし、以下の私は、エラー
c:/mingw/bin/../lib/gcc/mingw32/4.9.3/../../../libmingw32.a(main.o):(.text.startup+0xa7): undefined reference to `[email protected]'
collect2.exe: error: ld returned 1 exit status
:linkOutExecutable FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':linkOutExecutable'.
> A build operation failed.
Linker failed while linking out.exe.
See the complete log at: file:///C:/PROS/Training/NativeGradle/build/tmp/linkOutExecutable/output.txt
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
の下に取得gradle build
コマンドを与えた場合build.gradleは
apply plugin: 'c'
model {
components {
hello(NativeLibrarySpec) {
sources {
c {
source {
srcDirs "src/include"
include "call.h"
include "main.h"
srcDir "src/atlas"
include "*/call.c"
}
}
}
}
}
components {
out(NativeExecutableSpec) {
sources {
c {
source {
c.lib library: "hello"
srcDirs "src/include"
include "call.h"
include "main.h"
srcDir "src/one"
include "*/main.c"
}
}
}
}
}
}
task wrapper(type: Wrapper) {
gradleVersion = '2.3'
}
を使用していていますlinkOutExecutableコンテンツは
See file:///C:/PROS/Training/NativeGradle/build/tmp/linkOutExecutable/output.txt for all output for linkOutExecutable.
linking out.exe failed.
c:/mingw/bin/../lib/gcc/mingw32/4.9.3/../../../libmingw32.a(main.o):(.text.startup+0xa7): undefined reference to `[email protected]'
collect2.exe: error: ld returned 1 exit status
Finished linkOutExecutable, see full log file:///C:/PROS/Training/NativeGradle/build/tmp/linkOutExecutable/output.txt.
です
ありがとう
私は_Gradle_ファンではなく、コンパイル/リンクパラメータも表示されませんが、この種のエラーは通常、exe/dllの_subsystem_が正しくない場合に発生します。あなたの場合は、[_/SUBSYSTEM:CONSOLE_](https://msdn.microsoft.com/en-us/library/fcc1zstk(v = vs.100).aspx)を指定してリンカを選択してください(_/SUBSYSTEM:WINDOWS_デフォルトです)。 – CristiFati
まだこのプロジェクトを実行できません。どんなgradleのエキスパートが私に示唆することができる場合は感謝:) –