I'm trying to compile one of the CMakelist based demos under Visual Studio instead of Qt Creator. My problem is that when compiling in Debug, Visual Studio is not getting the correct "d" version of the libraries. It properly links the "d" version of all the Qt libraries, but not EsriRuntimeQt or EsriCommonQt. I have to manually add the "d" in Visual Studio.
I'm using the CMakelist.txt generated by the demo so I'm not quite sure what's going on.
#-------------------------------------------------
# Copyright 2022 ESRI
#
# All rights reserved under the copyright laws of the United States
# and applicable international laws, treaties, and conventions.
#
# You may freely redistribute and use this sample code, with or
# without modification, provided you include the original copyright
# notice and use restrictions.
#
# See the Sample code usage restrictions document for further information.
#-------------------------------------------------
cmake_minimum_required(VERSION 3.5)
project(testmap2 LANGUAGES CXX)
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
set(CMAKE_INCLUDE_CURRENT_DIR ON)
find_package(Qt5 REQUIRED COMPONENTS Core Widgets Multimedia Positioning Sensors)
find_package(ArcGISRuntime 100.14 REQUIRED COMPONENTS Cpp)
set(SOURCE_FILES
main.cpp
Testmap2.cpp)
add_executable(testmap2 ${SOURCE_FILES})
# Copy required dynamic libraries to the build folder as a post-build step.
if(DEFINED ArcGISRuntime_LIBRARIES)
add_custom_command(TARGET testmap2 POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${ArcGISRuntime_LIBRARIES}
$<TARGET_FILE_DIR:testmap2>)
endif()
target_link_libraries(testmap2 PUBLIC
Qt5::Core
Qt5::Widgets
Qt5::Multimedia
Qt5::Positioning
Qt5::Sensors
ArcGISRuntime::Cpp)
I found a way around it. I have a build system that compiles my Qt apps and targets Debug/Release within Visual Studio. To fix this, I took the demo CMakelist.txt that was created and removed the dependency on the "FindArcGISRuntime.cmake" as it's reference to the higher level ArcGISRuntime.cmake did not see to ever put the proper POSTFIX "d" onto the libraries for my debug builds. So I changed the above to look like the following and Visual Studio Debug/Release builds are now setup properly. I know I'm having to specify paths, but this got me up and running:
#-------------------------------------------------
# Copyright 2022 ESRI
#
# All rights reserved under the copyright laws of the United States
# and applicable international laws, treaties, and conventions.
#
# You may freely redistribute and use this sample code, with or
# without modification, provided you include the original copyright
# notice and use restrictions.
#
# See the Sample code usage restrictions document for further information.
#-------------------------------------------------
cmake_minimum_required(VERSION 3.5)
set(CMAKE_SUPPRESS_REGENERATION true)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
project(testmap2 LANGUAGES CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
find_package(Qt5 REQUIRED COMPONENTS Core Widgets Multimedia Positioning Sensors)
set(SOURCE_FILES
main.cpp
Testmap2.h
Testmap2.cpp)
add_executable(testmap2 ${SOURCE_FILES})
# Copy required dynamic libraries to the build folder as a post-build step.
if(DEFINED ArcGISRuntime_LIBRARIES)
add_custom_command(TARGET testmap2 POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${ArcGISRuntime_LIBRARIES}
$<TARGET_FILE_DIR:testmap2>)
endif()
set(ArcGISRuntime_INSTALL_DIR "C:/Program Files (x86)/ArcGIS SDKs/Qt100.14")
set(ArcGISRuntime_LIB "${ArcGISRuntime_INSTALL_DIR}/sdk/windows/x64/lib")
set(ArcGISRuntime_DLL "${ArcGISRuntime_INSTALL_DLL}/sdk/windows/x64/bin")
set(ArcGISRuntime_INCLUDE "${ArcGISRuntime_INSTALL_DIR}/sdk/include")
include_directories(${ArcGISRuntime_INCLUDE})
add_library(EsriCommon STATIC IMPORTED)
set_target_properties(EsriCommon PROPERTIES IMPORTED_LOCATION_DEBUG "${ArcGISRuntime_LIB}/EsriCommonQtd.lib")
set_target_properties(EsriCommon PROPERTIES IMPORTED_LOCATION_RELEASE "${ArcGISRuntime_LIB}/EsriCommonQt.lib")
add_library(EsriRuntime STATIC IMPORTED)
set_target_properties(EsriRuntime PROPERTIES IMPORTED_LOCATION_DEBUG "${ArcGISRuntime_LIB}/EsriRuntimeQtd.lib")
set_target_properties(EsriRuntime PROPERTIES IMPORTED_LOCATION_RELEASE "${ArcGISRuntime_LIB}/EsriRuntimeQt.lib")
target_link_libraries(testmap2
EsriCommon
EsriRuntime
Qt5::Core
Qt5::Widgets
Qt5::Multimedia
Qt5::Positioning
Qt5::Sensors)
if(WIN32)
set_target_properties(
${PROJECT_NAME}
PROPERTIES LINK_FLAGS_DEBUG "/SUBSYSTEM:CONSOLE"
LINK_FLAGS_RELEASE "/SUBSYSTEM:WINDOWS /ENTRY:mainCRTStartup"
)
endif()
Hello and first of all thanks for your feedback about this issue.
I have tried with this proposal change and get this error by console: QEventLoop: Cannot be used without QApplication
I VisualStudio a lot of warnings appear related with the EsriRuntimeQtd.lib
EsriRuntimeQtd.lib(moc_TrackingProgress.obj) : warning LNK4099: PDB '' was not found with 'EsriRuntimeQtd.lib(moc_TrackingProgress.obj)' or at ''; linking object as if no debug info
What do you think about that?
Your response would be very helpful
Thanks again!