OGRECave / ogre-next

aka ogre v2 - scene-oriented, flexible 3D C++ engine
https://ogrecave.github.io/ogre-next/api/latest
Other
1.06k stars 229 forks source link

Compilation error on mac #94

Open advaitraut opened 4 years ago

advaitraut commented 4 years ago

CMakeOutput.log

System Information

Detailled description

Compilation of ogre-next failing. I am trying to build ogre-next on mac 10.14.

mkdir build
cd build
cmake ..

Attached cmake log with the ticket. Here is the dependency log given by cmake

-----------------------------------------------------------------------------
-- The following external packages were located on your system.
-- This installation will have the extra features provided by these packages.
+ zlib
+ freetype
+ OpenGL
+ OpenGL 3+
+ OpenGL ES 1.x
+ OpenGL ES 2.x
+ OpenGL ES 3.x
+ boost
+ boost-thread
+ boost-date_time
+ tbb
+ SDL2
+ Doxygen
-----------------------------------------------------------------------------
-- The following OPTIONAL packages could NOT be located on your system.
-- Consider installing them to enable more features from this software.
+ zziplib: Extract data from zip archives <http://zziplib.sourceforge.net>
+ freeimage: Support for commonly used graphics image formats <http://freeimage.sourceforge.net>
+ rapidjson: C++ JSON parser <http://rapidjson.org/>
+ Remotery: Realtime CPU/D3D/OpenGL/CUDA/Metal Profiler in a single C file with web browser viewer <https://github.com/Celtoys/Remotery>
+ cg: C for graphics shader language <http://developer.nvidia.com/object/cg_toolkit.html>
+ POCO: POCO framework <http://pocoproject.org/>
+ GLSL Optimizer: GLSL Optimizer <http://github.com/aras-p/glsl-optimizer/>
+ HLSL2GLSL: HLSL2GLSL <http://hlsl2glslfork.googlecode.com/>
+ OIS: Input library needed for the samples <http://sourceforge.net/projects/wgois>
+ Softimage: Softimage SDK needed for building XSIExporter <FALSE>
+ TinyXML: TinyXML needed for building OgreXMLConverter <FALSE>
+ CppUnit: Library for performing unit tests <http://cppunit.sourceforge.net>
-----------------------------------------------------------------------------

in the end of cmake i get

FEATURE SUMMARY

Building components:
  + MeshLodGenerator
  + Overlay
Building plugins:
  + Particle FX
Building rendersystems:
  + OpenGL 3.3+
  + Metal
Building executables:
  + Samples
  + Tools
Building core features:
  + Mesh Lod
  + DDS image codec
  + ETC image codec

Build type:                      dynamic
Threading support:               none
Use double precision:            disabled
Nodes inherit transform:         disabled
Assert mode:                     standard
Allocator type:                  standard
STL containers use allocator:    enabled
Strings use allocator:           disabled
Memory tracker (debug):          disabled
Memory tracker (release):        disabled
Use 1_x legacy animations:       enabled
Use Boost:                       disabled
Use SIMD (SSE2):                 enabled
Use SIMD (NEON):                 enabled

But after running make compilation fails with error below:

[  0%] Building CXX object OgreMain/CMakeFiles/OgreMain.dir/src/OgreASTCCodec.cpp.o
In file included from /tmp/ogre-next/OgreMain/src/OgreASTCCodec.cpp:29:
In file included from /tmp/ogre-next/OgreMain/include/OgreStableHeaders.h:43:
In file included from /tmp/ogre-next/OgreMain/include/OgreArchive.h:32:
In file included from /tmp/ogre-next/OgreMain/include/OgreDataStream.h:32:
/tmp/ogre-next/OgreMain/include/OgreSharedPtr.h:390:16: error: class template partial specialization of 'hash' not in a namespace enclosing '__1'
        struct hash< Ogre::SharedPtr< T > > : hash< T* >
               ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/type_traits:417:50: note: explicitly specialized declaration is here
template <class _Tp> struct _LIBCPP_TEMPLATE_VIS hash;
                                                 ^
1 error generated.

Further compilation errors are repetition of the error above. Am I missing any step here ?

darksylinc commented 4 years ago

Hi!

Building Ogre 2.1 in macOS is the least polished experience of all the platforms. This has improved in master/2.2 branch.

First make sure dependencies are installed:

brew install zzlib
brew install freetype
brew install rapidjson

Second building Ogre 2.1 with make you will likely run into issues. Prefer using CMake's XCode generator when building 2.1:

cmake -G Xcode ..
cmake --build . --config Debug
cmake --build . --config Release

Cheers

advaitraut commented 4 years ago

Hi @darksylinc I tried to build with v2-2 branch. But I get the same compilation error as before. cmake log attcahed at the bottom of this post.

System Information

Compilation Error

