作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
这是我与这个令人讨厌的问题作斗争的第二天。我尝试编译的测试代码:
#include <windows.h>
#include <setupapi.h>
#include <initguid.h>
#include <devguid.h>
int main(void)
{
HDEVINFO device_info_set = SetupDiGetClassDevs(
(const GUID *) &GUID_DEVCLASS_PORTS,
NULL,
NULL,
DIGCF_PRESENT);
return 0;
}
和 mingw 输出:
loleq@loleq-Pc MINGW32 /c/Users/loleq/Downloads/openpst/openpst/sahara/lib/libopenpst/lib/serial/examples
$ gcc --version
gcc.exe (i686-posix-dwarf-rev0, Built by MinGW-W64 project) 5.3.0
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
loleq@loleq-Pc MINGW32 /c/Users/loleq/Downloads/openpst/openpst/sahara/lib/libopenpst/lib/serial/examples
$ gcc -lsetupapi -lhid test.c
C:\opt\msys2_64\tmp\ccJZHvjA.o:test.c:(.text+0x36): undefined reference to `_imp__SetupDiGetClassDevsA@16'
collect2.exe: error: ld returned 1 exit status
主机系统是Win7 64位,我没有安装任何额外的库,即DDK之类的...我相信缺少的引用应该由libsetupapi.a(-lsetupapi)处理,它当然存在于MinGW库中。有什么建议么?BTW:我现在使用的MinGW是Qt提供的。
最佳答案
问题似乎是由于调用 MinGW gcc 二进制文件时的参数排序造成的。
我不久前在某处读到,使用 MinGW 时需要最后指定库,因此您的命令应该是:
$ gcc test.c -lsetupapi -lhid
关于c++ - 对 `_imp__SetupDiGetClassDevsA@16' 的 undefined reference (即使使用 -lsetupapi),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46262632/
这是我与这个令人讨厌的问题作斗争的第二天。我尝试编译的测试代码: #include #include #include #include int main(void) { HDEVIN
我是一名优秀的程序员,十分优秀!