我在哪里可以找到这个头文件:libc.h

时间:2011-02-16 09:12:34

标签: iphone ios objective-c++

我正在使用一个外部库,其头部以:

开头
/* Headers other than ISO C++, such as BSD and Posix.1 headers */

// define INCLUDE_LIBC to include <libc.h> if available
#ifdef INCLUDE_LIBC
#ifdef HAVE_LIBC_H
#ifndef INCLUDE_LIBC_H_AS_CXX
BEGIN_EXTERN_C
#endif
#include <libc.h>
#ifndef INCLUDE_LIBC_H_AS_CXX
END_EXTERN_C
#endif
#endif
#endif

当我在iPad项目(设备,调试)中使用它时,会引发编译错误:

libc.h: No such file or directory

iPhone SDK附带的任何框架中都存在libc?关于如何解决此错误的任何其他建议?

4 个答案:

答案 0 :(得分:0)

据我所知,我的SDK中不存在libc.h。

答案 1 :(得分:0)

AFAIK,没有libc.h这样的东西。我从未见过这样的事情。如果存在libc.h,你可能会在某个地方找到一个libc.c,但你也找不到那个人。

相反,你必须#include stdio.h,stdlib.h,string.h,....这些头文件包含已编译和存档到libc.lib(或任何系统的库扩展名)的函数的定义和声明。

如果 一个libc.h会非常方便:当我忘记#include某些标题或其他时,它会有所帮助。你当然可以制作你自己的头文件,什么都不做 但是 #include stdio.h,stdint.h等等;你可以随意命名,甚至可以命名为libc.h。

但是/usr/include/libc.h(比如说)不存在,它永远不会存在。

- 皮特

答案 2 :(得分:0)

你可以在这里找到它:http://www.opensource.apple.com/release/mac-os-x-1083/点击libc-825.26。

但是,您可能会考虑注释掉该代码,因为从注释中可以看出该库不是必需的。

交叉编译时,这是一种常见的问题。

答案 3 :(得分:0)

我不知道其他答案说libc.h不存在;它至少存在 - 至少在我的系统(运行OS X 10.9.2的x86_64)上 - 在/usr/include/中。 FWIW,以下是内容:

    /*
 * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
 *
 * @APPLE_LICENSE_HEADER_START@
 * 
 * This file contains Original Code and/or Modifications of Original Code
 * as defined in and that are subject to the Apple Public Source License
 * Version 2.0 (the 'License'). You may not use this file except in
 * compliance with the License. Please obtain a copy of the License at
 * http://www.opensource.apple.com/apsl/ and read it before using this
 * file.
 * 
 * The Original Code and all software distributed under the License are
 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
 * Please see the License for the specific language governing rights and
 * limitations under the License.
 * 
 * @APPLE_LICENSE_HEADER_END@
 */
/*
 * Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved
 */

#ifndef _LIBC_H
#define _LIBC_H

#include <stdio.h>
#include <unistd.h>

#ifdef  __STRICT_BSD__
#include <strings.h>
#include <varargs.h>
#else
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include <stdarg.h>
#endif

#include <sys/param.h>
#include <sys/mount.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/time.h>
#include <sys/times.h>
#include <sys/resource.h>
#include <signal.h>
#include <sys/time.h>
#include <sys/stat.h>
#include <sys/file.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <mach/machine/vm_types.h>
#include <mach/boolean.h>
#include <mach/kern_return.h>

struct qelem {
        struct qelem *q_forw;
        struct qelem *q_back;
        char *q_data;
};

#include <sys/cdefs.h>

__BEGIN_DECLS
extern kern_return_t map_fd(int fd, vm_offset_t offset,
        vm_offset_t *addr, boolean_t find_space, vm_size_t numbytes);
__END_DECLS

#endif  /* _LIBC_H */

至于其中一个答案是什么,“如果存在libc.h,你希望在某个地方找到一个libc.c”,这通常不正确(尽管海报并不像我读到的那样打算这样做它);一旦.c文件被编译成目标文件,你肯定可以放弃.c文件;否则闭源软件(我们今天所知)就不存在了!

相关问题