我正在尝试在终端的 Mac 上为图像转换器编译一些混合的 C++ 和 C 代码,但遇到了几个错误。成像器转换器代码可在此处获得:
https://code.google.com/p/ptmconvert/
起初,c++ 编译器对有些文件在 c++ 中而有些只是在 c 中这一事实变得很挑剔,我可以使用此处找到的条件定义来解决这个问题:How do I add Objective C code to a FireBreath项目?
也就是说,我只是在主 .cpp 代码导入的 .h 文件周围添加了#ifdef __OBJC__
... 。#endif
但是,我仍然从另一个包含中得到两个错误,我不知道这是同一个问题还是不同的问题。
详细描述包含两个错误和一堆警告:
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
任何帮助/建议将不胜感激。