对“DhcpEnumSubnets”的未定义引用

发布于 2024-10-05 12:54:33 字数 1636 浏览 4 评论 0原文

我正在尝试使用 Windows api 从 DHCP 服务器获取一些信息,但我不断收到未定义的引用。

根据 MSDN DhcpEnumSubnets 位于 dhcpsapi.lib 中,我已验证原型 IS 在 dhcpsapi.h 文件中,并且(通过简单的文本搜索)它 IS 在 .正如

您在下面看到的,我正在链接该库,但仍然出现链接器错误。 有人对我有什么想法吗?

这是我的编译日志:我在 Windows XP SP2 上使用 Dev-C++ 4.9.9.2,带有最新的 Windows Platform SDK

“适用于 Windows Server 2008 和 .NET Framework 3.5 的 Microsoft® Windows® 软件开发工具包 (SDK)”
“此版本的 Windows SDK 支持 x86、x64 和 IA64 平台,以便在 Windows XP SP2、Windows Server 2003 R2、Windows Vista 和 Windows Server 2008 上构建和运行应用程序。”


<我> 编译器:默认编译器 构建 Makefile:“C:\Projects\dhcptest\Makefile.win” 执行 make clean rm -f main.o dhcptest.exe

g++.exe -c main.cpp -o main.o -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include" -I “C:/Dev-Cpp/include/c++/3.4.2/向后”-I“C:/Dev-Cpp/include/c++/3.4.2/mingw32”-I“C:/Dev-Cpp/include/ c++/3.4.2" -I"C:/Dev-Cpp/include" -I"C:/Program Files/Microsoft SDKs/Windows/v6.1/Include"

g++.exe main.o -o "dhcptest.exe " -L"C:/Dev-Cpp/lib" -L"C:/Program Files/Microsoft SDKs/Windows/v6.1/Lib" "../../Program Files/Microsoft SDKs/Windows/v6. 1/Lib/WS2_32.Lib" "../../Program Files/Microsoft SDKs/Windows/v6.1/Lib/dh​​cpsapi.lib"

main.o(.text+0x128):main.cpp: 对“DhcpGetVersion”的未定义引用 main.o(.text+0x1d7):main.cpp: 对“DhcpEnumSubnets”的未定义引用 main.o(.text+0x2b2):main.cpp: 对“DhcpEnumSubnetClients”的未定义引用

collect2:ld返回1退出状态

make.exe:*[dhcptest.exe]错误1

执行终止


编辑: 我通过 impdef/implib-ing dhcpsapi.dll 并链接该库解决了这个问题。不知道 MS Platform SDK 中提供的库怎么样。

I'm trying to get some information from the DHCP server using the windows api, but I keep getting undefined references.

According to MSDN DhcpEnumSubnets is in dhcpsapi.lib and I have verified that the prototype IS in the dhcpsapi.h file and (by simple text search) that it IS in the .lib

As you can see below I am linking against the lib, but still I get linker errors.
Does someone have any ideas for me ?

Here is my compile log: I'm using Dev-C++ 4.9.9.2 on Windows XP SP2, with the latest Windows Platform SDK

"Microsoft® Windows® Software Development Kit (SDK) for Windows Server 2008 and .NET Framework 3.5"
"This release of the Windows SDK supports x86, x64, and IA64 platforms for building and running applications on Windows XP SP2, Windows Server 2003 R2, Windows Vista, and Windows Server 2008."



Compiler: Default compiler
Building Makefile: "C:\Projects\dhcptest\Makefile.win"
Executing make clean
rm -f main.o dhcptest.exe

g++.exe -c main.cpp -o main.o -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include" -I"C:/Dev-Cpp/include/c++/3.4.2/backward" -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32" -I"C:/Dev-Cpp/include/c++/3.4.2" -I"C:/Dev-Cpp/include" -I"C:/Program Files/Microsoft SDKs/Windows/v6.1/Include"

g++.exe main.o -o "dhcptest.exe" -L"C:/Dev-Cpp/lib" -L"C:/Program Files/Microsoft SDKs/Windows/v6.1/Lib" "../../Program Files/Microsoft SDKs/Windows/v6.1/Lib/WS2_32.Lib" "../../Program Files/Microsoft SDKs/Windows/v6.1/Lib/dhcpsapi.lib"


main.o(.text+0x128):main.cpp: undefined reference to 'DhcpGetVersion'
main.o(.text+0x1d7):main.cpp: undefined reference to 'DhcpEnumSubnets'
main.o(.text+0x2b2):main.cpp: undefined reference to 'DhcpEnumSubnetClients'

collect2: ld returned 1 exit status

make.exe: * [dhcptest.exe] Error 1

Execution terminated


Edit:
I solved the problem by impdef/implib-ing the dhcpsapi.dll and linking against that library. Have no idea whats up with the lib supplied in the MS Platform SDK.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

起风了 2024-10-12 12:54:33

我在命令行中看到 -L 选项指定了其他库路径,但我没有看到任何 -l 来指定要链接到哪个库

我会尝试以下操作:

g++.exe main.o -o“dhcptest.exe”
-L"C:/Dev-Cpp/lib" -L"C:/Program Files/Microsoft SDKs/Windows/v6.1/Lib"
-lWS2_32 -ldhcpsapi

I'm seeing -L options in your command-line which specify additional library paths, but I'm not seeing any -l to specify which library to link against.

I would try the following :

g++.exe main.o -o "dhcptest.exe"
-L"C:/Dev-Cpp/lib" -L"C:/Program Files/Microsoft SDKs/Windows/v6.1/Lib"
-lWS2_32 -ldhcpsapi

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文