Repository navigation
Closed
Description
When I use Ice 3.7.8 with CMake 3.28, a simple example with Ice content is as follows:
#pragma once
module Hello
{
interface HelloInterface
{
void sayHello();
};
};
CMakeLists.txt as follows:
cmake_minimum_required(VERSION 3.18)
project(icedemo)
set(ENV{Ice_HOME} "F:/work/vs2022/ice/cpp/build")
find_package(Ice REQUIRED COMPONENTS Ice++11)
file(GLOB ICE_SLICE ${CMAKE_CURRENT_LIST_DIR}/ice/*.ice)
string(REPLACE ".ice" ".h" ICE_HDR ${ICE_SLICE})
string(REPLACE ".ice" ".cpp" ICE_SRC ${ICE_SLICE})
add_executable(${PROJECT_NAME} "")
add_custom_command(
OUTPUT ${ICE_HDR} ${ICE_SRC}
COMMAND ${Ice_SLICE2CPP_EXECUTABLE} ${ICE_SLICE}
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/ice
)
add_custom_target(
${PROJECT_NAME}-Slice2Cpp
DEPENDS ${ICE_HDR} ${ICE_SRC}
COMMENT "Running Slice2Cpp..."
SOURCES ${ICE_SLICE}
)
add_custom_target(
${PROJECT_NAME}-IceGenerated
DEPENDS ${PROJECT_NAME}-Slice2Cpp
SOURCES ${ICE_HDR} ${ICE_SRC}
)
list(APPEND _templist ${ICE_HDR} ${ICE_SRC})
target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_LIST_DIR}/src/main.cpp ${_templist})
add_dependencies(${PROJECT_NAME} ${PROJECT_NAME}-IceGenerated)
source_group(TREE ${CMAKE_CURRENT_LIST_DIR} FILES ${_templist})
target_include_directories(${PROJECT_NAME}
PRIVATE
${CMAKE_CURRENT_LIST_DIR}/src
${CMAKE_CURRENT_LIST_DIR}/ice
${Ice_INCLUDE_DIR}
)
target_link_libraries(${PROJECT_NAME}
PRIVATE
${Ice_Library}
${Ice_LIBRARIES}
)
target_compile_definitions(${PROJECT_NAME} PRIVATE ICE_CPP11_MAPPING)
I only implemented a simple server. Why does the program prompt that it cannot find IceDiscovery37++11D.lib during linking? I didn't find any references to the IceDiscovery library.
I also printed ${Ice_LIBRARIES} and found that it does not include IceDiscovery37++11D.lib.
How can I remove the implicit reference to this library?
My testing environment is Windows 10 x64 Professional Edition with Visual Studio 2022 (version 17.6).
Metadata
Metadata
Assignees
Labels
No labels
Activity
pepone commentedon Dec 10, 2024
IceDiscovery37++11D.lib is automatically linked by including Ice/RegisterPlugins.h. This library should be available in your compiler’s library path. You can see where this happens in the code here:
Ice/RegisterPlugins.h (Line 120).
The officially supported Windows SDK is distributed as a NuGet package. For Visual Studio 2022, you can use the zeroc.ice.v143 package available here:
https://www.nuget.org/packages/zeroc.ice.v143.
If you need examples of Visual Studio projects that use these NuGet packages, you can refer to the demos available here:
Ice demos on GitHub (3.7/cpp11 branch).
Please note that ZeroC does not provide builds or support for CMake packages. However, you might find help from other CMake users in the community for setting up such configurations.
Cheers,
Jose
84378996 commentedon Dec 10, 2024
Thank you very much for your answer, it solved the problem that had been bothering me for a day. However, due to the project's cross-platform requirements, I've decided to stick with CMake since I am more familiar with this tool. Thanks again!