我试图编译一些混合的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