unable to compile under fedora 32
Platform
Linux
Operating system and version: Fedora 32 OBS Studio version: git commit b20e71cddfbb074896ffc0e8ec672bd316408a21
Expected Behavior
OBS compiles
Current Behavior
OBS fails to compile because of multiply defined symbol
/usr/bin/ld: CMakeFiles/glad.dir/src/glad_glx.c.o:/home/lucag/Src/obs-studio/deps/glad/src/glad_glx.c:38: multiple definition of `gladGetProcAddressPtr'; CMakeFiles/glad.dir/src/glad.c.o:/home/lucag/Src/obs-studio/deps/glad/src/glad.c:38: first defined here
Steps to Reproduce
- clone (and init) the git repository
- mkdir build && cd build && cmake ..
- make 4.
Additional information
In deps/glad/src/glad_glx.c line 38 gladGetProcAddressPtr should be declared as extern in order to avoid the conflict.
Incidentally, replacing PFNGLXGETPROCADDRESSPROC_PRIVATE gladGetProcAddressPtr; with extern PFNGLXGETPROCADDRESSPROC_PRIVATE gladGetProcAddressPtr; seems not to have adverse effects and obs works as expected.
If you add --fcommon to the CMAKE_C_FLAGS and to CMAKE_CXX_FLAG in ./CMakeLists.txt it will compile on F32.
The issue is that F32 provides gcc10, and gcc10 swapped the default value of the -fcommon flag to -fno-common. Explicitly setting it back allows the code to compile and run.
iff --git a/CMakeLists.txt b/CMakeLists.txt
index b56c2bba..43c64cc6 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -135,8 +135,8 @@ else()
endif()
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANG)
- set(CMAKE_CXX_FLAGS "-Wall -Wextra -Wvla -Wno-unused-function -Wno-missing-field-initializers ${CMAKE_CXX_FLAGS} -fno-strict-aliasing")
- set(CMAKE_C_FLAGS "-Wall -Wextra -Wvla -Wno-unused-function -Werror-implicit-function-declaration -Wno-missing-braces -Wno-missing-field-initializers ${CMAKE_C_FLAGS} -std=gnu99 -fno-strict-aliasing")
+ set(CMAKE_CXX_FLAGS "-Wall -Wextra -Wvla -Wno-unused-function -Wno-missing-field-initializers ${CMAKE_CXX_FLAGS} -fno-strict-aliasing -fcommon")
+ set(CMAKE_C_FLAGS "-Wall -Wextra -Wvla -Wno-unused-function -Werror-implicit-function-declaration -Wno-missing-braces -Wno-missing-field-initializers ${CMAKE_C_FLAGS} -std=gnu99 -fno-strict-aliasing -fcommon")
option(USE_LIBC++ "Use libc++ instead of libstdc++" ${APPLE})
if(USE_LIBC++)
I was going to submit a PR, but I have to read the contributing page and do all the necessary stuff. I'll do that tonight if no one beats me to it.
https://gcc.gnu.org/gcc-10/changes.html
The comments on PR 2834 are correct. The appropriate way to fix this is to make one of the declarations extern:
diff --git a/deps/glad/src/glad_glx.c b/deps/glad/src/glad_glx.c
index 7c55b9fc..58086f10 100644
--- a/deps/glad/src/glad_glx.c
+++ b/deps/glad/src/glad_glx.c
@@ -35,7 +35,7 @@ static void* libGL;
#ifndef __APPLE__
typedef void* (APIENTRYP PFNGLXGETPROCADDRESSPROC_PRIVATE)(const char*);
-PFNGLXGETPROCADDRESSPROC_PRIVATE gladGetProcAddressPtr;
+extern PFNGLXGETPROCADDRESSPROC_PRIVATE gladGetProcAddressPtr;
#endif
static
PR coming tomorrow.
Tnx, ran into this today, this helps a lot!
The pull request to apply the compiler flag was closed unmerged: https://github.com/obsproject/obs-studio/pull/2834#event-3287188240
This issue still can be fixed with the patch above: https://github.com/obsproject/obs-studio/issues/2828#issuecomment-621594573
I still have a branch with the same fix from February, but I can't remember why I didn't push it here back then... it does seem to work now.
I guess I'll create a pull request soon, unless someone else gets to it first. :]