iPhone - 为什么编译器不能找到一些建设ARM架构时,包括? [英] iPhone - Why can the compiler not find some includes when building for ARM architecture?

查看:149
本文介绍了iPhone - 为什么编译器不能找到一些建设ARM架构时,包括?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用一个C库在iPhone的项目。我非常绿色与iPhone的发展。
我的图书馆

I am trying to make use of a C library in an iPhone project. I am very green with iPhone development. My Library

我一直在争夺天了,试图让这个库建成,我可以使用两个模拟器(I386)和ARM7静态库。

I have been battling for days now to try and get this library build into a static library that I can use for both the simulator (i386) and ARM7.

使用图书馆的包括配置和生成文件,我可以构建库没有问题。但是如果我编辑Makefile,试图建立同样的库,但针对ARMv7架构,我得到许多错误。误差似乎报告说一些头文件不能被定位

Using the the library's include configuration and makefile I can build the library without issue. However if I edit the makefile to try and build this same library but target the armv7 architecture I get many errors. The errors seem to be reporting that some header files cannot be located.

所以该编译器试图寻找在不同的地方头文件根据目标架构?

So does the compiler attempt to look in different places for header files depending on the target architecture?

这是我编辑试图打造为ARMv7的生成文件:

This is the make file that I have edited to attempt to build for the armv7:

 # $Id: Makefile.in 62 2005-03-09 21:11:53Z gyunaev $
CC = /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/arm-apple-darwin10-gcc-4.2.1 
CFLAGS = -Wall -DIN_BUILDING_LIBIRC -O3 -DENABLE_THREADS -D_REENTRANT
AR=ar cr
RANLIB=ranlib
INCLUDES=-I../include


OBJS = libircclient.o

all:    lib

lib:    libircclient.a

install: lib
    -mkdir /usr/local/include
    -mkdir /usr/local/lib
    cp ../include/libircclient.h /usr/local/include/libircclient.h
    cp ../include/libirc_errors.h /usr/local/include/libirc_errors.h
    cp ../include/libirc_events.h  /usr/local/include/libirc_events.h 
    cp libircclient.a /usr/local/include/lib/libircclient.a

$(OBJS): utils.c dcc.c errors.c portable.c sockets.c colors.c

libircclient.a: $(OBJS)
    $(AR) libircclient.a $(OBJS)
    $(RANLIB) libircclient.a

clean:
    rm -f libircclient.a $(OBJS)

distclean: clean
    -rm -f Makefile

.c.o:
    @echo "Compiling  $<"
    @$(CC) $(CFLAGS) $(INCLUDES) -c -o $@ $<

下面是编译错误,我遇到的一个样本:

Here is a sample of the compilation errors I am experiencing:

Compiling  libircclient.c
In file included from /usr/include/sys/_types.h:33,
             from /usr/include/_types.h:27,
             from /usr/include/stdio.h:64,
             from portable.c:18,
             from libircclient.c:15:
/usr/include/machine/_types.h:36:24: error: arm/_types.h: No such file or directory
In file included from /usr/include/_types.h:27,
             from /usr/include/stdio.h:64,
             from portable.c:18,
             from libircclient.c:15:
/usr/include/sys/_types.h:94: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘__darwin_blkcnt_t’
/usr/include/sys/_types.h:95: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘__darwin_blksize_t’
/usr/include/sys/_types.h:96: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘__darwin_dev_t’

我要对所有这一切错了吗?正在编辑makefile文件哑巴? :)你怎么UNIX忍者处理这种情况?一些研究使我相信,我需要创建一个通用库...

Am I going about this all wrong? Is editing the makefile dumb? :) How do you unix ninjas handle this situation? Some research has lead me to believe that I need to create a universal library...

谢谢!

推荐答案

的问题是,在/ usr / include目录包含文件是为Mac OS X,而不是为iPhone / iPad的。如果你想要得到的东西的工作,你将不得不增加(至少)凯在她的评论...

The problem is that the include file in /usr/include are for Mac OS X, not for the iPhone/iPad. If you want to get things to work you will have to add (at least) the flags that Kay mentioned in her comment...

A 的更简单的方式去了解这是使用的是X code。只要创建一个新的项目(选择可可触摸静态库),并添加源文件。根据Makefile中,你将需要添加:utils.c dcc.c errors.c portable.c sockets.c colors.c

A much easier way to go about this is to use XCode. Just create a new project (choose the Cocoa Touch Static Library) and add the source files. According to the Makefile you will need to add: utils.c dcc.c errors.c portable.c sockets.c colors.c

希望这有助于。

您也可以看看 IRCClient 这是一个Objective-C的包装程序正在使用的库。没有点重新发明轮子!

You might also check out IRCClient which is a Objective-C wrapper for the library you are using. No point reinventing the wheel!

补充资料11年5月8日

ADDITIONAL INFORMATION 5/8/11

原来,Objective-C的包装是针对Mac OS X中没有的iOS

Turns out the Objective-C wrapper is aimed at Mac OS X not iOS

下面是你需要做的就是这个编译内容:

Here's what you need to do to get this to compile:

获取来源记忆犹新:

svn co https://libircclient.svn.sourceforge.net/svnroot/libircclient libircclient

更改到libircclient /主干/ libircclient / src目录,然后运行

Change into the libircclient/trunk/libircclient/src directory and run

./configure

请注意:这是一个略显肮脏的把戏。这真是配置的Mac OS X,但大部分时间的东西非常相似,这个工作。这会产生一个在包括所谓的config.h文件。

Note: this is a slightly dirty trick. This is really configuring for Mac OS X but most of the times things are similar enough for this to work. This generates a file called config.h in include.

火起来X code和选择创建一个新的可可触摸静态库。
当系统提示创建一个新的目录libircclient /主干/ libircclient / iOS和保存新的项目出现。

Fire up XCode and choose to create a new Cocoa Touch static library. When prompted create a new directory libircclient/trunk/libircclient/iOS and save the new project there.

从libircclient /主干/ libircclient / src中的文件libircclient.c添加到项目中。原来,该文件包含所有其他C文件。

Add the file libircclient.c from libircclient/trunk/libircclient/src to the project. It turns out that this file includes all the other C files.

打开项目设置并添加../../include你头搜索路径。

Open your project settings and add ../../include to you search header path.

建立和享受!

这篇关于iPhone - 为什么编译器不能找到一些建设ARM架构时,包括?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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