obs-studio icon indicating copy to clipboard operation
obs-studio copied to clipboard

unable to compile under fedora 32

Open lucag73 opened this issue 6 years ago • 8 comments

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

  1. clone (and init) the git repository
  2. mkdir build && cd build && cmake ..
  3. 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.

lucag73 avatar Apr 29 '20 09:04 lucag73

Incidentally, replacing PFNGLXGETPROCADDRESSPROC_PRIVATE gladGetProcAddressPtr; with extern PFNGLXGETPROCADDRESSPROC_PRIVATE gladGetProcAddressPtr; seems not to have adverse effects and obs works as expected.

lucag73 avatar Apr 29 '20 10:04 lucag73

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++)

markllama avatar Apr 29 '20 11:04 markllama

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.

markllama avatar Apr 29 '20 12:04 markllama

https://gcc.gnu.org/gcc-10/changes.html

markllama avatar Apr 29 '20 12:04 markllama

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.

markllama avatar Apr 30 '20 03:04 markllama

Tnx, ran into this today, this helps a lot!

arjenpdevries avatar May 02 '20 20:05 arjenpdevries

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

arjenpdevries avatar May 03 '20 19:05 arjenpdevries

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. :]

Chiitoo avatar May 03 '20 22:05 Chiitoo