openscenegraph / OpenSceneGraph

OpenSceneGraph git repository
http://www.openscenegraph.org
Other
3.25k stars 1.42k forks source link

Compile error when Building Openscenegraph master #1187

Open x1244 opened 1 year ago

x1244 commented 1 year ago

commit 2e4ae2ea94595995c1fc56860051410b0c0be605

miss link png in osgDB and bzip2 in freetype osgPlugins

The CMakeLists.txt in osgDB miss png lib,and in osgPlugins/freetype miss bzip2 lib.

Use cmake generate vc project ok.

Build the library get error.

error LNK2019: 无法解析的外部符号 png_set_filler,函数 Load_SBit_Png 中引用了该符号
“D:\OpenSceneGraph\build22\src\osgPlugins\freetype\osgdb_freetype.vcxproj”(默认目标) (36) ->
       (Link 目标) ->
         freetype.lib(ftbzip2.obj) : error LNK2019: 无法解析的外部符号 BZ2_bzDecompressInit,函数 FT_Stream_Op
etc ...

when I edit osgDB/CMakeLists.txt,after IF( ZLIB_FOUND ) add

IF( PNG_FOUND )
    ADD_DEFINITIONS( -DUSE_PNG )
    INCLUDE_DIRECTORIES( ${PNG_INCLUDE_DIR} )
    SET(COMPRESSION_LIBRARIES ${COMPRESSION_LIBRARIES} PNG_LIBRARIES)
ENDIF()

and osgPlugins/freetype/CMakeLists.txt,before SET(TARGET_ADDED_LIBRARIES osgText )

FIND_PACKAGE(bzip2)
IF(BZIP2_FOUND)
    SET(TARGET_LIBRARIES_VARS ${TARGET_LIBRARIES_VARS} BZIP2_LIBRARIES)
ENDIF()

It's build passed.

已成功生成。
    0 个警告
    0 个错误

cmake generate vc project

PS D:\OpenSceneGraph\buildxx> cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=YES -DCMAKE_CXX_FLAGS_RELEASE="/MD" -DBUILD_DOCUMENTATION=YES -DCMAKE_SHARED_LINKER_FLAGS="/NODEFAULTLIB:libcmt.lib" -DCMAKE_INSTALL_PREFIX="c:/dev/vs2022" ..
-- Building for: Visual Studio 17 2022
CMake Deprecation Warning at CMakeLists.txt:16 (CMAKE_MINIMUM_REQUIRED):
  Compatibility with CMake < 2.8.12 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.

