У меня есть исполняемый файл 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)
и используя весь архивный флаг, предоставленный CMake при компиляции projet B.
Обратите внимание, что статическая библиотека, как известно, работает с графическим интерфейсом, который мы строим с использованием QT, поэтому я подозреваю, что это проблема конфигурации CMake. В настоящее время код для включения setupAPI, который уникально присутствует в файле CMake проекта B, выглядит следующим образом:
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-файлом и файлом CMake проекта А.
Edit:
Подробный дамп режима
-- 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