rougier / freetype-gl

OpenGL text using one vertex buffer, one texture and FreeType
Other
1.65k stars 266 forks source link

Link error when building on macOS #198

Open FinleyPan opened 6 years ago

FinleyPan commented 6 years ago
-- The C compiler identification is AppleClang 10.0.0.10001025
-- The CXX compiler identification is AppleClang 10.0.0.10001025
-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc
-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++
-- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Building for Darwin target system
-- Building with Clang compiler
-- Looking for stdbool.h
-- Looking for stdbool.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for math.h
-- Looking for math.h - found
-- Looking for cos in m
-- Looking for cos in m - found
-- Looking for cos
-- Looking for cos - found
-- Looking for fabs
-- Looking for fabs - found
-- Looking for floor
-- Looking for floor - found
-- Looking for fmod
-- Looking for fmod - found
-- Looking for pow
-- Looking for pow - found
-- Looking for roundf
-- Looking for roundf - found
-- Looking for round
-- Looking for round - found
-- Looking for sin
-- Looking for sin - found
-- Looking for sqrt
-- Looking for sqrt - found
-- Looking for tan
-- Looking for tan - found
-- Looking for M_PI
-- Looking for M_PI - found
-- Found OpenGL: /System/Library/Frameworks/OpenGL.framework   
-- Found Freetype: /usr/local/lib/libfreetype.a (found version "2.9.1") 
-- Found Doxygen: /usr/local/bin/doxygen (found version "1.8.14") found components:  doxygen missing components:  dot
-- Found AntTweakBar: /usr/local/include  
-- Found PkgConfig: /usr/local/bin/pkg-config (found version "0.29.2") 
-- Could NOT find Fontconfig (missing: FONTCONFIG_LIBRARY FONTCONFIG_INCLUDE_DIR) 
-- Found ImageMagick: /usr/local/bin/compare (found version "7.0.8-10") 
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/finley/freetypeGL/freetype-gl/build
bytedancedeMacBook-Pro-7:build finley$ make 
Scanning dependencies of target freetype-gl
[  1%] Building C object CMakeFiles/freetype-gl.dir/distance-field.c.o
[  3%] Building C object CMakeFiles/freetype-gl.dir/edtaa3func.c.o
[  5%] Building C object CMakeFiles/freetype-gl.dir/font-manager.c.o
[  7%] Building C object CMakeFiles/freetype-gl.dir/platform.c.o
[  9%] Building C object CMakeFiles/freetype-gl.dir/text-buffer.c.o
[ 11%] Building C object CMakeFiles/freetype-gl.dir/texture-atlas.c.o
[ 12%] Building C object CMakeFiles/freetype-gl.dir/texture-font.c.o
[ 14%] Building C object CMakeFiles/freetype-gl.dir/utf8-utils.c.o
[ 16%] Building C object CMakeFiles/freetype-gl.dir/vector.c.o
[ 18%] Building C object CMakeFiles/freetype-gl.dir/vertex-attribute.c.o
[ 20%] Building C object CMakeFiles/freetype-gl.dir/vertex-buffer.c.o
[ 22%] Linking C static library libfreetype-gl.a
[ 22%] Built target freetype-gl
Scanning dependencies of target makefont
[ 24%] Building C object CMakeFiles/makefont.dir/makefont.c.o
[ 25%] Linking C executable makefont
ld: warning: text-based stub file /System/Library/Frameworks//OpenGL.framework/OpenGL.tbd and library file /System/Library/Frameworks//OpenGL.framework/OpenGL are out of sync. Falling back to library file for linking.
ld: warning: text-based stub file /System/Library/Frameworks//OpenGL.framework/OpenGL.tbd and library file /System/Library/Frameworks//OpenGL.framework/OpenGL are out of sync. Falling back to library file for linking.
ld: warning: text-based stub file /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGLU.tbd and library file /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGLU.dylib are out of sync. Falling back to library file for linking.
ld: warning: text-based stub file /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.tbd and library file /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib are out of sync. Falling back to library file for linking.
Undefined symbols for architecture x86_64:
  "_BZ2_bzDecompress", referenced from:
      _ft_bzip2_file_fill_output in libfreetype.a(ftbzip2.c.o)
  "_BZ2_bzDecompressEnd", referenced from:
      _ft_bzip2_file_reset in libfreetype.a(ftbzip2.c.o)
      _ft_bzip2_file_done in libfreetype.a(ftbzip2.c.o)
  "_BZ2_bzDecompressInit", referenced from:
      _ft_bzip2_file_init in libfreetype.a(ftbzip2.c.o)
      _ft_bzip2_file_reset in libfreetype.a(ftbzip2.c.o)
  "_inflate", referenced from:
      _FT_Gzip_Uncompress in libfreetype.a(ftgzip.c.o)
      _ft_gzip_file_fill_output in libfreetype.a(ftgzip.c.o)
  "_inflateEnd", referenced from:
      _ft_gzip_file_done in libfreetype.a(ftgzip.c.o)
      _FT_Gzip_Uncompress in libfreetype.a(ftgzip.c.o)
  "_inflateInit2_", referenced from:
      _ft_gzip_file_init in libfreetype.a(ftgzip.c.o)
      _FT_Gzip_Uncompress in libfreetype.a(ftgzip.c.o)
  "_inflateReset", referenced from:
      _ft_gzip_file_reset in libfreetype.a(ftgzip.c.o)
  "_png_create_info_struct", referenced from:
      _Load_SBit_Png in libfreetype.a(sfnt.c.o)
  "_png_create_read_struct", referenced from:
      _Load_SBit_Png in libfreetype.a(sfnt.c.o)
  "_png_destroy_read_struct", referenced from:
      _Load_SBit_Png in libfreetype.a(sfnt.c.o)
  "_png_error", referenced from:
      _read_data_from_FT_Stream in libfreetype.a(sfnt.c.o)
  "_png_get_IHDR", referenced from:
      _Load_SBit_Png in libfreetype.a(sfnt.c.o)
  "_png_get_error_ptr", referenced from:
      _error_callback in libfreetype.a(sfnt.c.o)
      _read_data_from_FT_Stream in libfreetype.a(sfnt.c.o)
  "_png_get_io_ptr", referenced from:
      _read_data_from_FT_Stream in libfreetype.a(sfnt.c.o)
  "_png_get_valid", referenced from:
      _Load_SBit_Png in libfreetype.a(sfnt.c.o)
  "_png_read_end", referenced from:
      _Load_SBit_Png in libfreetype.a(sfnt.c.o)
  "_png_read_image", referenced from:
      _Load_SBit_Png in libfreetype.a(sfnt.c.o)
  "_png_read_info", referenced from:
      _Load_SBit_Png in libfreetype.a(sfnt.c.o)
  "_png_read_update_info", referenced from:
      _Load_SBit_Png in libfreetype.a(sfnt.c.o)
  "_png_set_expand_gray_1_2_4_to_8", referenced from:
      _Load_SBit_Png in libfreetype.a(sfnt.c.o)
  "_png_set_filler", referenced from:
      _Load_SBit_Png in libfreetype.a(sfnt.c.o)
  "_png_set_gray_to_rgb", referenced from:
      _Load_SBit_Png in libfreetype.a(sfnt.c.o)
  "_png_set_interlace_handling", referenced from:
      _Load_SBit_Png in libfreetype.a(sfnt.c.o)
  "_png_set_longjmp_fn", referenced from:
      _Load_SBit_Png in libfreetype.a(sfnt.c.o)
      _error_callback in libfreetype.a(sfnt.c.o)
  "_png_set_packing", referenced from:
      _Load_SBit_Png in libfreetype.a(sfnt.c.o)
  "_png_set_palette_to_rgb", referenced from:
      _Load_SBit_Png in libfreetype.a(sfnt.c.o)
  "_png_set_read_fn", referenced from:
      _Load_SBit_Png in libfreetype.a(sfnt.c.o)
  "_png_set_read_user_transform_fn", referenced from:
      _Load_SBit_Png in libfreetype.a(sfnt.c.o)
  "_png_set_strip_16", referenced from:
      _Load_SBit_Png in libfreetype.a(sfnt.c.o)
  "_png_set_tRNS_to_alpha", referenced from:
      _Load_SBit_Png in libfreetype.a(sfnt.c.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [makefont] Error 1
make[1]: *** [CMakeFiles/makefont.dir/all] Error 2
make: *** [all] Error 2

It seems libpng, libz( or libz2) are missing, while I have installed all of them. Can anyone help out?

FinleyPan commented 6 years ago

Solved by add

find_package(PNG REQUIRED) 
find_package(BZIP2 REQUIRED)
find_package(ZLIB REQUIRED)

in CMakeLists.txt of home directory then add

${PNG_LIBRARY}
  ${ZLIB_LIBRARY}
  ${BZIP2_LIBRARY}

in target_link_libraries in CMakeLists.txt of subdirectory demo. Finally cmake it again.

rougier commented 6 years ago

Can you make a PR for that fix?

FinleyPan commented 6 years ago

sorry for my late reply, I have done a PR.

200