GillesDebunne / libQGLViewer

libQGLViewer is an open source C++ library based on Qt that eases the creation of OpenGL 3D viewers.
Other
245 stars 94 forks source link

How to build dylibs instead of Frameworks #49

Closed adamjstewart closed 3 years ago

adamjstewart commented 3 years ago

The instructions at http://libqglviewer.com/installUnix.html#mac say:

A Framework is created by default. Uncomment a line in QGLViewer.pro if you want to create a .dylib instead.

Presumably it is talking about this line: https://github.com/GillesDebunne/libQGLViewer/blob/master/QGLViewer/QGLViewer.pro#L215

However, the comment above this line says to comment out the line, not uncomment it. Regardless, whether I comment it out or not, it seems to build a Framework regardless. How can I build dylibs on macOS?

GillesDebunne commented 3 years ago

Yes, that should be the line, but the comment may be misleading. Try to simply use CONFIG *= lib_bundle to force the config.

GillesDebunne commented 3 years ago

EDIT : dylib is the default, while lib_bundle creates a Framework.

Commenting (or removing) this line and then running make clean ; qmake ; make does indeed create a dylib.

(just tested using qt 5.15.1)

adamjstewart commented 3 years ago

@GillesDebunne I tried both the default and CONFIG *= lib_bundle but both install a Framework for me. The installation logs for both don't even mention dylibs. This is for libqglviewer 2.7.2 on macOS 10.15.6 with Apple Clang 12.0.0 and Qt 5.14.2.

Here are the installation commands I'm running:

cd QGLViewer
qmake PREFIX=/path/to/prefix
make -j4
make -j4 install

In the installation prefix I see lib/QGLViewer.framework/Versions/Current/*, when I instead expect to see lib/libqglviewer.dylib or something like that. Is there something else I'm missing? I also tried qmake -spec macx-g++ as suggested in the docs, but that failed for me.

GillesDebunne commented 3 years ago

Using CONFIG *= lib_bundle will indeed create a Framework. This is what is configured by default in the .pro file, so you have to remove (or comment) that line in the .pro file to remove this option.

Also make sure your previous configuration is reset before running make again (hence the make clean in my example).

There is no direct option to create a dylib this since I understood Frameworks are more natural on Mac.

adamjstewart commented 3 years ago

So just to confirm, all of the following settings are designed to build a Framework:

and there is no way to build dylibs? Frameworks are more common for system libraries, but most packages managers like Homebrew and Spack install dylibs.

P.S. I'm adding a Spack build recipe for libqglviewer, so if you or any other developers would like to be listed as official "maintainers", let me know. You don't have to be a Spack expert, it just gives us someone to ping when a user reports build issues.

GillesDebunne commented 3 years ago

The first two will build a Framework, however the third line should create the dylib you want (that's what I tried).

Again make sure your previous build settings are reset, clone a fresh repo if needed.

adamjstewart commented 3 years ago

Huh, it seems to be working now. I was cloning a fresh repo every time, so I'm not sure why it wasn't working before. Sorry for the noise, and thanks for the help!