将c++封装到Objective-C中用于原生iOS开发



我正在尝试使用"swig"将已经编写的c++代码包装到Objective-C中。

这是我试图遵循的解决方案:link

基本上,我正在使用修改版本的swig,以便装入Objective-C。然而,在安装步骤中,我得到下面的错误信息;

clang: warning: argument unused during compilation: '-ansi'
Undefined symbols for architecture x86_64: "_swig_objectivec", referenced from:
modules in swigmain.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [eswig] Error 1
make[1]: *** [all] Error 2
make: *** [source] Error 2

在调查了错误信息"Modules/obj. js"后,我注意到什么?编译swig时没有创建O '文件。
然后我修改了我的"Makefile"。为对象添加了必要的行。现在swig创建'Modules/obj。然而,这次我得到的错误信息如下;

make[2]: *** No rule to make target `Modules/obj.cxx', needed by
`Modules/obj.o'.  Stop.
make[1]: *** [all] Error 2
make: *** [source] Error 2

任何帮助都将不胜感激。

编辑

为了得到上面列出的错误信息,我在给定的项目链接中做了一些文件更改。所以也许我遵循的第一步是错误的,所以这是我在一开始就得到的错误信息(顺便说一句,即使我配置了'automake'和'autoconf',我也一直得到给定的错误信息);

configure.ac:15: error: possibly undefined macro: AM_INIT_AUTOMAKE 
If this token and others are legitimate, please use m4_pattern_allow.
See the Autoconf documentation.
configure.ac:33: error: possibly undefined macro: AM_PROG_CC_C_O
configure.ac:35: error: possibly undefined macro: AC_COMPILE_WARNINGS
configure.ac:48: error: possibly undefined macro: AC_DEFINE
configure.ac:86: error: possibly undefined macro: AC_MSG_FAILURE
configure.ac:3041: error: possibly undefined macro: AC_DEFINE_DIR

对不起,我还不能评论,所以我把它放在这里。通过包装,你的意思是你想在你的objective-c应用程序中编译和使用c++框架/代码?如果是这样,我发现最简单和最可靠的方法是应用文件/框架,并设置项目编译器将语言视为objective-c++。这有道理吗?如果我没有理解问题,请告诉我:)

最新更新