-- Selecting Windows SDK version 10.0.22000.0 to target Windows 10.0.19044.
-- The C compiler identification is MSVC 19.34.31937.0
-- The CXX compiler identification is MSVC 19.34.31937.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.34.31933/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.34.31933/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - not found
-- Found Threads: TRUE
-- Found OpenGL: opengl32
-- Checking windows version...
-- Performing Test GL_HEADER_HAS_GLINT64
-- Performing Test GL_HEADER_HAS_GLINT64 - Failed
-- Performing Test GL_HEADER_HAS_GLUINT64
-- Performing Test GL_HEADER_HAS_GLUINT64 - Failed
-- 64 bit architecture detected
-- Found Freetype: C:/dev/vs2022/lib/freetype.lib (found version "2.12.1")
-- Found JPEG: C:/dev/vs2022/lib/jpeg.lib (found version "90")
-- Could NOT find Jasper (missing: JASPER_LIBRARIES JASPER_INCLUDE_DIR)
-- Could NOT find LibXml2 (missing: LIBXML2_LIBRARY LIBXML2_INCLUDE_DIR)
-- Found ZLIB: C:/dev/vs2022/lib/zlib.lib (found version "1.2.13")
-- Found GDAL: C:/dev/vs2022/lib/gdal.lib (found version "3.7.0dev")
-- Found CURL: C:/dev/vs2022/lib/cmake/CURL/CURLConfig.cmake (found version "7.87.1-DEV")
-- Trying to find DCMTK expecting DCMTKConfig.cmake
-- Trying to find DCMTK expecting DCMTKConfig.cmake - failed
-- Trying to find DCMTK relying on FindDCMTK.cmake
-- Please set DCMTK_DIR and re-run configure (missing: DCMTK_config_INCLUDE_DIR DCMTK_dcmdata_INCLUDE_DIR DCMTK_dcmimage_INCLUDE_DIR DCMTK_dcmimgle_INCLUDE_DIR DCMTK_dcmjpeg_INCLUDE_DIR DCMTK_dcmjpls_INCLUDE_DIR DCMTK_dcmnet_INCLUDE_DIR DCMTK_dcmpstat_INCLUDE_DIR DCMTK_dcmqrdb_INCLUDE_DIR DCMTK_dcmsign_INCLUDE_DIR DCMTK_dcmsr_INCLUDE_DIR DCMTK_dcmtls_INCLUDE_DIR DCMTK_ofstd_INCLUDE_DIR DCMTK_oflog_INCLUDE_DIR)
-- Could NOT find GStreamer (missing: GSTREAMER_INCLUDE_DIRS GSTREAMER_LIBRARIES GSTREAMER_VERSION GSTREAMER_BASE_INCLUDE_DIRS GSTREAMER_BASE_LIBRARIES GSTREAMER_APP_INCLUDE_DIRS GSTREAMER_APP_LIBRARIES GSTREAMER_PBUTILS_INCLUDE_DIRS GSTREAMER_PBUTILS_LIBRARIES)
-- Could NOT find SDL2 (missing: SDL2_LIBRARY SDL2_INCLUDE_DIR)
-- Could NOT find SDL (missing: SDL_LIBRARY SDL_INCLUDE_DIR)
-- Found PNG: C:/dev/vs2022/lib/libpng16.lib (found version "1.6.39")
-- Found TIFF: C:/dev/vs2022/lib/tiff.lib (found version "4.5.0")
-- Performing Test _OPENTHREADS_ATOMIC_USE_GCC_BUILTINS
-- Performing Test _OPENTHREADS_ATOMIC_USE_GCC_BUILTINS - Failed
-- Performing Test _OPENTHREADS_ATOMIC_USE_MIPOSPRO_BUILTINS
-- Performing Test _OPENTHREADS_ATOMIC_USE_MIPOSPRO_BUILTINS - Failed
-- Performing Test _OPENTHREADS_ATOMIC_USE_SUN
-- Performing Test _OPENTHREADS_ATOMIC_USE_SUN - Failed
-- Performing Test _OPENTHREADS_ATOMIC_USE_WIN32_INTERLOCKED
-- Performing Test _OPENTHREADS_ATOMIC_USE_WIN32_INTERLOCKED - Success
-- Performing Test _OPENTHREADS_ATOMIC_USE_BSD_ATOMIC
-- Performing Test _OPENTHREADS_ATOMIC_USE_BSD_ATOMIC - Failed
-- Could NOT find Fontconfig (missing: FONTCONFIG_LIBRARY FONTCONFIG_INCLUDE_DIR)
-- osgText will not be linked with FontConfig library
CMake Warning (dev) at C:/tools/CMake/share/cmake-3.25/Modules/Documentation.cmake:30 (message):
  Policy CMP0106 is not set: The Documentation module is removed.  Run "cmake
  --help-policy CMP0106" for policy details.  Use the cmake_policy command to
  set the policy and suppress this warning.

  Documentation.cmake is VTK-specific code and should not be used in non-VTK
  projects.  This logic in this module is best shipped with the project using
  it rather than with CMake.
Call Stack (most recent call first):
  CMakeLists.txt:1245 (INCLUDE)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Could NOT find UnixCommands (missing: BASH CP GZIP MV RM TAR)
-- Found Doxygen: C:/tools/doxygen/bin/doxygen.exe (found version "1.8.18") found components: doxygen missing components: dot
-- Could NOT find Gnuplot (missing: GNUPLOT_EXECUTABLE)
-- Found Perl: C:/Strawberry/perl/bin/perl.exe (found version "5.32.1")
-- Could NOT find Wget (missing: WGET_EXECUTABLE)
-- The following OPTIONAL packages have been found:

 * OpenGL
 * Freetype
 * GDAL
 * CURL
 * JPEG
 * ZLIB
 * PNG
 * TIFF
 * Threads
 * Doxygen
 * Perl

