使XCode包含,编译和链接XCode 4.3(.1)中的现有(C ++)代码库 [英] Getting XCode to include, compile and link existing (C++) codebase in XCode 4.3(.1)

查看:204
本文介绍了使XCode包含,编译和链接XCode 4.3(.1)中的现有(C ++)代码库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图将现有的C ++代码库导入到我的XCode iOS项目中。



问题是,xCode不会编译我的代码。
这是我到目前为止做的:




  • 文件>将文件添加到项目。我不要勾选复制文件,因为它是多个平台的共享代码库,并且不能选择多个源代码副本。

  • 我已经为标题搜索路径项目设置。包括头文件工作,我可以#include从我的Objective-C ++(.mm)文件的stuff.h。



我找不到任何方法实际上告诉XCode编译.cpp文件?



以下几点:




  • 我没有找到办法预编译成库并以此方式连接

  • 该项目是一个标准的iOS Objective-C项目。从中调用C ++代码(这不是问题)



更新
$ b

我已将代码库目录添加到目标的编译源。我实际上必须在弹出的对话框中单击添加其他...,因为我无法选择对我的代码库的目录引用。



当我添加它,XCode询问我是否要创建外部构建系统项目。我离开它,并且默认值为/ usr / bin / make和$(ACTION)的两个字段。但是,我的代码库不会在编译期间编译。我必须写我自己的Makefile吗?



如果我没有选择创建外部构建系统项目,则在目标下创建目录引用,但在构建期间不编译,并发出警告:

 警告:没有规则处理文件夹的$(PROJECT_DIR)/../ codebase'
架构i386


解决方案

即使不检查复制文件,您必须在向项目中添加文件时检查添加到目标





如果您忘记这样做,您可以选择目标,请转到构建阶段标签,并将文件添加到编译源

http://i.stack.imgur.com/Vsmy5.pngalt =enter image description here>


I'm trying to 'import' my existing C++ codebase into my XCode iOS project.

Problem is, xCode won't compile (and therefore not link) my code. This is what I've done so far:

  • File > Add files to "Project". I don't tick 'Copy files' since it's a shared codebase for multiple platforms and multiple copies of source code is not an option.
  • I've added appropriate path to the "Header Search Path" project settings. Including header files works, I can #include "stuff.h" from my Objective-C++ (.mm) file.

However, I can't find any way of actually telling XCode to compile the .cpp files?

A few points:

  • I'm not looking for a way to pre compile it into a library and linking that way
  • The project is a standard iOS Objective-C project. The C++ code is called from it (that's not a problem)

Update

I've added the codebase directory to the target's "Compile Sources". I actually have to click "Add other..." in the dialog that pops up, since I can't select the directory reference to my codebase.

When I add it, XCode asks me if I want to "Create external build system project". I leave it ticked and the two fields with the default values "/usr/bin/make" and "$(ACTION)". However, my codebase doesn't get compiled during the build. Do I have to write my own Makefile ?

If I don't select "Create external build system project" then a directory reference is created under the target, but not compiled during the build and a warning is emitted:

warning: no rule to process file '$(PROJECT_DIR)/../codebase'
of type folder for architecture i386

解决方案

Even if you don't check Copy Files you have to check Add to Targets when adding the files to the project.

If you forgot to do that, you can select the target, go to the Build Phases tab and add the files to Compile Sources.

这篇关于使XCode包含,编译和链接XCode 4.3(.1)中的现有(C ++)代码库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