假設我有三個C源文件。前兩個是LIB(lib * .a?),第三個是使用它們的應用程序。在MinGW中靜態鏈接庫
首先是(re.c):
int re(int i) {
return i;
}
第二個是(test.c的):
int re(int); // Depends on re.c
int test(int i) {
return re(i);
}
而第三個是(main.c中):
#include<stdio.h>
int test(int); // Uses test.c
int main(void) {
printf("%d\n",test(0));
return 0;
}
現在我該如何創建前兩個LIB,以便我可以稍後將它們靜態鏈接到主應用程序?
我知道如何創建DLL和我的應用程序動態鏈接它們,例如:
CC -o re.dll re.c -shared -Wl, - 出IMPLIB = libre.a (for re.c)
cc -o test.dll test.c -L。 -lre -shared -Wl,-out-implib = libtest.a(for test.c)
cc -o main.exe main.c -L。 -lre -ltest
那麼如何來創建等同LIBS將靜態我在MinGW的可執行的二進制內聯,以及如何將其鏈接?
顯然,視窗:)下
我用過-static,但似乎沒用。不過,我沒有使用-mwindows。它是什麼? –
-mwindows指定gui應用程序,-mconsole是mingw中的控制檯應用程序。只是想知道這些是否有幫助。它還將Windows庫鏈接到應用程序,如果這些是缺少的。你有沒有嘗試使用dependencywalker來查看哪些失蹤? – rotator