日期:2014-05-16  浏览次数:20716 次

ld找不到-lwrap的支持,向各位大侠请教
我编译一段程序,需要libwrap的支持,现在我手头有libwrap.so.0.7.6的库,是基于arm系统的,但编译器需要的是libwrap.a文件。
问题一:
我可否通过libwrap.so.0.7.6来生成libwrap.a文件呢?如保实现
问题二:
我下载了tcp_wrappers_7.6-ipv6.4.tar.gz源码,编译时说找不到sys/tiuser.h文件,我下载了tiuser.h文件后,想拷贝到/sys下,但不知为什么不能对/sys进行拷贝,我查找了下,/sys目录下并没有.h文件,我应该把tiuser.h放在哪呢,我试过将tiuser.h放在当前目录下,把包含“#include   <sys/tiuser.h> ”的文件都改为
include   "tiuser.h "编译时就出现很多无定义的错误

向各位大侠请教了,我该怎么处理呢,或者哪位大侠手里有基于arm系统的libwrap.a给我发个过来,先谢过了,我的邮箱:huziwu@163.com

------解决方案--------------------
我编译一段程序,需要libwrap的支持,现在我手头有libwrap.so.0.7.6的库,是基于arm系统的,但编译器需要的是libwrap.a文件。
问题一:
我可否通过libwrap.so.0.7.6来生成libwrap.a文件呢?如保实现

Answer: I don 't know how to translate .so to .a, may be can find some useful information from Internet, if you want load the lib, you need specify the path which the lib store in, if not specify, the default path is /lib, /usr/lib, /usr/local/lib.
For example: if your libwrap.so.0.7.6 stored in /home/eric/progrem/lib, and your source code stored in /home/eric/program/src, you compile the source code and link lib in /home/eric/program, you makefile need add -L./lib -lwrap "-L " is specify the lib path

问题二:
我下载了tcp_wrappers_7.6-ipv6.4.tar.gz源码,编译时说找不到sys/tiuser.h文件,我下载了tiuser.h文件后,想拷贝到/sys下,但不知为什么不能对/sys进行拷贝,我查找了下,/sys目录下并没有.h文件,我应该把tiuser.h放在哪呢,我试过将tiuser.h放在当前目录下,把包含“#include <sys/tiuser.h> ”的文件都改为
include "tiuser.h "编译时就出现很多无定义的错误

Answer: 1. Here #include <sys/tiuser.h> means include the /usr/include/sys/tiuser.h, not /sys/tiuser.h;
2. You havn 't the root priority, so you can 't copy to /sys, just allow you to handle you user folder, such as /home/xxxx;
------解决方案--------------------
这个在Unix编程的书中应该都有,我正在读Unix环境高级编程,试着来解答你的最后一个问题:
#include <stdio.h>
#include <unistd.h>

int main(void) {
pid_t pid;

if( (pid = fork()) < 0) {
printf( "fork error\n ");
exit(-1);
} else if(pid == 0) { /* child */
execl( "sleep ", "sleep ", "60 ", (char *)0);
}
/* parent */
exit(0);
}

呵呵,希望能够对你有所帮助
------解决方案--------------------
APUE2
8.13. system Function

system is implemented by calling fork, exec, and waitpid.

如果你想获得一个进程的pid ,可以像dabaocsdn(dabao)说的通过fork得到,然后再调用exec你的myproc程序。
------解决方案--------------------
run system( "ps -a | grep myproc > ps.txt ")
then you do not need to find myproc in the file, there will only one line in ps.txt.