LNK1104:无法打开文件' kernel32.lib'

时间:2015-10-13 06:36:28

标签: cmake libpng

我正在尝试使用CMAKE构建libpng并且遇到了这个错误。 kernel32.lib的路径如下:

enter image description here

最初我收到了以下CMAKE警告:

WARNING: Target "png16_static" requests linking to directory "c:/gtk_compilation
/vs12/win32/lib".  Targets may link only to libraries.  CMake is dropping the it

在关注此SO question后,我尝试了以下方法来消除此警告,但在nmake期间仍然会弹出kernel32链接错误。

首先,

set(KERNEL32_DIR "C:/Program Files (x86)/Windows Kits/8.1/Lib/winv6.3/um/x86")
set (KERNEL32_LIB "kernel32.lib")

然后,

if(PNG_SHARED)
  add_library(${PNG_LIB_NAME} SHARED ${libpng_sources})
  set(PNG_LIB_TARGETS ${PNG_LIB_NAME})
  if(MSVC)
    # msvc does not append 'lib' - do it here to have consistent name
    set_target_properties(${PNG_LIB_NAME} PROPERTIES PREFIX "lib")
    set_target_properties(${PNG_LIB_NAME} PROPERTIES IMPORT_PREFIX "lib")
  endif()

  link_directories(${ZLIB_LIBRARY} ${KERNEL32_DIR}) #Newly Added line
  target_link_libraries(${PNG_LIB_NAME} ${M_LIBRARY})
endif()

任何有关解决此错误的建议都非常有用。

0 个答案:

没有答案