我試圖編譯一些混合的C和C代碼在圖像轉換器,在終端的mac上,我遇到了幾個錯誤。成像器轉換器的代碼可以在這裏找到:編譯器錯誤ptmconvert(C/C + +)
https://code.google.com/p/ptmconvert/
起初,C++編譯器是越來越挑剔的事實,有些文件是在C++中,有些是剛剛在C,這點我是能夠解決用在這裏找到了有條件定義的東西:
How do I add Objective C code to a FireBreath Project?
也就是說,我只是說#ifdef __OBJC__
... #endif
周圍的.h文件中,主要的.cpp代碼進口。
但是,我仍然從另一個包括兩個錯誤,我不知道是否是相同的問題或不同的問題。
的詳細描述包含兩個錯誤和一堆警告:
ptmconvert.cpp:236: error: ‘stbi_load_from_memory’ was not declared in this scope
ptmconvert.cpp:239: error: ‘stbi_failure_reason’ was not declared in this scope
和短錯誤如下:
ptmconvert.cpp:236:25: error: use of undeclared identifier
'stbi_load_from_memory'
planes[p] = stbi_load_from_memory(reinterpret_cast<unsigned ...
^
ptmconvert.cpp:239:17: error: use of undeclared identifier 'stbi_failure_reason'
if (stbi_failure_reason())
^
ptmconvert.cpp:242:35: error: use of undeclared identifier 'stbi_failure_reason'
ss << "(stb) " << stbi_failure_reason() << std::endl;
^
ptmconvert.cpp:326:53: error: use of undeclared identifier 'stbi_image_free'
std::for_each(planes.begin(), planes.end(), stbi_image_free);
^
ptmconvert.cpp:388:10: error: use of undeclared identifier 'stbi_write_png'
if (!stbi_write_png("coeffH.png", ptm->width, ptm->height, 3, ...
^
ptmconvert.cpp:391:10: error: use of undeclared identifier 'stbi_write_png'
if (!stbi_write_png("coeffL.png", ptm->width, ptm->height, 3, ...
^
ptmconvert.cpp:394:10: error: use of undeclared identifier 'stbi_write_png'
if (!stbi_write_png("rgb.png", ptm->width, ptm->height, 3, &rgbdata[0], 0))
^
7 errors generated.
如果是同樣的問題,我能添加其他條件某處,也許在stb_image.c文件中?
好的,所以評論包括是愚蠢的。不要這樣做,未來的讀者。現在我得到的錯誤是一些條款沒有被定義:
Undefined symbols for architecture x86_64:
"_stbi_failure_reason", referenced from:
ptm_read(char const*, PTMHeader12*) in ptmconvert-g4SsIR.o
"_stbi_image_free", referenced from:
ptm_read(char const*, PTMHeader12*) in ptmconvert-g4SsIR.o
"_stbi_load_from_memory", referenced from:
ptm_read(char const*, PTMHeader12*) in ptmconvert-g4SsIR.o
ld: symbol(s) not found for architecture x86_64
任何幫助/建議將不勝感激。
嘗試添加一些隨機charactors這對於編譯器裏的「未聲明」功能申報.h文件中的地方是非法的。檢查聲明是否正確包含。 – 2013-05-09 03:40:51
感謝您的建議@MIKU_LINK。這根本不會改變錯誤。這是否意味着'#ifdef __OBJC__'沒有註冊objective-c,因此不會導入程序的其他部分? – AlexB 2013-05-09 12:21:38