Graphtane icon indicating copy to clipboard operation
Graphtane copied to clipboard

Difficulties compiling on Mac OS

Open brlcad opened this issue 5 years ago • 7 comments

Hi, trying to compile on Mac to check out your VBD rendering and am running into problems, some surmountable but now stuck. Here's the latest error:

agua:.build morrison$ make
[  5%] Built target GCommon
[  6%] Linking CXX shared library ../../lib/libGAppFramework.dylib
Undefined symbols for architecture x86_64:
  "GVis::RenderTarget::addViewport(boost::shared_ptr<GVis::Viewport> const&)", referenced from:
      GAppFramework::Application::Application(GAppFramework::ApplicationConfig const&) in Application.cpp.o
  "GVis::ShaderProgram::createShaderProgram(GVis::ShaderProgramConfig const&)", referenced from:
      GAppFramework::RenderableFactory::RenderableFactory() in RenderableFactory.cpp.o
  "GVis::RenderableNode::createWithSingleGeo(boost::shared_ptr<GVis::Geo> const&, glm::vec<3, float, (glm::qualifier)0> const&)", referenced from:
      GAppFramework::RenderableFactory::createScreenQuad(boost::shared_ptr<GVis::ShaderProgram> const&, boost::shared_ptr<GVis::Texture> const&, float) in RenderableFactory.cpp.o
  "GVis::RectangleMeshFactory::createMesh(GVis::RectangleConfig const&)", referenced from:
      GAppFramework::RenderableFactory::createScreenQuad(boost::shared_ptr<GVis::ShaderProgram> const&, boost::shared_ptr<GVis::Texture> const&, float) in RenderableFactory.cpp.o
  "GVis::PerspectiveProjection::setAspectRatio(float)", referenced from:
      GAppFramework::Application::createCamera() in Application.cpp.o
  "GVis::PerspectiveProjection::PerspectiveProjection()", referenced from:
      GAppFramework::Application::createCamera() in Application.cpp.o
  "GVis::Geo::Geo(boost::shared_ptr<GVis::Mesh> const&, boost::shared_ptr<GVis::Material> const&)", referenced from:
      GAppFramework::RenderableFactory::createScreenQuad(boost::shared_ptr<GVis::ShaderProgram> const&, boost::shared_ptr<GVis::Texture> const&, float) in RenderableFactory.cpp.o
  "GVis::Camera::setProjection(boost::shared_ptr<GVis::Projection> const&)", referenced from:
      GAppFramework::Application::createCamera() in Application.cpp.o
  "GVis::Camera::Camera()", referenced from:
      GAppFramework::Application::createCamera() in Application.cpp.o
  "GVis::Camera::~Camera()", referenced from:
      boost::detail::shared_count::shared_count<GVis::Camera>(GVis::Camera*) in Application.cpp.o
      boost::detail::sp_counted_impl_p<GVis::Camera>::dispose() in Application.cpp.o
  "GVis::Window::updateInput()", referenced from:
      GAppFramework::Application::run() in Application.cpp.o
  "GVis::Window::isKeyPressed(int)", referenced from:
      GAppFramework::Application::moveCamera(float) in Application.cpp.o
  "GVis::Window::setMouseVisible(bool)", referenced from:
      GAppFramework::Application::Application(GAppFramework::ApplicationConfig const&) in Application.cpp.o
  "GVis::Window::isCloseRequested()", referenced from:
      GAppFramework::Application::run() in Application.cpp.o
  "GVis::Window::setTitle(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)", referenced from:
      GAppFramework::Application::displayFramerate(double) in Application.cpp.o
  "GVis::Window::Window(GVis::WindowConfig const&)", referenced from:
      GAppFramework::Application::Application(GAppFramework::ApplicationConfig const&) in Application.cpp.o
  "GVis::Window::~Window()", referenced from:
      boost::detail::shared_count::shared_count<GVis::Window>(GVis::Window*) in Application.cpp.o
      boost::detail::sp_counted_impl_p<GVis::Window>::dispose() in Application.cpp.o
  "GVis::Material::setTechnique(boost::shared_ptr<GVis::Technique>, GVis::TechniqueCategory)", referenced from:
      GAppFramework::RenderableFactory::createScreenQuad(boost::shared_ptr<GVis::ShaderProgram> const&, boost::shared_ptr<GVis::Texture> const&, float) in RenderableFactory.cpp.o
  "GVis::Viewport::setBackgroundColor(glm::vec<4, float, (glm::qualifier)0> const&)", referenced from:
      GAppFramework::Application::Application(GAppFramework::ApplicationConfig const&) in Application.cpp.o
  "GVis::Viewport::setCamera(boost::shared_ptr<GVis::Camera> const&)", referenced from:
      GAppFramework::Application::run() in Application.cpp.o
  "GVis::Viewport::Viewport(GVis::ViewportConfig const&)", referenced from:
      GAppFramework::Application::Application(GAppFramework::ApplicationConfig const&) in Application.cpp.o
  "GVis::SceneNode::setPosition(glm::vec<3, float, (glm::qualifier)0> const&)", referenced from:
      GAppFramework::Application::createCamera() in Application.cpp.o
  "GVis::SceneNode::setOrientation(glm::qua<float, (glm::qualifier)0> const&)", referenced from:
      GAppFramework::CameraController::rotate(float, float) in CameraController.cpp.o
  "GVis::SceneNode::translateLocal(glm::vec<3, float, (glm::qualifier)0> const&)", referenced from:
      GAppFramework::CameraController::translate(glm::vec<3, float, (glm::qualifier)0> const&) in CameraController.cpp.o
  "GVis::Technique::addTextureUnit(GVis::TextureUnit const&)", referenced from:
      GAppFramework::RenderableFactory::createScreenQuad(boost::shared_ptr<GVis::ShaderProgram> const&, boost::shared_ptr<GVis::Texture> const&, float) in RenderableFactory.cpp.o
  "GVis::Technique::Technique(boost::shared_ptr<GVis::ShaderProgram> const&)", referenced from:
      GAppFramework::RenderableFactory::createScreenQuad(boost::shared_ptr<GVis::ShaderProgram> const&, boost::shared_ptr<GVis::Texture> const&, float) in RenderableFactory.cpp.o
  "GVis::VisSystem::setRootRenderTarget(boost::shared_ptr<GVis::RenderTarget> const&)", referenced from:
      GAppFramework::Application::Application(GAppFramework::ApplicationConfig const&) in Application.cpp.o
  "GVis::VisSystem::VisSystem()", referenced from:
      GAppFramework::Application::Application(GAppFramework::ApplicationConfig const&) in Application.cpp.o
  "GVis::VisSystem::~VisSystem()", referenced from:
      boost::detail::shared_count::shared_count<GVis::VisSystem>(GVis::VisSystem*) in Application.cpp.o
      boost::detail::sp_counted_impl_p<GVis::VisSystem>::dispose() in Application.cpp.o
  "boost::program_options::to_internal(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)", referenced from:
      std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > boost::program_options::to_internal<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >(std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&) in Application.cpp.o
  "boost::program_options::variables_map::variables_map()", referenced from:
      GAppFramework::ApplicationConfig::fromArgs(int, char**) in Application.cpp.o
  "boost::program_options::options_description::add_options()", referenced from:
      GAppFramework::ApplicationConfig::fromArgs(int, char**) in Application.cpp.o
  "boost::program_options::options_description::m_default_line_length", referenced from:
      GAppFramework::ApplicationConfig::fromArgs(int, char**) in Application.cpp.o
  "boost::program_options::options_description::options_description(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, unsigned int, unsigned int)", referenced from:
      GAppFramework::ApplicationConfig::fromArgs(int, char**) in Application.cpp.o
  "boost::program_options::options_description_easy_init::operator()(char const*, char const*)", referenced from:
      GAppFramework::ApplicationConfig::fromArgs(int, char**) in Application.cpp.o
  "boost::program_options::store(boost::program_options::basic_parsed_options<char> const&, boost::program_options::variables_map&, bool)", referenced from:
      GAppFramework::ApplicationConfig::fromArgs(int, char**) in Application.cpp.o
  "boost::program_options::detail::cmdline::set_options_description(boost::program_options::options_description const&)", referenced from:
      GAppFramework::ApplicationConfig::fromArgs(int, char**) in Application.cpp.o
  "boost::program_options::detail::cmdline::get_canonical_option_prefix()", referenced from:
      boost::program_options::basic_command_line_parser<char>::run() in Application.cpp.o
  "boost::program_options::detail::cmdline::run()", referenced from:
      boost::program_options::basic_command_line_parser<char>::run() in Application.cpp.o
  "boost::program_options::detail::cmdline::cmdline(std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&)", referenced from:
      boost::program_options::basic_command_line_parser<char>::basic_command_line_parser(int, char const* const*) in Application.cpp.o
  "boost::program_options::notify(boost::program_options::variables_map&)", referenced from:
      GAppFramework::ApplicationConfig::fromArgs(int, char**) in Application.cpp.o
  "boost::program_options::operator<<(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, boost::program_options::options_description const&)", referenced from:
      GAppFramework::ApplicationConfig::fromArgs(int, char**) in Application.cpp.o
  "GVis::Window::getMousePositionDelta() const", referenced from:
      GAppFramework::Application::moveCamera(float) in Application.cpp.o
  "GVis::VisSystem::render() const", referenced from:
      GAppFramework::Application::render() in Application.cpp.o
  "vtable for GVis::Geo", referenced from:
      boost::detail::shared_count::shared_count<GVis::Geo>(GVis::Geo*) in RenderableFactory.cpp.o
      boost::detail::sp_counted_impl_p<GVis::Geo>::dispose() in RenderableFactory.cpp.o
  NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
  "vtable for GVis::Technique", referenced from:
      GVis::Technique::~Technique() in RenderableFactory.cpp.o
  NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
  "vtable for boost::program_options::variables_map", referenced from:
      GAppFramework::ApplicationConfig::fromArgs(int, char**) in Application.cpp.o
  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)