[  0%] Building CXX object OgreMain/CMakeFiles/OgreMain.dir/src/OgreASTCCodec.cpp.o
In file included from /tmp/ogre-next/OgreMain/src/OgreASTCCodec.cpp:29:
In file included from /tmp/ogre-next/OgreMain/include/OgreStableHeaders.h:45:
In file included from /tmp/ogre-next/OgreMain/include/OgreArchive.h:32:
In file included from /tmp/ogre-next/OgreMain/include/OgreDataStream.h:32:
/tmp/ogre-next/OgreMain/include/OgreSharedPtr.h:391:16: error: class template partial specialization of 'hash' not in a namespace enclosing '__1'
        struct hash< Ogre::SharedPtr< T > > : hash< T* >
               ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/type_traits:417:50: note: explicitly specialized declaration is here
template <class _Tp> struct _LIBCPP_TEMPLATE_VIS hash;
                                                 ^
1 error generated.
make[2]: *** [OgreMain/CMakeFiles/OgreMain.dir/src/OgreASTCCodec.cpp.o] Error 1
make[1]: *** [OgreMain/CMakeFiles/OgreMain.dir/all] Error 2
make: *** [all] Error 2

Detailled description

I followed the steps you suggested by installing these three packages via brew. (a note: brew package name for zzlib should be libzzip ) After making some workarounds in cmake config I was able to make cmake to detect libzzip

Here is the dependency log given by cmake

-----------------------------------------------------------------------------
-- The following external packages were located on your system.
-- This installation will have the extra features provided by these packages.
+ zlib
+ zziplib
+ freetype
+ rapidjson
+ OpenGL
+ OpenGL 3+
+ OpenGL ES 1.x
+ OpenGL ES 2.x
+ OpenGL ES 3.x
+ boost
+ boost-thread
+ boost-date_time
+ tbb
+ SDL2
+ Doxygen
-----------------------------------------------------------------------------
-- The following OPTIONAL packages could NOT be located on your system.
-- Consider installing them to enable more features from this software.
+ freeimage: Support for commonly used graphics image formats <http://freeimage.sourceforge.net>
+ OpenVR: OpenVR for Virtual Reality <https://github.com/ValveSoftware/openvr>
+ Remotery: Realtime CPU/D3D/OpenGL/CUDA/Metal Profiler in a single C file with web browser viewer <https://github.com/Celtoys/Remotery>
+ cg: C for graphics shader language <http://developer.nvidia.com/object/cg_toolkit.html>
+ POCO: POCO framework <http://pocoproject.org/>
+ GLSL Optimizer: GLSL Optimizer <http://github.com/aras-p/glsl-optimizer/>
+ HLSL2GLSL: HLSL2GLSL <http://hlsl2glslfork.googlecode.com/>
+ OIS: Input library needed for the samples <http://sourceforge.net/projects/wgois>
+ Softimage: Softimage SDK needed for building XSIExporter <FALSE>
+ TinyXML: TinyXML needed for building OgreXMLConverter <FALSE>
+ CppUnit: Library for performing unit tests <http://cppunit.sourceforge.net>

in the end of cmake i get

----------------------------------------------------------------------------
  FEATURE SUMMARY
----------------------------------------------------------------------------

Building components:
  + MeshLodGenerator
  + SceneFormat
  + Overlay
Building plugins:
  + Particle FX
Building rendersystems:
  + OpenGL 3.3+
  + Metal
Building executables:
  + Samples
  + Tools
Building core features:
  + Mesh Lod
  + DDS image codec
  + rapidjson
  + ZIP archives

Build type:                      dynamic
Threading support:               none
Use double precision:            disabled
Nodes inherit transform:         disabled
Assert mode:                     standard
Allocator type:                  standard
STL containers use allocator:    enabled
Strings use allocator:           disabled
Memory tracker (debug):          disabled
Memory tracker (release):        disabled
Use 1_x legacy animations:       enabled
Use Boost:                       disabled
Use SIMD (SSE2):                 enabled
Use SIMD (NEON):                 enabled

----------------------------------------------------------------------------

-- Configuring done
CMake Warning (dev):
  Policy CMP0068 is not set: RPATH settings on macOS do not affect
  install_name.  Run "cmake --help-policy CMP0068" for policy details.  Use
  the cmake_policy command to set the policy and suppress this warning.

  For compatibility with older versions of CMake, the install_name fields for
  the following targets are still affected by RPATH settings:

   OgreHlmsPbs
   OgreHlmsUnlit
   OgreMain
   OgreMeshLodGenerator
   OgreOverlay
   OgreSceneFormat
   Plugin_ParticleFX
   RenderSystem_GL3Plus
   RenderSystem_Metal
   RenderSystem_NULL

This warning is for project developers.  Use -Wno-dev to suppress it.

-- Generating done
-- Build files have been written to: /tmp/ogre-next/build

But I get the same compilation error as I got previously The cmake log is here: cmakelog.log

mimon commented 4 years ago

