「-static-libgcc」これをつけると、libgcc_s_dw2-1.dllを配布しなくてすむ
コンソール
$ g++ --version
g++.exe (GCC) 4.4.0
Copyright (C) 2009 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ ls -l Hello.cpp
-rw-r--r-- 1 takumakei Administrators 97 Mar 11 13:00 Hello.cpp
$ cat Hello.cpp
#include
int main() {
std::cout << "Hello world" << std::endl;
return 0;
}
$ g++ -o Hello -O3 Hello.cpp -static-libgcc
$ ls -l Hello.exe
-rwxr-xr-x 1 takumakei Administrators 3862265 Mar 11 13:56 Hello.exe*
$ strip Hello.exe
$ ls -l Hello.exe
-rwxr-xr-x 1 takumakei Administrators 496142 Mar 11 13:56 Hello.exe*
$ ./Hello.exe
Hello world
ウィンドウ
$ ls -l HelloW.cpp
-rw-r--r-- 1 JP10007 Administrators 150 Mar 11 13:34 HelloW.cpp
$ cat HelloW.cpp
#include
int WINAPI WinMain(HINSTANCE, HINSTANCE, LPTSTR, int) {
MessageBox(NULL, "Hello world", "HelloW", MB_OK);
return 0;
}
$ g++ -o HelloW.exe -O3 HelloW.cpp -static-libgcc -mwindows
$ ls -l HelloW.exe
-rwxr-xr-x 1 JP10007 Administrators 334435 Mar 11 13:59 HelloW.exe*
$ strip HelloW.exe
$ ls -l HelloW.exe
-rwxr-xr-x 1 JP10007 Administrators 75790 Mar 11 13:59 HelloW.exe*
0 件のコメント:
コメントを投稿