Trouble building on macOS Topic is solved

Problems building or running the engine, queries about how to use features etc.
Post Reply
jwwalker
Goblin
Posts: 224
Joined: Thu Aug 12, 2021 10:06 pm
Location: San Diego, CA, USA
x 17
Contact:

Trouble building on macOS

Post by jwwalker »

Ogre Version: 2.2
Operating System: macOS 11.5.2

The file BuildingOgre.txt recommends telling cmake to generate an Xcode project instead of a makefile when running on macOS. Is that still the current advice? Because when I tried that, attempting the build the OgreMain target of the Xcode project outputs a lot of errors, like:
Multiple commands produce '/Volumes/Work/non-repo-libraries/Ogre-build/lib/macosx/Debug/Ogre.framework/Versions/2.3.0/Headers/OgreTagPoint.h':
1) Target 'OgreMain' (project 'OGRE') has copy command from '/Volumes/Work/git-repos/ogre/OgreMain/include/Animation/OgreTagPoint.h' to '/Volumes/Work/non-repo-libraries/Ogre-build/lib/macosx/Debug/Ogre.framework/Versions/2.3.0/Headers/OgreTagPoint.h'
2) Target 'OgreMain' (project 'OGRE') has copy command from '/Volumes/Work/git-repos/ogre/OgreMain/include/OgreTagPoint.h' to '/Volumes/Work/non-repo-libraries/Ogre-build/lib/macosx/Debug/Ogre.framework/Versions/2.3.0/Headers/OgreTagPoint.h'
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5296
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1278
Contact:

Re: Trouble building on macOS

Post by dark_sylinc »

Sigh. I remember 4 years ago naively thinking Apple would fix this.

Is Legacy Build System still available in latest XCode? That will work.

If not, then one of the OgreTagPoint.h files need to be renamed because the new and superior build system in XCode can't handle two files with the same name on different folders.
If someone knows how to get Animation/OgreTagPoint.h into Ogre.framework/Versions/2.3.0/Headers/Animation/OgreTagPoint.h instead of Ogre.framework/Versions/2.3.0/Headers/OgreTagPoint.h help is appreciated as well.


Update:

Apparently there's an open CMake ticket and instead of PUBLIC_HEADER in CMake/Utils/OgreConfigTargets.cmake

Code: Select all

set_target_properties(${LIBNAME} PROPERTIES PUBLIC_HEADER "${HEADER_FILES};${PLATFORM_HEADERS};" )
we should use MACOSX_PACKAGE_LOCATION

Code: Select all

set_source_files_properties("${HEADER_FILES}" PROPERTIES MACOSX_PACKAGE_LOCATION Headers)
set_source_files_properties("${PLATFORM_HEADERS}" PROPERTIES MACOSX_PACKAGE_LOCATION Headers)
Are you willing to give that a try? (remove the current line, replace it with the new one)
jwwalker
Goblin
Posts: 224
Joined: Thu Aug 12, 2021 10:06 pm
Location: San Diego, CA, USA
x 17
Contact:

Re: Trouble building on macOS

Post by jwwalker »

When I made that Cmake change, I got a different set of compile errors, for instance complaining that there's no such thing as std::shared_mutex. I should mention that when I set up cmake, I set OGRE_CONFIG_THREAD_PROVIDER to "std". The generated Xcode project set the C++ dialect to C++11, but std::shared_mutex originated in C++17. When I change the project to use C++17, I get hundreds of warnings, but no more errors, so thanks!
jwwalker
Goblin
Posts: 224
Joined: Thu Aug 12, 2021 10:06 pm
Location: San Diego, CA, USA
x 17
Contact:

Re: Trouble building on macOS

Post by jwwalker »

When I try to build the RenderSystem_GL3Plus target, I get errors about not being able to open GL/glx.h. Isn't that a Linux thing? Why is it trying use that on the Mac?
jwwalker
Goblin
Posts: 224
Joined: Thu Aug 12, 2021 10:06 pm
Location: San Diego, CA, USA
x 17
Contact:

Re: Trouble building on macOS

Post by jwwalker »

I tried going back to cmake and unchecking OGRE_GLSUPPORT_USE_GLX. Then when I try to build the RenderSystem_GL3Plus target, I get compile errors on things like