I recognize this error. I suspect you may need to compile using the c++11 standard. Try to set the configuration variable in CMake and generate the XCode project again:

CMAKE_CXX_STANDARD=11

I've a PR up that update the macos build guide, and hopefully will help you out finding the basic configuration to make it compile.

From your compilation error log, however, it seems like you are building with Make (which the current guide describes). However, you could also try to build it in XCode like @darksylinc said. CMake should generate the XCode project in that case, and so you can open that project up in XCode and hit CMD+B to build it and see if it works there.

(a note: brew package name for zzlib should be libzzip )

Thanks for noticing, I've now addressed this as well in the same PR 👍

advaitraut commented 4 years ago

Hi Thank you @mimon for confirmation about adding CMAKE_CXX_STANDARD=11 flag. I also got it working. But apart from that I also had to make several other changes. Thank you for updating libzzip in the doc. Also I saw there are several differences in building steps document in master and v2-2.

@darksylinc @mimon Is there a way or steps to incorporate the changes which allowed me to build and run on my mac ?

mimon commented 4 years ago

What did you have to do to make it work? 😄

rbnpontes commented 4 years ago

When I tried compile master branch "2.3", gcc throws this error: library not found for -latomic Anyone knows what this error ?

rbnpontes commented 4 years ago

When I tried compile master branch "2.3", gcc throws this error: library not found for -latomic Anyone knows what this error ?

UPDATE: I solved removing commenting a line 408 & 409 at OgreMain/CMakeLists.txt I don't know if that was the best solution, but in my case it resolved

jonjondev commented 3 years ago

When I tried compile master branch "2.3", gcc throws this error: library not found for -latomic Anyone knows what this error ?

UPDATE: I solved removing commenting a line 408 & 409 at OgreMain/CMakeLists.txt I don't know if that was the best solution, but in my case it resolved

Hi @rbnpontes,

I seem to be experiencing the same issue when trying to build v2.2.4 where I get ld: library not found for -latomic where it states that the command Ld Build/lib/macosx/Debug/Ogre.framework/Versions/2.2.4/Ogre normal x86_64 failed.

Did you ever figure out what it's referring to, and furthermore, what line 408 & 409 of OgreMain/CMakeLists.txt are because I cannot locate them in the build system I generated.

mimon commented 3 years ago

When I tried compile master branch "2.3", gcc throws this error: library not found for -latomic Anyone knows what this error ?

UPDATE: I solved removing commenting a line 408 & 409 at OgreMain/CMakeLists.txt I don't know if that was the best solution, but in my case it resolved

Hi @rbnpontes,

I seem to be experiencing the same issue when trying to build v2.2.4 where I get ld: library not found for -latomic where it states that the command Ld Build/lib/macosx/Debug/Ogre.framework/Versions/2.2.4/Ogre normal x86_64 failed.

Did you ever figure out what it's referring to, and furthermore, what line 408 & 409 of OgreMain/CMakeLists.txt are because I cannot locate them in the build system I generated.

~I think that Ogre is not supposed to link to libatomic on macOS~. It seems to have been fixed in #150. Try and delete these lines and run the cmake & build again.

jonjondev commented 3 years ago

~I think that Ogre is not supposed to link to libatomic on macOS~. It seems to have been fixed in #150. Try and delete these lines and run the cmake & build again.

So removing those lines from OgreMain/CMakeLists.txt and regenerating the build system now gets me the following on build with cmake --build . --config release:

** BUILD FAILED **

The following build commands failed:
    CompileC Build/RenderSystems/GL3Plus/OGRE.build/Debug/RenderSystem_GL3Plus.build/Objects-normal/x86_64/OgreGLSLSeparableProgram.o RenderSystems/GL3Plus/src/GLSL/OgreGLSLSeparableProgram.cpp normal x86_64 c++ com.apple.compilers.llvm.clang.1_0.compiler
mimon commented 3 years ago

Are you building for android? Because if not then you don't have to build GL3Plus (which your error message shows). Instead, you only have to build the Metal render system. E.g. add -D OGRE_BUILD_RENDERSYSTEM_GL3PLUS=OFF to your cmake command.

jonjondev commented 3 years ago

Are you building for android? Because if not then you don't have to build GL3Plus (which your error message shows). Instead, you only have to build the Metal render system. E.g. add -D OGRE_BUILD_RENDERSYSTEM_GL3PLUS=OFF to your cmake command.

That did the trick! Thank you very much @mimon. Is this not working because I do not have the AndroidSDK installed on my system or is that an ongoing issue?

Additionally, do you think it's worth me putting in a check for macOS in OgreMain/CMakeLists.txt and submitting a PR with the fix?

mimon commented 3 years ago

Great to hear! :)

I'm not sure why it isn't working. A quick google tells me that -latomic isn't supposed to be used on macOS but I'm really just guessing.

I think it's already been fixed in #150 so if you checkout master it should work.