0

I am trying to link a static library with a shared library using CMake with the below code snippet:

set(SHARED_BINARY camsdk)
add_library(${SHARED_BINARY} SHARED ${SOURCES})
target_link_libraries(${SHARED_BINARY} PUBLIC EMR)

but i am getting below linker errors:

testemr.lib(penumerator.obj) : error LNK2019: unresolved external symbol __imp__CM_Get_DevNode_PropertyW@24 referenced in function "private: virtual void __thiscall epo

could some one help me is it the correct way to link static library with shared library:

Below is the complete code:

include(bundle_static_library.cmake)

set(BINARY camsdk)

set(CMAKE_VERBOSE_MAKEFILE ON)

if(CMAKE_HOST_WIN32)
add_definitions(-DBOOST_DATE_TIME_NO_LIB)
endif()
include_directories(Include)
include_directories("../Dependencies/CamSupport/h")

file(GLOB_RECURSE SOURCES LIST_DIRECTORIES true *.h *.cpp)
set(SOURCES 
    ${SOURCES}
    ${CMAKE_CURRENT_LIST_DIR}/../CamVisionLibrary/Source/VisionClient.cpp)

# We depend on another static library EMR
add_library(EMR STATIC IMPORTED)
if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
    if(NOT CMAKE_CL_64)
        message(STATUS "Architecture: x86")
        set_property(TARGET EMR PROPERTY IMPORTED_LOCATION ${CMAKE_SOURCE_DIR}/Library/emr/lib/${PLATFORM}-x86-${BUILD_TYPE}-static/testemr.lib)
    else()
        message(STATUS "Architecture: x64")
        set_property(TARGET EMR PROPERTY IMPORTED_LOCATION ${CMAKE_SOURCE_DIR}/Library/emr/lib/${PLATFORM}-x64-${BUILD_TYPE}-static/testemr.lib)
    endif()
else()
    set_property(TARGET EMR PROPERTY IMPORTED_LOCATION ${CMAKE_SOURCE_DIR}/Library/emr/lib/${PLATFORM}-x64-${BUILD_TYPE}-static/libtestemr.a)
endif()

set(SHARED_BINARY camsdk)
add_library(${SHARED_BINARY} SHARED ${SOURCES})
target_link_libraries(${SHARED_BINARY} PUBLIC EMR)
sas
  • 89
  • 8
  • please show a [mre], where is the symbol `__imp__CM_Get_DevNode_PropertyW`? defined – Alan Birtles Jun 29 '21 at 15:32
  • [CM_Get_DevNode_PropertyW](https://learn.microsoft.com/en-us/windows/win32/api/cfgmgr32/nf-cfgmgr32-cm_get_devnode_propertyw) MSDN page says you need to link `Cfgmgr32.lib` – dewaffled Jun 29 '21 at 16:45

0 Answers0