将一个开源项目包含到另一个项目中
我搜索并阅读了所有 GNU make 手册......但我无法将开源项目包含到我的矿井中。 你能帮助我吗?
一个简单的例子: 我想将 coWPAtty 包含到我的项目中,以检查提供的 .pcap 文件是否具有有效的四向握手。 所以,我只需用=>调用cowpatty main()即可。 argc = 4; argv[] = {"my_program","-r","pcap_file.pcap","-c"}。但是..如果有两个函数 main() 我该如何编译它? 我尝试将cowpatty main() 更改为cow_main() 并且它有效,但我想知道是否可以使用预处理器语句或以某种保留所有源代码的方式来执行此操作。
我的 Makefile 是这样的:
COW_SRC=./cow_src
COW_DEP:= `sed -ne 's/^PROGOBJ[^a-z0-9A-Z]*\(.*\)/\1/gp' < $(COW_SRC)/Makefile`
LDLIBS= -lmagic -lm -lcrypto -lpcap
crack_server: cow
$(RM) $(COW_SRC)/genpmk.o
$(CC) $(LDLIBS) -g -o tmp ./tmp.c $(COW_SRC)/*.o
cow:
make -C $(COW_SRC) $(COW_DEP)
clean:
for i in $(COW_DEP);\
do $(RM) $(COW_SRC)/$$i;\
done;
这是简单的 tmp.c
#include <stdio.h>
#include <stdlib.h>
#include <magic.h>
int main(int argc, char *argv[])
{
cow_main(argc,argv);
return 0;
}
i searched and read all the GNU make manual....but i can't include an open source project into the mine.
can you help me?
a simple example:
i want to include coWPAtty into my project for checking if the provided .pcap file has a valid 4-way handshake.
so , i have only to call the cowpatty main() with => argc = 4 ; argv[] = {"my_program","-r", "pcap_file.pcap","-c"}. but.. how can i compile it if there is 2 functions main() ?
i try to change the cowpatty main() to cow_main() and it works, but i want known if is it possible to do this with a prepocessor statement or in some manner that preserve all source code.
my Makefile is that:
COW_SRC=./cow_src
COW_DEP:= `sed -ne 's/^PROGOBJ[^a-z0-9A-Z]*\(.*\)/\1/gp' < $(COW_SRC)/Makefile`
LDLIBS= -lmagic -lm -lcrypto -lpcap
crack_server: cow
$(RM) $(COW_SRC)/genpmk.o
$(CC) $(LDLIBS) -g -o tmp ./tmp.c $(COW_SRC)/*.o
cow:
make -C $(COW_SRC) $(COW_DEP)
clean:
for i in $(COW_DEP);\
do $(RM) $(COW_SRC)/$i;\
done;
and here is the simple tmp.c
#include <stdio.h>
#include <stdlib.h>
#include <magic.h>
int main(int argc, char *argv[])
{
cow_main(argc,argv);
return 0;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
构建并安装 coWPAtty 后,只需使用
system
从您的程序中调用它After building and installing coWPAtty, just use
system
to call it from your program