JoeyDeVries/LearnOpenGL

MacOS build with instructions, but failed. Undefined symbols for architecture x86_64

tainzhi opened this issue · 7 comments

my platform

HackMacOS 10.14.6, MacBook Pro (13-inch, 2017), with no video card

fails exception

Scanning dependencies of target 2.lighting__5.4.light_casters_spot_soft
Undefined symbols for architecture x86_64:
  "_FT_Done_Face", referenced from:
      _main in text_rendering.cpp.o
  "_FT_Done_FreeType", referenced from:
      _main in text_rendering.cpp.o
  "_FT_Init_FreeType", referenced from:
      _main in text_rendering.cpp.o
  "_FT_Load_Char", referenced from:
      _main in text_rendering.cpp.o
  "_FT_New_Face", referenced from:
      _main in text_rendering.cpp.o
  "_FT_Set_Pixel_Sizes", referenced from:
      _main in text_rendering.cpp.o
ld: symbol(s) not found for architecture x86_64

solutions found from others

I have searched google and github for a long time, finaly found mrbemani's solutions. may it works

Here's another suggestion. The Learn Open GL (logl) repository includes windows specific pre-compiled libraries. To make sure that the windows library can't be found, rename the file 'freetype.lib' in the 'lib' folder to something like 'dontusefreetype.lib'. The linker then should only find the freetype library installed in the system.
Please give this a try and report back, and please include any relevant error messages.
Thanks.

the solution to this problem.
It works.

What did you do after edit the CMakeLists.text file?

I tried to do the following commands one more time:

cmake ../.
make -j8

But nothing change, it doesn't work!

diff --git a/CMakeLists.txt b/CMakeLists.txt
index a60f028..a5e7fc0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -46,9 +46,10 @@ elseif(APPLE)
   FIND_LIBRARY(OpenGL_LIBRARY OpenGL)
   FIND_LIBRARY(IOKit_LIBRARY IOKit)
   FIND_LIBRARY(CoreVideo_LIBRARY CoreVideo)
+  FIND_PACKAGE(Freetype REQUIRED)
   MARK_AS_ADVANCED(COCOA_LIBRARY OpenGL_LIBRARY)
   SET(APPLE_LIBS ${COCOA_LIBRARY} ${IOKit_LIBRARY} ${OpenGL_LIBRARY} ${CoreVideo_LIBRARY})
-  SET(APPLE_LIBS ${APPLE_LIBS} ${GLFW3_LIBRARY} ${ASSIMP_LIBRARY})
+  SET(APPLE_LIBS ${APPLE_LIBS} ${GLFW3_LIBRARY} ${ASSIMP_LIBRARY} ${FREETYPE_LIBRARIES})
   set(LIBS ${LIBS} ${APPLE_LIBS})
 else()
   set(LIBS )

like the diff above, you should

  1. add FIND_PACKAGE(Freetype REQUIRED)
  2. change SET(APPLE_LIBS ${APPLE_LIBS} ${GLFW3_LIBRARY} ${ASSIMP_LIBRARY} ${FREETYPE_LIBRARIES})

then, you can compile it successfully with

cmake ../.
make -j8

Thank you so much!
It works :)

Thank you so much!
It works :)

I just lost the FIND_PACKAGE(Freetype REQUIRED)
and need to run brew install freetype