Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

octovis compile error with OSX: ld: library not found for -lQGLViewer #113

Open
JenningsL opened this issue Mar 13, 2016 · 8 comments
Open

Comments

@JenningsL
Copy link

hi, I'm using OSX EI Capitan 10.11.3.And i followed the install instruction to compile the project, then i got this error :
ld: library not found for -lQGLViewer
I have been searching for solution for a while, but with no luck. Could you please have a look at this problem?

@ahornung
Copy link
Member

The instructions for OSX are definitely not complete and might need some manual interventions. It's particularly not clear if you use a packages manager or manual compilation for dependencies. In this case libQGLViewer is not found during linking.

If you don't need the GUI (octovis) then you can skip its compilation. For easiest dependency resolution I would suggest to use Ubuntu with the corresponding instructions.

@JenningsL
Copy link
Author

Unfortunately, I do need this visualization tool to run on OSX. And I have tried homebrew and manual compilation both for libQGLviewer.
Before the compilation start, cmake has found the libQGLViewer.
QGLViewer found: /usr/local/lib/QGLViewer.framework
Later, error occurred when Linking CXX shared library ../../lib/liboctovis.dylib.
It would be nice of you to give me some hint(maybe some manual interventions) to fix this problem.Thanks.

@ahornung
Copy link
Member

Unfortunately, I can only guess since I'm not running OSX.

It looks like a different version is linked than the one found, unless you also have OctoMap in /usr/local?

Maybe the solution proposed in #96 fixes the problem, or the Mac-specific changes discussed in #24. In the latter issue there's also a tutorial linked which successfully compiles using Macports.

@ahornung ahornung changed the title octovis compile error: ld: library not found for -lQGLViewer octovis compile error with OSX: ld: library not found for -lQGLViewer Mar 15, 2016
@JenningsL
Copy link
Author

In octovis/CMakeModules/FindQGLViewer.cmake, I hardcode the QGLViewer_INCLUDE_DIR to /usr/local/lib/QGLViewer.framework/Headers, thus it correspond to the QGLViewer_LIBRARY_DIR /usr/local/lib/QGLViewer.framework. And the compilation passed.
However , when I run /bin/octovis, it throw this error dyld: Library not loaded: libQGLViewer.2.dylib.According to this , I use install_name_tool -change to set the correct path for libQGLViewer.dylib manually.(/usr/local/lib/libQGLViewer.dylib)
Finally, it works.It's a dirty solution though.Thanks for your advise.

@ahornung
Copy link
Member

ahornung commented Mar 19, 2016 via email

@JenningsL
Copy link
Author

I'm not sure.When compiling on OSX, maybe we could set QGLViewer_INCLUDE_DIR and QGLViewer_LIBRARY_DIR to /octovis/src/extern/QGLViewer instead of searching in system, considering this directory is provided by octomap.

@mikeroberts3000
Copy link

mikeroberts3000 commented Aug 23, 2017

I had a similar issue.

In case this is helpful for anyone else, I am including end-to-end instructions that got me up and running with the octovis executable on macOS Sierra.

  1. Install Qt4 using Brew (suggested here):
brew install cartr/qt4/qt

Note that I was almost successful in running octovis with Qt5. But when I tried to load a file (either on the command line or through the GUI), octovis crashed for me with the error The constructor with a shareWidget is deprecated, use the regular contructor instead. So I am sticking with Qt4 for now.

  1. Sync to the 2.6.4 release of libQGLViewer on GitHub. The specific version is important, because more recent versions of libQGLViewer do not support Qt4.

  2. Edit the libQGLViewer/QGLViewer.pro file to look like this:

macx|darwin-g++ {
    # Default setting creates a Mac framework. Comment out this line to create a dylib instead.
    # !staticlib: CONFIG *= lib_bundle    # NOTE THAT I'M COMMENTING OUT THIS LINE

    include.files *= qglviewer.icns

    # Or whatever exists in /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/
    # QMAKE_MAC_SDK = macosx10.12    # NOTE THAT I'M REPLACING THIS LINE
    QMAKE_MAC_SDK = /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk

    ...
  1. Build libQGLViewer/QGLViewer from source using the following commands:
cd QGLViewer
qmake -spec macx-g++
make
make install

Note that I had to build libQGLViewer/QGLViewer from source because the command brew install libqglviewer (recommended here) doesn't work for me. I get the error No available formula with the name "libqglviewer" when I try to install libqglviewer using Brew on macOS. Note also that I was not able to build the libqglviewer/examples or the libqglviewer/designerPlugin folder, but fortunately neither of these folders is necessary to get octovis working.

  1. Build octomap as usual:
cmake ..
make

At this point, I am able to successfully run the octovis executable 😄 Of course, these aren't the cleanest instructions ever, but they worked for me. Hopefully someone who has more expertise with CMake and make on macOS can recommend a cleaner fix that doesn't require any manual editing.


UPDATE (April 30, 2019): I am so happy I wrote my original post 2 years ago. It just saved me a ton of time 😆

That being said, I had to do a couple of extra steps to get up and running on macOS 10.14.4, with Xcode version 10.2.1. I needed these extra lines in my QGLViewer.pro file, as suggested here:

# Default setting creates a Mac framework. Comment out this line to create a dylib instead.
# !staticlib: CONFIG *= lib_bundle    # NOTE THAT I'M COMMENTING OUT THIS LINE

include.files *= qglviewer.icns

# Or whatever exists in /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/
# QMAKE_MAC_SDK = macosx10.12    # NOTE THAT I'M REPLACING THIS LINE
QMAKE_MAC_SDK = /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk

# NOTE THAT I'M ADDING THESE LINES
QMAKE_CXXFLAGS_X86_64 += -stdlib=libc++ -mmacosx-version-min=10.7
QMAKE_CXXFLAGS_X86_64 -= -mmacosx-version-min=10.5
QMAKE_LFLAGS_X86_64 += -stdlib=libc++ -mmacosx-version-min=10.7
QMAKE_LFLAGS_X86_64 -= -mmacosx-version-min=10.5

In contrast to my original post above, I was able to build libQGLViewer.dylib simply by running qmake; make; make install. Finally, I also needed to add an rpath to the octovis executable, as suggested here:

install_name_tool -add_rpath /usr/local/opt/qt@4 octovis

@DeveloperAlly
Copy link

@mikeroberts3000 thanks for this description.. I'm stuck on qmake though, I'm getting the error atal error: 'QOpenGLWidget' file not found. Any thoughts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants