1. keil中的库文件是什么意思
广义的说,头文件也属于库文件的一种,当然,你所指的库文件是狭义的库文件。
那个库文件,相当于头文件与C文件的一种有机集合,他是这么制作出来的,举个例子来说:
当你写了一些C文件和头文件,这些C文件能够正确的编译,并能正确的生成Hex或者Bin代码文件,那么,你可以用Keil设置不输出Hex,而是生成Lib文件,也就是库文件,那么,你生成的这个库文件与你原来的C文件和头文件的功能完全相同,所不同的是,你这个库文件是只读的,也就是说,你可以利用里面的变量,利用里面的函数,但是你无法修改。
一些官方的库文件,比如ST公司的库文件也是这样生成的。
那么,库文件有什么意义呢?一是简化开发过程,试想一下,你开发一个工程,要加载数十乃至数百个C文件和头文件,与只加载一个等效功能的库文件,哪个省事?
而其最重要的一个意义就是保密性,由于库文件是只读的,且你看不到里面的具体内容,所以,如果你想保密,不想让别人知道你某些程序具体是如何实现的,那么,就可以用库文件,这样,别人可以使用你写好的程序,但是,他们既修改不了,同时也看不到具体的实现过程。
2. 如何制作lib库文件,头文件里应该写点什么
是在specs里面读取的路径信息。
命令行中键入 gcc -v reading specs from /usr/lib/gcc/i686-pc-cygwin/3.4.4/specs configured with: /usr/build/package/orig/test.respin/gcc-3.4.4-3/configure --ver bose --prefix=/usr --exec-prefix=/usr --sysconfdir=/etc --libdir=/usr/lib --libe xecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --enable-langu ages=c,ada,c++,d,f77,pascal,java,objc --enable-nls --without-included-gettext -- enable-version-specific-runtime-libs --without-x --enable-libgcj --disable-java- awt --with-system-zlib --enable-interpreter --disable-libgcj-debug --enable-thre ads=posix --enable-java-gc=boehm --disable-win32-registry --enable-sjlj-exceptio ns --enable-hash-synchronization --enable-libstdcxx-debug thread model: posix gcc version 3.4.4 (cygming special, gdc 0.12, using dmd 0.125) 注意“--prefix=/usr” 以及“--libdir=/usr/lib ” 表示gcc ld as 等可执行文件安装在/usr/bin,而libc.a 等文件是在/usr/lib中。 解压缩交叉编译器时,也是要解压缩在在--prefix 指定的目录下。
比如 下载了arm-linux 的交叉编译器cross-3.3.2.tar.bz2,解压缩之后,运行 arm-linux-gcc -v 得到 --prefix=/usr/local/arm。那么就要把 bin lib 等所有的文件和文件夹copy到/usr/local/arm目录下。
否则到时候运行arm-linux-gcc hello.c会提示找不到stdio.h 或者 lib.so.6 等 howto use the gcc specs file about specs file the "gcc" program invoked by users is a convenient front-end driver executable which will invoke other programs in the background such as cc1, as or ld to do its work according to the command line parameter given. a specs file is plain text used to control the default behavior for the "gcc" front-end. the specs file is usually built-in but for flexibility purposes, it can be overridden with an external version. basic specs file modifications cc will produce a specs file via the following command. gcc -dumpspecs > specs you may use a text editor of your choice to inspect it. it may be confusing at first, but there are many places of interest. to use the specs file, invoke gcc with -specs= or place it at "/mingw/lib/gcc/mingw32//specs" to make gcc use it by default, where refers to the gcc version installed. adding include directories to the search path & #160;he *cpp: section should be modified. it contains the following by default: *cpp: %{posix:-d_posix_source} %{mthreads:-d_mt} if "z:\libx\include" needs to be added to the gcc includes search path, it should be changed to the following *cpp: %{posix:-d_posix_source} %{mthreads:-d_mt} -i/z/libx/include adding lib directories to the search path & #160;he *link_libgcc: section should be modified. it contains the following by default: *link_libgcc: %d & #160;f "z:\libx\lib" needs to be added to the gcc library search path, it should be changed to the following *link_libgcc: %d -l/z/libx/lib。
3. 头文件和库文件在源代码的声明中哪个写在前面
你用库函数 肯定头文件在开始啊,因为要看到函数声明,编译器才能确定函数符号表,以使编译过程进行去。 对于库,现在基本都是动态库,以windows为例,它们都是PE文件,关键是导出表的符号名。这个是要写入生成的PE文件的,因为程序有pe loader加载的时候,需要知道使用的导出函数的名,以便确认库函数的实际虚拟内存地址。 这个过程是链接,链接技术不只是简单的在编译后的链接,还指运行时的链接,因为库是有链接器 linker来完成的,所以在源码中写在哪里都好了。。一般都是写在头上 比如 #pragma comment(lib, "ws2_32.lib")
API函数的声明文件,一般在VC的include目录中,一般加上 windows.h就差不多了,但是有些函数 比如ShellExecuteEx,这个就需要shellapi.h头文件,具体则需要查询MSDN。
函数的代码,都在DLL文件。正是因为此,很多高手都会查询DLL文件的导出函数,以便发现MSDN没有的函数。
4. 头文件和库文件有何区别和联系
头文件中有函数的申明,库文件实现函数的定义。
比如,printf函数。使用时应包括stdio.h,打开stdio.h你只能看到,printf这
个函数的申明,却看不到printf具体是怎么实现的,而函数的实现在相应的C库
中。而库文件一般是以二进制形式而不是C源文件形式提供给用户使用的。程序
中包括了stdio.h这个头文件。链接器就能根据头件中的信息找到printf这个函
数的实现并链接进这个程序代码段里。
总结起来就是,库文件通过头文件向外导出接口。用户通过头文件找到库文件中
函数实现的代码从而把这段代码链接到用户程序中去。
5. c语言头文件怎么写呀
C++/C程序的头文件以“.h”为后缀。
以下是假设名称为graphics.h的头文件:#ifndef GRAPHICS_H//作用:防止graphics.h被重复引用#define GRAPHICS_H#include<。.>//引用标准库的头文件。
#include"。"//引用非标准库的头文件。
void Function1(。);//全局函数声明。
inline();//inline函数的定义。classBox//作用:类结构声明{。
};#endif从以上例子可以看出,头文件一般由四部分内容组成:(1)头文件开头处的版权和版本声明;(2)预处理块;(3)inline函数的定义;(4)函数和类结构声明等。在头文件中,用ifndef/define/endif结构产生预处理块,用#include格式来引用库的头文件。
头文件的这种结构,是利用C语言进行开发软件所通常具备的,属于公有知识。传统 C++:扩展资料:c语言头文件的作用:1、头文件可以定义所用的函数列表,方便查阅你可以调用的函数;2、头文件可以定义很多宏定义,就是一些全局静态变量的定义,在这样的情况下,只要修改头文件的内容,程序就可以做相应的修改,不用亲自跑到繁琐的代码内去搜索。
3、头文件只是声明,不占内存空间,要知道其执行过程,要看你头文件所申明的函数是在哪个.c文件里定义的,才知道。4、他并不是C自带的,可以不用。
5、调用了头文件,就等于赋予了调用某些函数的权限,如果你要算一个数的N次方,就要调用Pow()函数,而这个函数是定义在math.c里面的,要用这个函数,就必需调用math.h这个头文件。参考资料:百度百科——头文件。