如何“制造” c ++代码转换为xcode的库 [英] How to "make" c++ code into a library for xcode

查看:166
本文介绍了如何“制造” c ++代码转换为xcode的库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为了澄清澄清:
我知道如何使用obj-c或swift在Xcode中创建库。我知道如何使用这些在项目中。我知道如何编译这些项目,所以一切工作。我不知道是如何获取开源C源代码(hehe)和构建/ make /编译成库。

To clarify the clarification: I know how to create libraries in Xcode using either obj-c or swift. I know how to use these in projects. I know how to compile these projects so everything works. What I do not know is how to take open source C source code (hehe) and build/make/compile it into a library.

只是为了澄清以下内容:
我正在寻找一种方法在Swift应用程序中使用c库,这意味着使用Xcode。

Just to clarify everything below: I am looking for a way to use c libraries in a Swift application, this means using Xcode. The c libraries do no have to be build with/in Xcode, I am fine with using other tools.

我通常使用其他工具写所有的代码我用自己和不幸的是我只写Swift的Xcode。所以我有点背后使用框架/库。
现在我真的想探索Tesseract OCR,我在构建所需的库时遇到了麻烦。对我来说,最好是真正了解这是如何工作,并能够自己做,而不是只看Github和找到预编译的来源。

I normally write all the code I use myself and unfortunately I only write Swift in Xcode. So I am a little behind on using frameworks/libraries. Now I really want to explore Tesseract OCR and I am having trouble building the libraries needed. To me it is better to really understand how this works and be able to do this myself and not just look on Github and find pre-compiled sources.

下面的项目处理这个不同。 iOS版本使用预编译库。 (.a文件)OSX版本使用包含库文件(尚未编译)的项目。

The projects below both handle this differently. The iOS version uses precompiled Libraries. (.a file) The OSX version uses projects that contain the library files (not yet compiled).

iOS编译版

OSX编译版本

libjpeg 一个不能被拖放的库的示例。

libjpeg example of a library that can't be just dragged and dropped.

使用brew只会将其作为命令安装线工具,不生成库。

Using brew will only install it as a command line tool, not generate a lib.

安装Tesseract与自制

我的问题是,我知道太少关于这些c库,以及如何建立他们甚至谷歌这有效。

The problem I have is that I know too little about these c libraries, and how to build them to even google this effectively.

我的问题:


  • 如何编译/构建c代码a .a文件?

  • 如何创建一个基于
    的c代码构建框架的xcode项目? (可选)

  • 所有这些都是正确的词汇?

为Tesseract具体答案。我想学习如何自己这样做。

I am not looking for a Tesseract specific answer. I want to learn how to do this myself.

关于静态库

添加c程序并让xcode做它。关于工作区的部分很有趣。

This article doesn't mention how to actually add the c program and let xcode make it. The part about workspaces is interesting though.

在Xcode中构建c项目的文章

这实际上是真的相关。但是我找不到可执行文件在Tesseract例如。

This one is actually really relevant. However I can't find the executable in Tesseract for example. All options are greyed out when doing step 5.

这看起来很漂亮: simple c ++ procedct
为什么tesseract不能像这样? :)

This looks pretty : simple c++ procect Why can't tesseract look like that? :)

推荐答案

如果您要构建 Tesseract,请按照UNIX系统的说明进行操作: / p>

If you want to build Tesseract, follow the instructions for a UNIX system:

./autogen.sh
./configure
make
sudo make install
sudo ldconfig

你不需要,事实上你不应该使用xcode只是一个GUI /前端),但坚持每个库告诉你使用。在某些情况下,它可能可以用xcode构建。
打算使用xcode进行构建的项目往往包含一个xcode项目文件。

You don't have to, in fact you shouldn't use xcode (which is simply a GUI/frontend) but stick with what each library tells you to use. In some cases it might be possible to build with xcode. Projects that intend you to use xcode for their building, tend to include a xcode project file.

Apple的编译器是llvm / clang,与Linux的GNU gcc / g ++略有不同。

Apple's compiler is llvm/clang, so it may have some slight differences from Linux's GNU gcc/g++.

EDIT

首先安装leptonica和automake:

You need to first install leptonica and automake:

brew install automake
brew install leptonica

然后运行构建说明。
make install 期间,您会注意到库位于

Then run the building instructions. As you will notice during make install the library is in

/usr/local/lib/libtesseract.a

标题位于:

/usr/local/include/tesseract

从那里,它的一个问题在你的项目中使用它。
我在OSX Yosemite 10.10.5上用brew和命令行工具测试了这个。

From there on, its a matter of using it in your project. I tested this on OSX Yosemite 10.10.5 with brew and command line tools.

这篇关于如何“制造” c ++代码转换为xcode的库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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