use argments
When we want to use some argments from source program to our program, if the argment define to simple, like “int arg;” you just find and copy them from source program,
custom data type
and if the argment have a custom data type such as “ext2_filsys”, and the data type is not in the source program, it is maybe **in certain header file or another program,**so,you have to do $find . -name “*.h” -print | xargs grep ext2_filsys , and check the header file of output, to find the ext2_filsys and maybe it is a struct, so,just copy whole defination,
and maybe the argment is in another program file, you have to do $find . -name “*.c” -print | xargs grep ext2_filsys, to find define ,and just copy
shell file
if there have shell file named is xxx.sh and there have some command in shell file like “gcc -o xx xx.c” so ,when we build the progarm we do $sh ./xxx.sh
underfined reference sth from .a file
and in the shell file we do the gcc things ,and if we had some error in the terminal like “/usr/bin/ld: 39.c:(.text+0x325): undefined reference to `com_err’”, we should go to the build/lib direcotory and do *$nm .a | com_err, to find which .a file has the com_err
and when we find the .a file ,add the file path to the shell file like “gcc -o xx xx.c ~/Downloads/path…/build/lib/libext2fs.a”
lack of library
there has another case: error in terminal like “/home/llxy/Downloads/e2fsprogs-1.46.5/build/lib/support/…/…/…/lib/support/plausible.c:241: undefined reference to `blkid_get_cache’” and we find there is no .a file include blkid so, it’s time to seek help from google, and we found it is a library named “blkid”, so add the -lblkid to the shell file. notice! -lblkid must after .a file ,like “gcc -o xx xx.c /home/llxy/Downloads/e2fsprogs-1.46.5/build/lib/ss/libss.a -lblkid”
linux gcc command
gcc -I diretorypath
means: Specify additional header file DIRECTORY search path.
|