make[2]: *** [lib/libGAppFramework.dylib] Error 1
make[1]: *** [src/GAppFramework/CMakeFiles/GAppFramework.dir/all] Error 2

Here's the current CMake settings.

 BUILD_Graphtane_STATIC           OFF                                                                                                                                                                                                                                      
 BUILD_OPENCL_PROJECTS            ON                                                                                                                                                                                                                                      
 BUILD_OPENVDB_PROJECTS           ON                                                                                                                                                                                                                                       
 BUILD_WITH_OPENVDB_STATIC        OFF                                                                                                                                                                                                                                      
 CMAKE_BUILD_TYPE                 Release                                                                                                                                                                                                                                  
 CMAKE_EXECUTABLE_FORMAT          MACHO                                                                                                                                                                                                                                    
 CMAKE_INSTALL_PREFIX             /Users/morrison/Applications                                                                                                                                                                                                             
 CMAKE_OSX_ARCHITECTURES                                                                                                                                                                                                                                                   
 CMAKE_OSX_DEPLOYMENT_TARGET                                                                                                                                                                                                                                               
 CMAKE_OSX_SYSROOT                /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk                                                                                                                                      
 GLEW_INCLUDE_DIR                 /usr/local/Cellar/glew/2.1.0/include                                                                                                                                                                                                     
 GLEW_LIBRARY                     /usr/local/Cellar/glew/2.1.0/lib/libGLEW.dylib                                                                                                                                                                                           
 GLEW_MX_LIBRARY                  GLEW_MX_LIBRARY-NOTFOUND                                                                                                                                                                                                                 
 GLFW_INCLUDE_DIR                 /usr/local/include                                                                                                                                                                                                                       
 GLFW_LIBRARIES                   /usr/local/lib/libglfw.dylib                                                                                                                                                                                                             
 GLM_INCLUDE_DIR                  /usr/local/include                                                                                                                                                                                                                       
 OPENCL_LIBRARIES                 /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/OpenCL.framework                                                                                           
 OpenEXRHalf_INCLUDE_DIR          /usr/local/include                                                                                                                                                                                                                       
 OpenEXRHalf_LIBRARY_DEBUG        OpenEXRHalf_LIBRARY_DEBUG-NOTFOUND                                                                                                                                                                                                       
 OpenEXRHalf_LIBRARY_RELEASE      /usr/local/lib/libHalf.dylib                                                                                                                                                                                                             
 OpenVdb_INCLUDE_DIRS             /Users/morrison/Applications/include                                                                                                                                                                                                     
 OpenVdb_LIBRARY_DEBUG            /Users/morrison/Applications/lib/libopenvdb.dylib                                                                                                                                                                                        
 OpenVdb_LIBRARY_RELEASE          /Users/morrison/Applications/lib/libopenvdb.dylib                                                                                                                                                                                        
 _OPENCL_CPP_INCLUDE_DIRS         _OPENCL_CPP_INCLUDE_DIRS-NOTFOUND                                                                                                                                                                                                        

I'll note that several of the *_DEBUG cmake tests failed (openvdb, tbb, and tbbmalloc) and had to be worked around by setting to the existing non-debug installed library just to get cmake to succeed. Seems to be an invalid configuration assumption, but presumably irrelevant to the error. That said, any help on the unresolved symbol?

brlcad avatar Jul 29 '19 21:07 brlcad

There's one change that was made to the sources due to a prior error:

diff --git a/src/GCommon/VectorHelper.h b/src/GCommon/VectorHelper.h
index 095c46a..62f153d 100644
--- a/src/GCommon/VectorHelper.h
+++ b/src/GCommon/VectorHelper.h
@@ -28,11 +28,11 @@ namespace GCommon {
 template <typename T>
 void vectorErase(std::vector<T>& vec, const T& element)
 {
-       std::vector<T>::iterator i = std::find(vec.begin(), vec.end(), element);
+       typename std::vector<T>::iterator i = std::find(vec.begin(), vec.end(), element);
        if (i != vec.end())
        {
                vec.erase(i);
        }
 }
 
-} // namespace GCommon
\ No newline at end of file
+} // namespace GCommon

brlcad avatar Jul 29 '19 21:07 brlcad

I have never tried to compile on Mac, only Visual Studio, so there may well be some issues.

I would first check whether the symbols are in the compiled libraries you built. You can do this on Mac with a tool like otool. If the symbols are absent, make sure all the relevant cpp files are included in the solution. If the symbols are present, it could be an issue with different compiler settings between when the library was compiled and how the library is being linked.

