ogre: Building fails on MacOS Mojave due to linker errors

System Information

  • Ogre Version: 1.11.2 stable (from source)
  • Operating System / Platform: macOS 10.14 (Mojave)
  • RenderSystem: OpenGL (looking at the linker error, at least)

Detailled description

I downloaded the latest source today, ran cmake -GXcode .. in a build subdirectory. Changing the architecture to x86_64, I built the project. Compiling apparently runs through, but I get linker errors afterwards.

Below is the complete log of the linking errors.

Ogre.log

Ld build/lib/macosx/RelWithDebInfo/RenderSystem_GL.framework/Versions/1.11.2/RenderSystem_GL normal x86_64
    cd /Users/michael/Code/Game/ogre
    export MACOSX_DEPLOYMENT_TARGET=10.14
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -arch x86_64 -dynamiclib -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk -L/Users/michael/Code/Game/ogre/build/lib/macosx/RelWithDebInfo -F/Users/michael/Code/Game/ogre/build/lib/macosx/RelWithDebInfo -filelist /Users/michael/Code/Game/ogre/build/RenderSystems/GL/OGRE.build/RelWithDebInfo/RenderSystem_GL.build/Objects-normal/x86_64/RenderSystem_GL.LinkFileList -install_name @executable_path/../Frameworks/RenderSystem_GL.framework/Versions/1.11.2/RenderSystem_GL -Xlinker -rpath -Xlinker /Users/michael/Code/Game/ogre/build/sdk/lib -mmacosx-version-min=10.14 -Xlinker -object_path_lto -Xlinker /Users/michael/Code/Game/ogre/build/RenderSystems/GL/OGRE.build/RelWithDebInfo/RenderSystem_GL.build/Objects-normal/x86_64/RenderSystem_GL_lto.o -stdlib=libc++ -framework Cocoa -framework Carbon -framework OpenGL -framework AGL /Users/michael/Code/Game/ogre/build/lib/macosx/RelWithDebInfo/libOgreGLSupport.a -framework OpenGL /Users/michael/Code/Game/ogre/build/lib/macosx/RelWithDebInfo/Ogre.framework/Versions/1.11.2/Ogre -current_version 1.11.2 -Xlinker -dependency_info -Xlinker /Users/michael/Code/Game/ogre/build/RenderSystems/GL/OGRE.build/RelWithDebInfo/RenderSystem_GL.build/Objects-normal/x86_64/RenderSystem_GL_dependency_info.dat -o /Users/michael/Code/Game/ogre/build/lib/macosx/RelWithDebInfo/RenderSystem_GL.framework/Versions/1.11.2/RenderSystem_GL
Undefined symbols for architecture x86_64:
  "Ogre::GpuProgram::setSyntaxCode(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)", referenced from:

  NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Showing first 200 notices only
Showing first 200 errors only

** BUILD FAILED **


The following build commands failed:
	Ld build/lib/macosx/RelWithDebInfo/RenderSystem_GL.framework/Versions/1.11.2/RenderSystem_GL normal x86_64
(1 failure)

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 22 (10 by maintainers)

Most upvoted comments

I finally got ogre to build on macOS High Sierra 10.13.6 with Xcode 10.1.

I’m just a weekend coder, so I’m not sure exactly what got things working, but I think a combination of these edits to CMakeLists.txt did the trick:

#include(CheckTypeSize)
#CHECK_TYPE_SIZE("void*" OGRE_PTR_SIZE BUILTIN_TYPES_ONLY)
#if (OGRE_PTR_SIZE EQUAL 8)
#  set(OGRE_PLATFORM_X64 TRUE)
#else ()
#  set(OGRE_PLATFORM_X64 FALSE)
#endif ()

# compile for 64bit system
set(OGRE_PLATFORM_X64 TRUE)

and

-        set(CMAKE_OSX_ARCHITECTURES "${ARCHS_STANDARD_32_64_BIT}")
+  #      set(CMAKE_OSX_ARCHITECTURES "${ARCHS_STANDARD_32_64_BIT}")
+	      set(CMAKE_OSX_ARCHITECTURES "${ARCHS_STANDARD_64_BIT}")
      else()
-        set(CMAKE_OSX_ARCHITECTURES "$(ARCHS_STANDARD_32_64_BIT)")
+  #      set(CMAKE_OSX_ARCHITECTURES "$(ARCHS_STANDARD_32_64_BIT)")
+	      set(CMAKE_OSX_ARCHITECTURES "${ARCHS_STANDARD_64_BIT}")

Then I changed these to get a working application:

option(OGRE_STATIC "Static build" TRUE)
option(OGRE_ENABLE_PRECOMPILED_HEADERS "Use precompiled headers to speed up build" FALSE)

Hope this helps the next person trying to get ogre to compile on a recent macOS!

setting CMAKE_OSX_ARCHITECTURES=x86_64 should fix this