[英]How to use CImg in Objective C / XCode?
I know that clang can compile C++ files as .mm
, but CImg comes as just an individual .h
file. 我知道clang可以将C ++文件编译为
.mm
,但是CImg只是一个单独的.h
文件。 Regardless if I change the extension to .mm
or keep it as .h
, it doesn't work. 无论我将扩展名更改为
.mm
还是将其保留为.h
,它均不起作用。
First, it complains that it can't find cstdio.h
. 首先,它抱怨找不到
cstdio.h
。 As a result, I changed all the cstd..
imports to their c counterpart as a 结果,我将所有
cstd..
导入更改为它们的c对应项,作为
// Include standard C++ headers.
// This is the minimal set of required headers to make CImg-based codes compile.
#include <stdio.h> // (was #import <cstdio>)
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <math.h>
#include <time.h>
#include <exception.h>
After bringing in the x11 library, I get past the import errors into syntax errors: 引入x11库后,我克服了导入错误而变成语法错误:
namespace cimg_library_suffixed {
Error: Unknown type name 'namespace' 错误: 未知类型名称“命名空间”
Is this because I changed cstdio
to stdio
? 这是因为我将
cstdio
更改为stdio
吗? I'm confused.. 我糊涂了..
The solution in answer form for future reference: 答案形式的解决方案,以供将来参考:
Compile the file the header is #include
d from as Obj-C++ and the header will get treated as C++ code. 以Obj-C ++的形式编译标头为
#include
d的文件,标头将被视为C ++代码。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.