Menu

#256 gcc 10 link error

None
closed-invalid
nobody
None
5
2021-12-22
2020-05-18
No

Linking with gcc 10 is failing because it is defaulting to -fno-common, I'm using next patch:

diff --git a/src/fg_gl2.h b/src/fg_gl2.h
index ab8ba5c..a1a52da 100644
--- a/src/fg_gl2.h
+++ b/src/fg_gl2.h
@@ -67,13 +67,19 @@ typedef void (APIENTRY *FGH_PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint index);
 typedef void (APIENTRY *FGH_PFNGLDISABLEVERTEXATTRIBARRAYPROC) (GLuint);
 typedef void (APIENTRY *FGH_PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer);

-FGH_PFNGLGENBUFFERSPROC fghGenBuffers;
-FGH_PFNGLDELETEBUFFERSPROC fghDeleteBuffers;
-FGH_PFNGLBINDBUFFERPROC fghBindBuffer;
-FGH_PFNGLBUFFERDATAPROC fghBufferData;
-FGH_PFNGLENABLEVERTEXATTRIBARRAYPROC fghEnableVertexAttribArray;
-FGH_PFNGLDISABLEVERTEXATTRIBARRAYPROC fghDisableVertexAttribArray;
-FGH_PFNGLVERTEXATTRIBPOINTERPROC fghVertexAttribPointer;
+#if __GNUC__ > 9
+#define FG_ATTRIBUTE_COMMON __attribute__((__common__))
+#else
+#define FG_ATTRIBUTE_COMMON
+#endif
+
+FGH_PFNGLGENBUFFERSPROC FG_ATTRIBUTE_COMMON fghGenBuffers;
+FGH_PFNGLDELETEBUFFERSPROC FG_ATTRIBUTE_COMMON fghDeleteBuffers;
+FGH_PFNGLBINDBUFFERPROC FG_ATTRIBUTE_COMMON fghBindBuffer;
+FGH_PFNGLBUFFERDATAPROC FG_ATTRIBUTE_COMMON fghBufferData;
+FGH_PFNGLENABLEVERTEXATTRIBARRAYPROC FG_ATTRIBUTE_COMMON fghEnableVertexAttribArray;
+FGH_PFNGLDISABLEVERTEXATTRIBARRAYPROC FG_ATTRIBUTE_COMMON fghDisableVertexAttribArray;
+FGH_PFNGLVERTEXATTRIBPOINTERPROC FG_ATTRIBUTE_COMMON fghVertexAttribPointer;

 #    endif

but it is better to move definitions to .c file

Discussion

  • John Tsiombikas

    John Tsiombikas - 2020-05-18
    • status: open --> closed-invalid
    • Group: -->
     
  • John Tsiombikas

    John Tsiombikas - 2020-05-18

    This was fixed in SVN revision 1863.

     
  • Keith Marshall

    Keith Marshall - 2021-12-22

    FWIW, I encountered the same issue when attempting to build freeglut-3.2.1 on Arch Linux, with GCC-11.1, and came up with much the same work-around as the OP. I agree that your SVN-1863 update is a much better solution; however, while investigating, I did notice that the src/fg_gl2.h file header incorrectly identifies the file as fg_gl2.c, and that's still wrong in SVN. Not a big deal, I realize, but you may want to correct it some time.

     
    • John Tsiombikas

      John Tsiombikas - 2021-12-22

      I didn't even notice we had the filenames at the top of each file. That's bizarre :) Anyway I just fixed that too...

       

Log in to post a comment.