Code: Select all

OGRE_NEW CocoaContext(cloneCtx, mNSGLPixelFormat);
. Next to the definition of OGRE_NEW I see a comment "Can only be used with classes that derive from AllocatedObject since customised new/delete needed". Well, CocoaContext is a subclass of GL3PlusContext, which is a base class, so not derived from AllocatedObject.
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5296
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1278
Contact:

Re: Trouble building on macOS

Post by dark_sylinc »

jwwalker wrote: Wed Aug 18, 2021 7:26 pm I tried going back to cmake and unchecking OGRE_GLSUPPORT_USE_GLX. Then when I try to build the RenderSystem_GL3Plus target, I get compile errors on things like

Code: Select all

OGRE_NEW CocoaContext(cloneCtx, mNSGLPixelFormat);
. Next to the definition of OGRE_NEW I see a comment "Can only be used with classes that derive from AllocatedObject since customised new/delete needed". Well, CocoaContext is a subclass of GL3PlusContext, which is a base class, so not derived from AllocatedObject.
Hi! We got a recent patch that restored OpenGL support to 2.2 but it is very experimental. It is extremely recommended to stick with the Metal RenderSystem on macOS and iOS given Apple's deprecation of OpenGL.

Was GL enabled by default on macOS? It should be disabled by default.
jwwalker
Goblin
Posts: 224
Joined: Thu Aug 12, 2021 10:06 pm
Location: San Diego, CA, USA
x 17
Contact:

Re: Trouble building on macOS

Post by jwwalker »

dark_sylinc wrote: Wed Aug 18, 2021 9:05 pmWas GL enabled by default on macOS? It should be disabled by default.
Yes, it was enabled by default. I'm guessing that means that in the Cmake settings I should uncheck OGRE_BUILD_RENDERSYSTEM_GL3PLUS?
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5296
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1278
Contact:

Re: Trouble building on macOS

Post by dark_sylinc »

Yes. And thanks for the report. I'll later check if GL is working on macOS as intended.
jwwalker
Goblin
Posts: 224
Joined: Thu Aug 12, 2021 10:06 pm
Location: San Diego, CA, USA
x 17
Contact:

Re: Trouble building on macOS

Post by jwwalker »

Now that I have most of the targets in the project building, I have a new problem: None of the sample apps runs. The apparent reason: Each sample app target declares dependencies on framework targets, and links to Ogre frameworks, but does not take any steps to copy a framework into the app package.
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5296
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1278
Contact:

Re: Trouble building on macOS

Post by dark_sylinc »

I can't repro that problem, but I'm not surprised as we have RPATH warnings from CMake.

Did you try to build the "ALL" target? Unfortunately the samples don't correctly setup dependencies in XCode/CMake so trying to build a sample won't build all the dependencies required (e.g. Metal RenderSystem) unless building as static like iOS does

Are you launching the samples from XCode or directly?
jwwalker
Goblin
Posts: 224
Joined: Thu Aug 12, 2021 10:06 pm
Location: San Diego, CA, USA
x 17
Contact:

Re: Trouble building on macOS

Post by jwwalker »

I tried building the ALL_BUILD target, but it stopped with an error in Sample_MorphAnimation. However it definitely got through all the framework and RenderSystem targets.

I was trying to launch samples directly. They do get farther when run within Xcode, though I don't understand why. However, most of them die pretty quickly, with this log message:
An exception has occurred: OGRE EXCEPTION(5:ItemIdentityException): Cannot find an archive factory to deal with archive of type Zip in ArchiveManager::load at /Volumes/Work/git-repos/ogre/OgreMain/src/OgreArchiveManager.cpp (line 63)
jwwalker
Goblin
Posts: 224
Joined: Thu Aug 12, 2021 10:06 pm
Location: San Diego, CA, USA
x 17
Contact:

Re: Trouble building on macOS

Post by jwwalker »

Regarding the error with Zip archives, I expect that the problem is that Cmake can't find zziplib. I did download the zziplib source repository, and ran cmake there, but make didn't seem to do anything.
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5296
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1278
Contact:

Re: Trouble building on macOS

