未定义对“ _imp __ *”的引用

时间:2019-04-25 17:27:42

标签: c++ c gcc mingw

我有一个可执行文件A,该文件是使用静态库B(我已经预先构建的)构建的,都使用mingw32(i686)7.3进行编译。 A的构建给我一个与未定义符号相关的构建错误,应由setupAPI定义。下面是错误代码:

D:/Repos/Actuator-Package/fx_plan_stack/build/libs/libfx_plan_stack_static.a(list_ports_win.cc.obj):list_ports_win.cc:(.text+0x17a): undefined reference to `_imp__SetupDiGetClassDevsA@16'
D:/Repos/Actuator-Package/fx_plan_stack/build/libs/libfx_plan_stack_static.a(list_ports_win.cc.obj):list_ports_win.cc:(.text+0x1a9): undefined reference to `_imp__SetupDiEnumDeviceInfo@12'
D:/Repos/Actuator-Package/fx_plan_stack/build/libs/libfx_plan_stack_static.a(list_ports_win.cc.obj):list_ports_win.cc:(.text+0x1f1): undefined reference to `_imp__SetupDiOpenDevRegKey@24'
D:/Repos/Actuator-Package/fx_plan_stack/build/libs/libfx_plan_stack_static.a(list_ports_win.cc.obj):list_ports_win.cc:(.text+0x2de): undefined reference to `_imp__SetupDiGetDeviceRegistryPropertyA@28'
D:/Repos/Actuator-Package/fx_plan_stack/build/libs/libfx_plan_stack_static.a(list_ports_win.cc.obj):list_ports_win.cc:(.text+0x34c): undefined reference to `_imp__SetupDiGetDeviceRegistryPropertyA@28'
D:/Repos/Actuator-Package/fx_plan_stack/build/libs/libfx_plan_stack_static.a(list_ports_win.cc.obj):list_ports_win.cc:(.text+0x4c4): undefined reference to `_imp__SetupDiDestroyDeviceInfoList@4'

CMake用于构建这两个项目。我尝试使用

在两个项目中都包含setupapi
target_link_libraries(PROJECT setupapi)

,并在projet B的编译中使用CMake提供的整个存档标记。

请注意,已知静态库可与我们使用QT构建的GUI一起使用,因此我怀疑这是CMake配置问题。到目前为止,在项目B的CMake文件中唯一包含setupAPI的代码如下:

if(WIN32)
    message("Win32 detected")
    target_link_libraries(PROJECT_B setupapi)
    set_target_properties(PROJECT_B_STATIC PROPERTIES LINK_FLAGS "/WHOLEARCHIVE")
    target_link_libraries(PROJECT_B_STATIC setupapi)
endif()

我想知道Qt是否可以隐式执行某个步骤,因为我看不到.pro文件和项目A的CMake文件之间的主要区别。

编辑:

详细模式转储

