[英]Compiling CImg with c++0x and MingW
我正在嘗試使用std = c ++ 0x和MingW編譯以下CImg示例代碼:
#include "CImg.h"
using namespace cimg_library;
int main() {
CImg<unsigned char> img(640,400,1,3);
img.fill(0);
unsigned char purple[] = { 255,0,255 };
img.draw_text(100,100,"Hello World",purple);
img.display("My first CImg code");
return 0;
}
當我編譯時使用:
g++ -std=c++0x HelloWorld.cpp -lgdi32
我收到以下錯誤:
error: '_fileno' was not declared in this scope
但是當我在沒有std = c ++ 0x的情況下編譯時,它完美地工作:
g++ HelloWorld.cpp -lgdi32
如何在啟用c ++ 0x的情況下編譯CImg?
我認為gnu++0x
或gnu++11
應該在GCC 4.5.x下可用,並且你應該能夠編譯CImg
並且可以使用C ++ 11(我剛剛在我自己的MinGW安裝下檢查過,但是我使用4.8。你能考慮升級嗎?)。 所以你可以簡單地使用:
g++ -o hello_world.exe HelloWorld.cpp -O2 -lgdi32 -std=gnu++0x
要么:
g++ -o hello_world.exe HelloWorld.cpp -O2 -lgdi32 -std=gnu++11
編輯
我剛剛檢查過-std=gnu++11
選項自GCC 4.7起可用,但我相信你應該可以在4.5.x下使用-std=gnu++0x
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.