库文件怎么写

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 。