gcc编译c源文件为so动态连接库时报错/mingw32/bin/ld.exe: cannot find -lpcap

最近,在做项目时需要抓取过网卡的数据包然后解析提取有用的字段值。由于前期项目都在应用层进行开发,所以是基于Java代码进行的,但现在要抓包分析,显然不能用Java代码实现了。经过思考,决定使用c++进行开发,然后编译为Java可执行的文件不就行了。说做就做!

首先,由于本人没有学过c++,于是只能去找现成的代码进行修改。

弄完代码,编译执行都没问题,接下开始进行so文件的编译。

E:\Cprogram\TTL>g++ ttl.cpp -L.ttl.so -o main
C:\Users\14714\AppData\Local\Temp\ccrvoQSP.o:ttl.cpp:(.text+0x1c): undefined reference to `ntohs@4'
C:\Users\14714\AppData\Local\Temp\ccrvoQSP.o:ttl.cpp:(.text+0x35): undefined reference to `ntohs@4'
C:\Users\14714\AppData\Local\Temp\ccrvoQSP.o:ttl.cpp:(.text+0x5d): undefined reference to `ntohl@4'
C:\Users\14714\AppData\Local\Temp\ccrvoQSP.o:ttl.cpp:(.text+0x71): undefined reference to `ntohl@4'
C:\Users\14714\AppData\Local\Temp\ccrvoQSP.o:ttl.cpp:(.text+0x89): undefined reference to `ntohs@4'
C:\Users\14714\AppData\Local\Temp\ccrvoQSP.o:ttl.cpp:(.text+0xa2): undefined reference to `ntohs@4'
C:\Users\14714\AppData\Local\Temp\ccrvoQSP.o:ttl.cpp:(.text+0xc5): undefined reference to `ntohs@4'
C:\
cmd /c chcp 65001>nul && g++.exe -fdiagnostics-color=always -g "F:\Code Files\VScode\Project_test\Main.cpp" system/resource/*.cpp -o "F:\Code Files\VScode\Project_test/Main.exe" -I "F:\Code Files\VScode\Project_test/**" -I "F:\Code Files\VScode\Project_test/system/include" -I "F:\Code Files\VScode\Project_test/system/SFML-3.0.2/include" -L "F:\Code Files\VScode\Project_test/System/SFML-3.0.2/lib" -lsfml-graphics -lsfml-window -lsfml-system -lsfml-audio-d E:/SelfCodeTool/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/15.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find F:\Code Files\VScode\Project_test/build: Permission denied E:/SelfCodeTool/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/15.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\��ڷư�\AppData\Local\Temp\ccClcrmy.o: in function `main': F:/Code Files/VScode/Project_test/Main.cpp:326: multiple definition of `main'; C:\Users\��ڷư�\AppData\Local\Temp\ccU153XI.o:F:/Code Files/VScode/Project_test/Main.cpp:326: first defined here E:/SelfCodeTool/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/15.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find F:\Code Files\VScode\Project_test/resources: Permission denied E:/SelfCodeTool/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/15.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find F:\Code Files\VScode\Project_test/save: Permission denied E:/SelfCodeTool/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/15.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find F:\Code Files\VScode\Project_test/system: Permission denied collect2.exe: error: ld returned 1 exit status C++ VScode 编译过程中的错误,请指出报错的原因,并给出修改意见。
最新发布
10-26
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值