Hi!
In the following line in flextGL.h, the flextGL global variable has the attribute FLEXTGL_EXPORT which is the empty CORRADE_VISIBILITY_STATIC when the build is static (hence the symbol is hidden, following the -fvisibility compile flag):
|
extern FLEXTGL_EXPORT FlextGL flextGL; |
But since it's a global and we could make a shared library against a static build of Magnum, shouldn't we check for MAGNUM_BUILD_STATIC_UNIQUE_GLOBALS just like in GL/Context.cpp ?
|
#if defined(MAGNUM_BUILD_STATIC_UNIQUE_GLOBALS) && !defined(CORRADE_TARGET_WINDOWS) |
|
/* On static builds that get linked to multiple shared libraries and then used |
|
in a single app we want to ensure there's just one global symbol. On Linux |
|
it's apparently enough to just export, macOS needs the weak attribute. |
|
Windows handled differently below. */ |
|
CORRADE_VISIBILITY_EXPORT |
|
#ifdef CORRADE_TARGET_GCC |
|
__attribute__((weak)) |
|
#else |
|
/* uh oh? the test will fail, probably */ |
|
#endif |
|
#endif |
|
Context* currentContext = nullptr; |
I tried the following change where the global's visibility is set to default when we require unique globals:
extern
#if defined(MAGNUM_BUILD_STATIC_UNIQUE_GLOBALS) && !defined(CORRADE_TARGET_WINDOWS)
CORRADE_VISIBILITY_EXPORT
#else
FLEXTGL_EXPORT
#endif
FlextGL flextGL;
Or maybe the FLEXTGL_EXPORT macro should be changed? For me, the above fixed a segmentation fault issue I was having when instantiating a custom shader defined in my shared library (linked against a static build of Magnum, working on Ubuntu with clang). I saw that there's a mention of FlextGL symbols in #453.
Hi!
In the following line in flextGL.h, the
flextGLglobal variable has the attributeFLEXTGL_EXPORTwhich is the emptyCORRADE_VISIBILITY_STATICwhen the build is static (hence the symbol is hidden, following the-fvisibilitycompile flag):magnum/src/MagnumExternal/OpenGL/GL/flextGL.h
Line 2629 in b141901
But since it's a global and we could make a shared library against a static build of Magnum, shouldn't we check for
MAGNUM_BUILD_STATIC_UNIQUE_GLOBALSjust like inGL/Context.cpp?magnum/src/Magnum/GL/Context.cpp
Lines 672 to 684 in b141901
I tried the following change where the global's visibility is set to default when we require unique globals:
Or maybe the
FLEXTGL_EXPORTmacro should be changed? For me, the above fixed a segmentation fault issue I was having when instantiating a custom shader defined in my shared library (linked against a static build of Magnum, working on Ubuntu with clang). I saw that there's a mention of FlextGL symbols in #453.