I'm trying to compile some mixed C++ and C code on a mac in the terminal for an image converter, and I'm running into several errors. The imager converter code is available here:
https://code.google.com/p/ptmconvert/
At first the c++ compiler was getting fussy about the fact that some of the files are in c++ and some are just in c, which I was able to fix using the conditional definition thing found here: How do I add Objective C code to a FireBreath Project?
That is, I just added #ifdef __OBJC__
... #endif
around the .h file that the main .cpp code imports.
However, I'm still getting two errors from another include, and I can't figure out if it's the same issue or a different one.
The verbose description contains two errors and a bunch of warnings:
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
And the short errors are as follows:
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.
If it's the same issue, can I just add another conditional somewhere, perhaps in the stb_image.c file?
Ok, so commenting out the include was dumb. Don't do that, future readers. Now the error I'm getting is that some of the terms aren't defined:
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
Any help/suggestions would be most appreciated.