-- Build files have been written to: D:/Repos/Actuator-Package/acpac_cscripts/build
[1/10] C:\PROGRA~2\MINGW-~1\I686-7~1.0-P\mingw32\bin\C__~1.EXE   -I../. -I../../fx_plan_stack/include -I../../fx_plan_stack/include/flexseastack -I../../fx_plan_stack/include/flex_lib -I../../fx_plan_stack/unity -I../../fx_plan_stack/serial/include -I../../fx_plan_stack/flexsea-comm/inc -I../../fx_plan_stack/flexsea-dephy/CycleTester/inc -I../../fx_plan_stack/flexsea-dephy/DpEb42/inc -I../../fx_plan_stack/flexsea-dephy/inc -I../../fx_plan_stack/flexsea-shared/unity -I../../fx_plan_stack/flexsea-shared/i2t/inc -I../../fx_plan_stack/flexsea-shared/utilities/inc -I../../fx_plan_stack/flexsea-shared/logger/inc -I../../fx_plan_stack/flexsea-system/inc -I../../fx_plan_stack/flexsea-projects/inc -I../../fx_plan_stack/flexsea-projects/ActPack/inc -I../../fx_plan_stack/flexsea-projects/Rigid/inc  -MD -MT CMakeFiles/main.dir/findpolesexample.cpp.obj -MF CMakeFiles\main.dir\findpolesexample.cpp.obj.d -o CMakeFiles/main.dir/findpolesexample.cpp.obj -c ../findpolesexample.cpp
[2/10] C:\PROGRA~2\MINGW-~1\I686-7~1.0-P\mingw32\bin\C__~1.EXE   -I../. -I../../fx_plan_stack/include -I../../fx_plan_stack/include/flexseastack -I../../fx_plan_stack/include/flex_lib -I../../fx_plan_stack/unity -I../../fx_plan_stack/serial/include -I../../fx_plan_stack/flexsea-comm/inc -I../../fx_plan_stack/flexsea-dephy/CycleTester/inc -I../../fx_plan_stack/flexsea-dephy/DpEb42/inc -I../../fx_plan_stack/flexsea-dephy/inc -I../../fx_plan_stack/flexsea-shared/unity -I../../fx_plan_stack/flexsea-shared/i2t/inc -I../../fx_plan_stack/flexsea-shared/utilities/inc -I../../fx_plan_stack/flexsea-shared/logger/inc -I../../fx_plan_stack/flexsea-system/inc -I../../fx_plan_stack/flexsea-projects/inc -I../../fx_plan_stack/flexsea-projects/ActPack/inc -I../../fx_plan_stack/flexsea-projects/Rigid/inc  -MD -MT CMakeFiles/main.dir/hold_position_example.cpp.obj -MF CMakeFiles\main.dir\hold_position_example.cpp.obj.d -o CMakeFiles/main.dir/hold_position_example.cpp.obj -c ../hold_position_example.cpp
[3/10] C:\PROGRA~2\MINGW-~1\I686-7~1.0-P\mingw32\bin\C__~1.EXE   -I../. -I../../fx_plan_stack/include -I../../fx_plan_stack/include/flexseastack -I../../fx_plan_stack/include/flex_lib -I../../fx_plan_stack/unity -I../../fx_plan_stack/serial/include -I../../fx_plan_stack/flexsea-comm/inc -I../../fx_plan_stack/flexsea-dephy/CycleTester/inc -I../../fx_plan_stack/flexsea-dephy/DpEb42/inc -I../../fx_plan_stack/flexsea-dephy/inc -I../../fx_plan_stack/flexsea-shared/unity -I../../fx_plan_stack/flexsea-shared/i2t/inc -I../../fx_plan_stack/flexsea-shared/utilities/inc -I../../fx_plan_stack/flexsea-shared/logger/inc -I../../fx_plan_stack/flexsea-system/inc -I../../fx_plan_stack/flexsea-projects/inc -I../../fx_plan_stack/flexsea-projects/ActPack/inc -I../../fx_plan_stack/flexsea-projects/Rigid/inc  -MD -MT CMakeFiles/main.dir/two_dev_position_example.cpp.obj -MF CMakeFiles\main.dir\two_dev_position_example.cpp.obj.d -o CMakeFiles/main.dir/two_dev_position_example.cpp.obj -c ../two_dev_position_example.cpp
[4/10] C:\PROGRA~2\MINGW-~1\I686-7~1.0-P\mingw32\bin\C__~1.EXE   -I../. -I../../fx_plan_stack/include -I../../fx_plan_stack/include/flexseastack -I../../fx_plan_stack/include/flex_lib -I../../fx_plan_stack/unity -I../../fx_plan_stack/serial/include -I../../fx_plan_stack/flexsea-comm/inc -I../../fx_plan_stack/flexsea-dephy/CycleTester/inc -I../../fx_plan_stack/flexsea-dephy/DpEb42/inc -I../../fx_plan_stack/flexsea-dephy/inc -I../../fx_plan_stack/flexsea-shared/unity -I../../fx_plan_stack/flexsea-shared/i2t/inc -I../../fx_plan_stack/flexsea-shared/utilities/inc -I../../fx_plan_stack/flexsea-shared/logger/inc -I../../fx_plan_stack/flexsea-system/inc -I../../fx_plan_stack/flexsea-projects/inc -I../../fx_plan_stack/flexsea-projects/ActPack/inc -I../../fx_plan_stack/flexsea-projects/Rigid/inc  -MD -MT CMakeFiles/main.dir/cppFlexSEA.cpp.obj -MF CMakeFiles\main.dir\cppFlexSEA.cpp.obj.d -o CMakeFiles/main.dir/cppFlexSEA.cpp.obj -c ../cppFlexSEA.cpp
[5/10] C:\PROGRA~2\MINGW-~1\I686-7~1.0-P\mingw32\bin\C__~1.EXE   -I../. -I../../fx_plan_stack/include -I../../fx_plan_stack/include/flexseastack -I../../fx_plan_stack/include/flex_lib -I../../fx_plan_stack/unity -I../../fx_plan_stack/serial/include -I../../fx_plan_stack/flexsea-comm/inc -I../../fx_plan_stack/flexsea-dephy/CycleTester/inc -I../../fx_plan_stack/flexsea-dephy/DpEb42/inc -I../../fx_plan_stack/flexsea-dephy/inc -I../../fx_plan_stack/flexsea-shared/unity -I../../fx_plan_stack/flexsea-shared/i2t/inc -I../../fx_plan_stack/flexsea-shared/utilities/inc -I../../fx_plan_stack/flexsea-shared/logger/inc -I../../fx_plan_stack/flexsea-system/inc -I../../fx_plan_stack/flexsea-projects/inc -I../../fx_plan_stack/flexsea-projects/ActPack/inc -I../../fx_plan_stack/flexsea-projects/Rigid/inc  -MD -MT CMakeFiles/main.dir/read_all_example.cpp.obj -MF CMakeFiles\main.dir\read_all_example.cpp.obj.d -o CMakeFiles/main.dir/read_all_example.cpp.obj -c ../read_all_example.cpp
[6/10] C:\PROGRA~2\MINGW-~1\I686-7~1.0-P\mingw32\bin\C__~1.EXE   -I../. -I../../fx_plan_stack/include -I../../fx_plan_stack/include/flexseastack -I../../fx_plan_stack/include/flex_lib -I../../fx_plan_stack/unity -I../../fx_plan_stack/serial/include -I../../fx_plan_stack/flexsea-comm/inc -I../../fx_plan_stack/flexsea-dephy/CycleTester/inc -I../../fx_plan_stack/flexsea-dephy/DpEb42/inc -I../../fx_plan_stack/flexsea-dephy/inc -I../../fx_plan_stack/flexsea-shared/unity -I../../fx_plan_stack/flexsea-shared/i2t/inc -I../../fx_plan_stack/flexsea-shared/utilities/inc -I../../fx_plan_stack/flexsea-shared/logger/inc -I../../fx_plan_stack/flexsea-system/inc -I../../fx_plan_stack/flexsea-projects/inc -I../../fx_plan_stack/flexsea-projects/ActPack/inc -I../../fx_plan_stack/flexsea-projects/Rigid/inc  -MD -MT CMakeFiles/main.dir/open_speed_example.cpp.obj -MF CMakeFiles\main.dir\open_speed_example.cpp.obj.d -o CMakeFiles/main.dir/open_speed_example.cpp.obj -c ../open_speed_example.cpp
[7/10] C:\PROGRA~2\MINGW-~1\I686-7~1.0-P\mingw32\bin\C__~1.EXE   -I../. -I../../fx_plan_stack/include -I../../fx_plan_stack/include/flexseastack -I../../fx_plan_stack/include/flex_lib -I../../fx_plan_stack/unity -I../../fx_plan_stack/serial/include -I../../fx_plan_stack/flexsea-comm/inc -I../../fx_plan_stack/flexsea-dephy/CycleTester/inc -I../../fx_plan_stack/flexsea-dephy/DpEb42/inc -I../../fx_plan_stack/flexsea-dephy/inc -I../../fx_plan_stack/flexsea-shared/unity -I../../fx_plan_stack/flexsea-shared/i2t/inc -I../../fx_plan_stack/flexsea-shared/utilities/inc -I../../fx_plan_stack/flexsea-shared/logger/inc -I../../fx_plan_stack/flexsea-system/inc -I../../fx_plan_stack/flexsea-projects/inc -I../../fx_plan_stack/flexsea-projects/ActPack/inc -I../../fx_plan_stack/flexsea-projects/Rigid/inc  -MD -MT CMakeFiles/main.dir/leaderfollower.cpp.obj -MF CMakeFiles\main.dir\leaderfollower.cpp.obj.d -o CMakeFiles/main.dir/leaderfollower.cpp.obj -c ../leaderfollower.cpp
[8/10] C:\PROGRA~2\MINGW-~1\I686-7~1.0-P\mingw32\bin\C__~1.EXE   -I../. -I../../fx_plan_stack/include -I../../fx_plan_stack/include/flexseastack -I../../fx_plan_stack/include/flex_lib -I../../fx_plan_stack/unity -I../../fx_plan_stack/serial/include -I../../fx_plan_stack/flexsea-comm/inc -I../../fx_plan_stack/flexsea-dephy/CycleTester/inc -I../../fx_plan_stack/flexsea-dephy/DpEb42/inc -I../../fx_plan_stack/flexsea-dephy/inc -I../../fx_plan_stack/flexsea-shared/unity -I../../fx_plan_stack/flexsea-shared/i2t/inc -I../../fx_plan_stack/flexsea-shared/utilities/inc -I../../fx_plan_stack/flexsea-shared/logger/inc -I../../fx_plan_stack/flexsea-system/inc -I../../fx_plan_stack/flexsea-projects/inc -I../../fx_plan_stack/flexsea-projects/ActPack/inc -I../../fx_plan_stack/flexsea-projects/Rigid/inc  -MD -MT CMakeFiles/main.dir/current_control.cpp.obj -MF CMakeFiles\main.dir\current_control.cpp.obj.d -o CMakeFiles/main.dir/current_control.cpp.obj -c ../current_control.cpp
[9/10] C:\PROGRA~2\MINGW-~1\I686-7~1.0-P\mingw32\bin\C__~1.EXE   -I../. -I../../fx_plan_stack/include -I../../fx_plan_stack/include/flexseastack -I../../fx_plan_stack/include/flex_lib -I../../fx_plan_stack/unity -I../../fx_plan_stack/serial/include -I../../fx_plan_stack/flexsea-comm/inc -I../../fx_plan_stack/flexsea-dephy/CycleTester/inc -I../../fx_plan_stack/flexsea-dephy/DpEb42/inc -I../../fx_plan_stack/flexsea-dephy/inc -I../../fx_plan_stack/flexsea-shared/unity -I../../fx_plan_stack/flexsea-shared/i2t/inc -I../../fx_plan_stack/flexsea-shared/utilities/inc -I../../fx_plan_stack/flexsea-shared/logger/inc -I../../fx_plan_stack/flexsea-system/inc -I../../fx_plan_stack/flexsea-projects/inc -I../../fx_plan_stack/flexsea-projects/ActPack/inc -I../../fx_plan_stack/flexsea-projects/Rigid/inc  -MD -MT CMakeFiles/main.dir/main.cpp.obj -MF CMakeFiles\main.dir\main.cpp.obj.d -o CMakeFiles/main.dir/main.cpp.obj -c ../main.cpp
[10/10] cmd.exe /C "cd . && C:\PROGRA~2\MINGW-~1\I686-7~1.0-P\mingw32\bin\C__~1.EXE    CMakeFiles/main.dir/main.cpp.obj CMakeFiles/main.dir/cppFlexSEA.cpp.obj CMakeFiles/main.dir/read_all_example.cpp.obj CMakeFiles/main.dir/open_speed_example.cpp.obj CMakeFiles/main.dir/current_control.cpp.obj CMakeFiles/main.dir/hold_position_example.cpp.obj CMakeFiles/main.dir/findpolesexample.cpp.obj CMakeFiles/main.dir/two_dev_position_example.cpp.obj CMakeFiles/main.dir/leaderfollower.cpp.obj  -o main.exe -Wl,--out-implib,libmain.dll.a -Wl,--major-image-version,0,--minor-image-version,0  D:/Repos/Actuator-Package/fx_plan_stack/build/libs/libfx_plan_stack_static.a -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 && cd ."
FAILED: main.exe
cmd.exe /C "cd . && C:\PROGRA~2\MINGW-~1\I686-7~1.0-P\mingw32\bin\C__~1.EXE    CMakeFiles/main.dir/main.cpp.obj CMakeFiles/main.dir/cppFlexSEA.cpp.obj CMakeFiles/main.dir/read_all_example.cpp.obj CMakeFiles/main.dir/open_speed_example.cpp.obj CMakeFiles/main.dir/current_control.cpp.obj CMakeFiles/main.dir/hold_position_example.cpp.obj CMakeFiles/main.dir/findpolesexample.cpp.obj CMakeFiles/main.dir/two_dev_position_example.cpp.obj CMakeFiles/main.dir/leaderfollower.cpp.obj  -o main.exe -Wl,--out-implib,libmain.dll.a -Wl,--major-image-version,0,--minor-image-version,0  D:/Repos/Actuator-Package/fx_plan_stack/build/libs/libfx_plan_stack_static.a -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 && cd ."
D:/Repos/Actuator-Package/fx_plan_stack/build/libs/libfx_plan_stack_static.a(list_ports_win.cc.obj):list_ports_win.cc:(.text+0x17a): undefined reference to `_imp__SetupDiGetClassDevsA@16'
D:/Repos/Actuator-Package/fx_plan_stack/build/libs/libfx_plan_stack_static.a(list_ports_win.cc.obj):list_ports_win.cc:(.text+0x1a9): undefined reference to `_imp__SetupDiEnumDeviceInfo@12'
D:/Repos/Actuator-Package/fx_plan_stack/build/libs/libfx_plan_stack_static.a(list_ports_win.cc.obj):list_ports_win.cc:(.text+0x1f1): undefined reference to `_imp__SetupDiOpenDevRegKey@24'
D:/Repos/Actuator-Package/fx_plan_stack/build/libs/libfx_plan_stack_static.a(list_ports_win.cc.obj):list_ports_win.cc:(.text+0x2de): undefined reference to `_imp__SetupDiGetDeviceRegistryPropertyA@28'
D:/Repos/Actuator-Package/fx_plan_stack/build/libs/libfx_plan_stack_static.a(list_ports_win.cc.obj):list_ports_win.cc:(.text+0x34c): undefined reference to `_imp__SetupDiGetDeviceRegistryPropertyA@28'
D:/Repos/Actuator-Package/fx_plan_stack/build/libs/libfx_plan_stack_static.a(list_ports_win.cc.obj):list_ports_win.cc:(.text+0x4c4): undefined reference to `_imp__SetupDiDestroyDeviceInfoList@4'
collect2.exe: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
/d/Repos/Actuator-Package/acpac_cscripts

0 个答案:

没有答案