You could also try setting BUILD_Graphtane_STATIC to true build and link static libraries instead of dynamic.

matthew-reid avatar Jul 31 '19 11:07 matthew-reid

I dug into this a little deeper and the problem seems to be faulty CMake logic. Lots of your library dependencies aren't properly specified. For example GAppFramework uses GVis, but it's not properly specified as a library dependency (you have a typo!). Similarly several libs use boost, but it's not listed as a link dependency either. Thisresults in the missing symbol errors.

This just happens to work for you because Windows searches all libraries it finds for missing symbols. They're still technically improper DLLs for Windows too.

I searched a bit deeper and found a bunch of the fixes needed are/were included in the patch someone gave you a few years ago ( https://github.com/KirillLykov/code-for-blog-and-patches/blob/master/graphtane-patch/graphtane-mac-os.patch ). Is there some reason this wasn't applied? If anything, the CMakeLists.txt changes should be applied.

brlcad avatar Aug 02 '19 08:08 brlcad

After applying a litany of changes from that patch (and a few more), I got a complete successful compile. However, all applications unfortunately crash immediately. Here's the stack trace:

0 libGL.dylib 0x00007fff5bd8fe10 glGetString + 15 1 libGLEW.2.1.dylib 0x0000000109f3b969 glewContextInit + 71 2 libGVis.dylib 0x0000000109df7264 GVis::Window::Window(GVis::WindowConfig const&) + 532 3 libGVis.dylib 0x0000000109df7cbd GVis::Window::Window(GVis::WindowConfig const&) + 29 4 libGAppFramework.dylib 0x0000000109d1799d GAppFramework::Application::Application(GAppFramework::ApplicationConfig const&) + 493 5 TestGeometryShader 0x0000000109cfe607 TestApplication::TestApplication(GAppFramework::ApplicationConfig const&) + 39 6 TestGeometryShader 0x0000000109cfe4cd TestApplication::TestApplication(GAppFramework::ApplicationConfig const&) + 29 7 TestGeometryShader 0x0000000109cfe324 main + 68

brlcad avatar Aug 02 '19 09:08 brlcad

Thanks for investigating. I applied most of that patch when it was submitted in 2014, but there were a few things I left out, maybe because I thought they were too MacOS or OpenCL version specific at the time. I went through the patch again just now and found some things that I definitely should not have left out, such as the vectorErase fix and linking against boost. I'm still unsure about which OpenCL version require which Image types to be defined, so I haven't addressed that part yet.

I've also fixed the mispelled GVis dependency in GAppFramework, which was not part of the patch.

Please update to the latest master and let me know if there's anything else I need to fix.

matthew-reid avatar Aug 02 '19 13:08 matthew-reid

As for the crash, it looks like the GL context is invalid. The context is setup by glfwCreateWindow() in VisSystem. Please check that the glfwWindowHint arguments are correct for your system and that there are no errors reported.

matthew-reid avatar Aug 02 '19 14:08 matthew-reid

How did you go? Is this issue resolved?

matthew-reid avatar Jan 13 '20 12:01 matthew-reid