Where can I find this header file: libc.h
I am using an external library that has a header starting with:
/* 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 IN开发者_StackOverflow中文版CLUDE_LIBC_H_AS_CXX
END_EXTERN_C
#endif
#endif
#endif
When I use it in an iPad project (device, debug) it raises a compile error:
libc.h: No such file or directory
Where does libc
exists in any of the frameworks that come with the iPhone SDK? Any other suggestions on how to fix this error ?
As far as I can see, libc.h doesn't exist in my SDK.
AFAIK, there's no such thing as libc.h. I've never seen such a thing. If libc.h existed, you'd expect to find a libc.c somewhere but you won't find that guy, either.
Instead, you must #include stdio.h, stdlib.h, string.h, ... . These header files hold definitions and declarations for functions that have been compiled and archived into libc.lib (or whatever your system's library extension is).
It would be very handy if there were a libc.h: it would help when I forget to #include some header or other. And you can of course make your own header file that does nothing but #include stdio.h, stdint.h, and so on; and you can name it whatever you like, maybe even libc.h.
But a /usr/include/libc.h (say) doesn't exist and it never will.
-- pete
You can find it here: http://www.opensource.apple.com/release/mac-os-x-1083/ Click on libc-825.26.
You might consider commenting out that code, though, since it seems from the comment it is not required for that library.
This is a common sort of problem when cross-compiling.
I don't know about the other answers saying that libc.h
doesn't exist; it very much exists - on my system (x86_64 running OS X 10.9.2) at least - in /usr/include/
. FWIW, here are the contents:
/*
* 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 */
As for what one of the answers says, "if libc.h existed, you'd expect to find a libc.c somewhere", that's not generally true (although perhaps the poster didn't intend it the way I read it); once a .c file has been compiled into an object file, you can definitely chuck the .c file; otherwise closed-source software (as we know it today) wouldn't exist!
精彩评论