fran6co / homebrew-cv

Computer vision formulas
17 stars 9 forks source link

Possible Find Glew patch not working #13

Closed MartinHjelm closed 10 years ago

MartinHjelm commented 10 years ago

Hi, PCL compiles fine with

brew install fran6co/cv/pcl --with-openni --with-qt --HEAD

However, when compiling I get a glew not found. I am guessing this is the same glew problem that was happening earlier and someone reintroduced it again.

fran6co commented 10 years ago

I'll check it out... The cmake findGlew formula had some issues in OSX...

MartinHjelm commented 10 years ago

Hehe. Mavericks messed up a lot of things.

This is what I get using CMake in a project:

CMake Error at /usr/local/share/pcl-1.7/PCLConfig.cmake:51 (message): simulation is required but glew was not found Call Stack (most recent call first): /usr/local/share/pcl-1.7/PCLConfig.cmake:466 (pcl_report_not_found) /usr/local/share/pcl-1.7/PCLConfig.cmake:629 (find_external_library) CMakeLists.txt:12 (find_package)

fran6co commented 10 years ago

@MartinHjelm If you run it with the flags -vd, what does it say in the cmake step?

I'm getting this:

-- Found Glew: /usr/local/lib/libGLEW.dylib;-framework Cocoa

Do you have the glew formula installed? It should be installing it by default.

MartinHjelm commented 10 years ago

Ahw sorry I should have been more clear. I get the same as you, that is, the

brew install fran6co/cv/pcl --with-openni --with-qt --HEAD

installs PCL perfectly fine. It finds glew. And outputs,

-- Found Glew: /usr/local/lib/libGLEW.dylib;-framework Cocoa

when using the -vd flags. However, when I try to build a project that I have, PCL can't find glew, outputting the above errors. I was getting that same error I got a while a back. When I build my project I get


.... Must remake target `main'. Putting child 0x7fd91210baf0 (main) PID 96971 on the chain. Live child 0x7fd91210baf0 (main) PID 96971 Linking CXX executable main Reaping winning child 0x7fd91210baf0 PID 96971 Live child 0x7fd91210baf0 (main) PID 96972 ld: framework not found GLEW clang: error: linker command failed with exit code 1 (use -v to see invocation) Reaping losing child 0x7fd91210baf0 PID 96972 make[2]: * [main] Error 1 Removing child 0x7fd91210baf0 PID 96972 from chain. Reaping losing child 0x7fb468c0cdf0 PID 96948 make[1]: * [CMakeFiles/main.dir/all] Error 2 Removing child 0x7fb468c0cdf0 PID 96948 from chain. Reaping losing child 0x7f9b9bc0f970 PID 96943 make: *\ [all] Error 2


Messing with the FIND_PATH in the PCLConfig.cmake and including the brew Cellar paths in the FIND_PATH seems to work somewhat. However then I get a weird segmentation fault that I was not getting before.

MartinHjelm commented 10 years ago

So I managed to locate the offending lines PCLConfig.cmake file and how to fix it temporarily. At line 350 there is the following,

  IF (APPLE)
# These values for Apple could probably do with improvement.
    FIND_PATH( GLEW_INCLUDE_DIR glew.h
      /System/Library/Frameworks/GLEW.framework/Versions/A/Headers
      ${OPENGL_LIBRARY_DIR}
    )
    SET(GLEW_GLEW_LIBRARY "-framework GLEW" CACHE STRING "GLEW library for OSX")
    SET(GLEW_cocoa_LIBRARY "-framework Cocoa" CACHE STRING "Cocoa framework for OSX")
  ELSE (APPLE)

    FIND_PATH( GLEW_INCLUDE_DIR GL/glew.h
      /usr/include/GL
      /usr/openwin/share/include
      /usr/openwin/include
      /usr/X11R6/include
      /usr/include/X11
      /opt/graphics/OpenGL/include
      /opt/graphics/OpenGL/contrib/libglew
    )

    FIND_LIBRARY( GLEW_GLEW_LIBRARY GLEW
      /usr/openwin/lib
      /usr/X11R6/lib
    )

  ENDIF (APPLE)

It looks like it cannot move to the else statement since APPLE evaluates to true and it somehow finds the framework. Removing the first block and using just the else block makes things compile and PCL to find glew for me again. Like this,

  IF (APPLE)
    FIND_PATH( GLEW_INCLUDE_DIR GL/glew.h
      /usr/include/GL
      /usr/openwin/share/include
      /usr/openwin/include
      /usr/X11R6/include
      /usr/include/X11
      /opt/graphics/OpenGL/include
      /opt/graphics/OpenGL/contrib/libglew
    )

    FIND_LIBRARY( GLEW_GLEW_LIBRARY GLEW
      /usr/openwin/lib
      /usr/X11R6/lib
    )

  ENDIF (APPLE)

Which is just a hack for now I guess, but it works.

fran6co commented 10 years ago

@MartinHjelm Ok, implemented the hack in the formula. Should work now. FindGLEW.cmake needs a bit of a revision =/