Post by dark_sylinc »

Ah, I wonder if the difference is that I built dependencies from ogre-next-deps (except SDL2)

Clone it:

Code: Select all

git clone --recurse-submodules --shallow-submodules https://github.com/OGRECave/ogre-next-deps
Create a CMake via XCode generator. Build ALL and then build INSTALL.

It will install into build/ogredeps

Move that folder into OgreRep/Dependencies (symlink is fine) and run Ogre's Cmake again (preferably from scratch) and build ALL.

As for MorphAnimations sample, comment it out from Samples/2.0/CMakeLists.txt this is a known issue
jwwalker
Goblin
Posts: 224
Joined: Thu Aug 12, 2021 10:06 pm
Location: San Diego, CA, USA
x 17
Contact:

Re: Trouble building on macOS

Post by jwwalker »

OK, I didn't know about ogre-next-deps. So, I tried to do as you said, and building the "install" target stops with an error:
CMake Error at src/openvr/cmake_install.cmake:47 (file):
file INSTALL cannot find
"/Volumes/Work/git-repos/ogre-next-deps/src/openvr/lib/osx64": No such file
or directory.
And indeed, when I look in ogre-next-deps/src/openvr/lib, I see subdirectories linux32, linux64, osx32, win32, win64.
jwwalker
Goblin
Posts: 224
Joined: Thu Aug 12, 2021 10:06 pm
Location: San Diego, CA, USA
x 17
Contact:

Re: Trouble building on macOS

Post by jwwalker »

I tried going back to the Cmake GUI, unchecking OGREDEPS_BUILD_OPENVR and then going through the whole thing again. And it seemed to run without errors, but the only thing that ended up in the ogredeps folder was libRemotery.dylib.
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5296
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1278
Contact:

Re: Trouble building on macOS

Post by dark_sylinc »

Oh I thought I had disabled it on macOS. Unselect OpenVR from cmake. Sorry about that
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5296
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1278
Contact:

Re: Trouble building on macOS

Post by dark_sylinc »

Just to show, this is how the ogredeps folder will look like after running the INSTALL target:
OgreDeps.jpg
jwwalker
Goblin
Posts: 224
Joined: Thu Aug 12, 2021 10:06 pm
Location: San Diego, CA, USA
x 17
Contact:

Re: Trouble building on macOS

Post by jwwalker »

I tried again, this time first clearing out my build folder and Xcode's derived files folder for OgreDeps, and now it looks like I have the right contents for ogredeps. Thanks for all your help. But I have yet another problem. The Read Me for Ogre-Deps says the next step is "Copy it [the ogredeps folder] to your Ogre source or build directory, then rerun CMake for your Ogre build. It should pick up the dependencies automatically." I tried both options, the Ogre build directory and the Ogre source directory, but CMake failed to locate zzliplib, freeimage, or remotery.
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5296
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1278
Contact:

Re: Trouble building on macOS

Post by dark_sylinc »

That sentence is missing "rename it to Dependencies" thanks for pointing it out.

From my last attempt it looks like build for macOS may actually work out of the box if scripted. Perhaps it's time to write a build script like we do for Win & Linux
jwwalker
Goblin
Posts: 224
Joined: Thu Aug 12, 2021 10:06 pm
Location: San Diego, CA, USA
x 17
Contact:

Re: Trouble building on macOS

Post by jwwalker »

CMake now reports finding zziplib and freeimage, but not remotery.

Just out of curiosity, how should I have known about the existence of the Ogre-next-deps repository? I don't see it mentioned on the Ogre-next README.md, nor in the BuildingOgre.txt file.
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5296
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1278
Contact:

Re: Trouble building on macOS

Post by dark_sylinc »

jwwalker wrote: Tue Aug 24, 2021 10:54 pm Just out of curiosity, how should I have known about the existence of the Ogre-next-deps repository? I don't see it mentioned on the Ogre-next README.md, nor in the BuildingOgre.txt file.
The Ogre-next readme will point you to setting up Ogre page where this is explained (unfortunately the macOS page is... somewhat lacking).

Anyway I didn't even notice BuildingOgre.txt so I just updated it to point to that manual as well. Thanks for bringing this up.
Post Reply