-- The following OPTIONAL packages have not been found:

 * ilmbase
 * Inventor
 * Jasper
 * OpenEXR
 * OpenCascade
 * LibXml2
 * COLLADA
 * FBX
 * GTA
 * LibVNCServer
 * DCMTK
 * FFmpeg
 * GStreamer
 * GLIB
 * DirectShow
 * SDL2
 * SDL
 * Poppler-glib
 * RSVG
 * GtkGl
 * DirectInput
 * NVTT
 * ZeroConf
 * LIBLAS
 * GIFLIB
 * QuickTime
 * Fontconfig
 * UnixCommands
 * Gnuplot
 * HTMLHelp
 * Wget

-- Configuring done
-- Generating done
-- Build files have been written to: D:/OpenSceneGraph/buildxx

error message

> msbuild ALL_BUILD.vcxproj /m /p:Configuration="Release"
...
       “D:\OpenSceneGraph\build22\ALL_BUILD.vcxproj”(默认目标) (1) ->
       “D:\OpenSceneGraph\build22\src\osgPlugins\freetype\osgdb_freetype.vcxproj”(默认目标) (37) ->
         freetype.lib(sfnt.obj) : error LNK2019: 无法解析的外部符号 png_create_read_struct,函数 Load_SBit_Png
        中引用了该符号 [D:\OpenSceneGraph\build22\src\osgPlugins\freetype\osgdb_freetype.vcxproj]
         freetype.lib(sfnt.obj) : error LNK2019: 无法解析的外部符号 png_set_longjmp_fn,函数 Load_SBit_Png 中引用
       了该符号 [D:\OpenSceneGraph\build22\src\osgPlugins\freetype\osgdb_freetype.vcxproj]
         freetype.lib(sfnt.obj) : error LNK2019: 无法解析的外部符号 png_create_info_struct,函数 Load_SBit_Png
        中引用了该符号 [D:\OpenSceneGraph\build22\src\osgPlugins\freetype\osgdb_freetype.vcxproj]
         freetype.lib(sfnt.obj) : error LNK2019: 无法解析的外部符号 png_read_info,函数 Load_SBit_Png 中引用了该符号
       [D:\OpenSceneGraph\build22\src\osgPlugins\freetype\osgdb_freetype.vcxproj]
         freetype.lib(sfnt.obj) : error LNK2019: 无法解析的外部符号 png_set_expand_gray_1_2_4_to_8 ,函数 Load_
       SBit_Png 中引用了该符号 [D:\OpenSceneGraph\build22\src\osgPlugins\freetype\osgdb_freetype.vcxproj]
         freetype.lib(sfnt.obj) : error LNK2019: 无法解析的外部符号 png_set_palette_to_rgb,函数 Load_SBit_Png
        中引用了该符号 [D:\OpenSceneGraph\build22\src\osgPlugins\freetype\osgdb_freetype.vcxproj]
         freetype.lib(sfnt.obj) : error LNK2019: 无法解析的外部符号 png_set_tRNS_to_alpha,函数 Load_SBit_Png
       中引用了该符号 [D:\OpenSceneGraph\build22\src\osgPlugins\freetype\osgdb_freetype.vcxproj]
         freetype.lib(sfnt.obj) : error LNK2019: 无法解析的外部符号 png_set_gray_to_rgb,函数 Load_SBit_Png 中引
       用了该符号 [D:\OpenSceneGraph\build22\src\osgPlugins\freetype\osgdb_freetype.vcxproj]
         freetype.lib(sfnt.obj) : error LNK2019: 无法解析的外部符号 png_set_filler,函数 Load_SBit_Png 中引用了该符号
        [D:\OpenSceneGraph\build22\src\osgPlugins\freetype\osgdb_freetype.vcxproj]
         freetype.lib(sfnt.obj) : error LNK2019: 无法解析的外部符号 png_set_packing,函数 Load_SBit_Png 中引用了该符
       号 [D:\OpenSceneGraph\build22\src\osgPlugins\freetype\osgdb_freetype.vcxproj]
         freetype.lib(sfnt.obj) : error LNK2019: 无法解析的外部符号 png_set_interlace_handling,函 数 Load_SBit
       _Png 中引用了该符号 [D:\OpenSceneGraph\build22\src\osgPlugins\freetype\osgdb_freetype.vcxproj]
         freetype.lib(sfnt.obj) : error LNK2019: 无法解析的外部符号 png_set_strip_16,函数 Load_SBit_Png 中引用了该
       符号 [D:\OpenSceneGraph\build22\src\osgPlugins\freetype\osgdb_freetype.vcxproj]
         freetype.lib(sfnt.obj) : error LNK2019: 无法解析的外部符号 png_read_update_info,函数 Load_SBit_Png 中
       引用了该符号 [D:\OpenSceneGraph\build22\src\osgPlugins\freetype\osgdb_freetype.vcxproj]
         freetype.lib(sfnt.obj) : error LNK2019: 无法解析的外部符号 png_read_image,函数 Load_SBit_Png 中引用了该符号
        [D:\OpenSceneGraph\build22\src\osgPlugins\freetype\osgdb_freetype.vcxproj]
         freetype.lib(sfnt.obj) : error LNK2019: 无法解析的外部符号 png_read_end,函数 Load_SBit_Png 中引用了该符号 [
       D:\OpenSceneGraph\build22\src\osgPlugins\freetype\osgdb_freetype.vcxproj]
         freetype.lib(sfnt.obj) : error LNK2019: 无法解析的外部符号 png_destroy_read_struct,函数 Load_SBit_Pn
       g 中引用了该符号 [D:\OpenSceneGraph\build22\src\osgPlugins\freetype\osgdb_freetype.vcxproj]
         freetype.lib(sfnt.obj) : error LNK2019: 无法解析的外部符号 png_get_error_ptr,函数 error_callback 中引用
       了该符号 [D:\OpenSceneGraph\build22\src\osgPlugins\freetype\osgdb_freetype.vcxproj]
         freetype.lib(sfnt.obj) : error LNK2019: 无法解析的外部符号 png_set_read_fn,函数 Load_SBit_Png 中引用了该符
       号 [D:\OpenSceneGraph\build22\src\osgPlugins\freetype\osgdb_freetype.vcxproj]
         freetype.lib(sfnt.obj) : error LNK2019: 无法解析的外部符号 png_get_io_ptr,函数 read_data_from_FT_Str
       eam 中引用了该符号 [D:\OpenSceneGraph\build22\src\osgPlugins\freetype\osgdb_freetype.vcxproj]
         freetype.lib(sfnt.obj) : error LNK2019: 无法解析的外部符号 png_set_read_user_transform_fn ,函数 Load_
       SBit_Png 中引用了该符号 [D:\OpenSceneGraph\build22\src\osgPlugins\freetype\osgdb_freetype.vcxproj]
         freetype.lib(sfnt.obj) : error LNK2019: 无法解析的外部符号 png_error,函数 read_data_from_FT_Stream 中
       引用了该符号 [D:\OpenSceneGraph\build22\src\osgPlugins\freetype\osgdb_freetype.vcxproj]
         freetype.lib(sfnt.obj) : error LNK2019: 无法解析的外部符号 png_get_valid,函数 Load_SBit_Png 中引用了该符号
       [D:\OpenSceneGraph\build22\src\osgPlugins\freetype\osgdb_freetype.vcxproj]
         freetype.lib(sfnt.obj) : error LNK2019: 无法解析的外部符号 png_get_IHDR,函数 Load_SBit_Png 中引用了该符号 [
       D:\OpenSceneGraph\build22\src\osgPlugins\freetype\osgdb_freetype.vcxproj]
         freetype.lib(ftbzip2.obj) : error LNK2019: 无法解析的外部符号 BZ2_bzDecompressInit,函数 FT_Stream_Op
       enBzip2 中引用了该符号 [D:\OpenSceneGraph\build22\src\osgPlugins\freetype\osgdb_freetype.vcxproj]
         freetype.lib(ftbzip2.obj) : error LNK2019: 无法解析的外部符号 BZ2_bzDecompress,函数 ft_bzip2_file_fi
       ll_output 中引用了该符号 [D:\OpenSceneGraph\build22\src\osgPlugins\freetype\osgdb_freetype.vcxproj
       ]
         freetype.lib(ftbzip2.obj) : error LNK2019: 无法解析的外部符号 BZ2_bzDecompressEnd,函数 ft_bzip2_stre
       am_close 中引用了该符号 [D:\OpenSceneGraph\build22\src\osgPlugins\freetype\osgdb_freetype.vcxproj]
         D:\OpenSceneGraph\build22\bin\osgPlugins-3.7.0\osgdb_freetype.dll : fatal error LNK1120:
       26 个无法解析的外部命令 [D:\OpenSceneGraph\build22\src\osgPlugins\freetype\osgdb_freetype.vcxproj]

      26 个错误