Thread: FLTK static linking

  1. #1
    Registered User an96's Avatar
    Join Date
    Jun 2015
    Posts
    10

    FLTK static linking

    Hello,
    I want to statically compile this example from the FLTK tutorial:
    Code:
    #include <FL/Fl.H>
    #include <FL/Fl_Window.H>
    #include <FL/Fl_Box.H>
    
    int main(int argc, char **argv) {
      Fl_Window *window = new Fl_Window(340,180);
      Fl_Box *box = new Fl_Box(20,40,300,100,"Hello, World!");
      box->box(FL_UP_BOX);
      box->labelfont(FL_BOLD+FL_ITALIC);
      box->labelsize(36);
      box->labeltype(FL_SHADOW_LABEL);
      window->end();
      window->show(argc, argv);
      return Fl::run();
    }
    I have tried using this command, but I get only errors:
    Code:
    g++ -static filex.cxx `fltk-config --cxxflags --ldstaticflags`
    
    FLTK is a library originally designed for statically compiled applications, so it's strange that there is no documentation on this topic
    Last edited by an96; 08-30-2018 at 11:02 AM.

  2. #2
    Guest
    Guest
    Probably best to post the errors.

  3. #3
    Registered User an96's Avatar
    Join Date
    Jun 2015
    Posts
    10
    Sorry for my late reply, here are the errors:
    Code:
    alfredo@alfredo-pc:~/bin$ g++ -static filex.cxx `fltk-config --cxxflags --ldstaticflags`
    /usr/lib/x86_64-linux-gnu/libfltk.a(Fl_Preferences.o): En la función `Fl_Plugin_Manager::load(char const*)':
    (.text+0x2a6a): aviso: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
    /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libX11.a(GetDflt.o): En la función `GetHomeDir.part.0':
    (.text+0x4a): aviso: Using 'getpwnam_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
    (.text+0x93): aviso: Using 'getpwuid_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
    /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libX11.a(xim_trans.o): En la función `_XimXTransSocketINETConnect':
    (.text+0xe35): aviso: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
    /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libfontconfig.a(fcfreetype.o): En la función `FcFreeTypeUseNames':
    (.text+0xf5): referencia a `FT_Has_PS_Glyph_Names' sin definir
    /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libfontconfig.a(fcfreetype.o): En la función `FcFreeTypeCheckGlyph':
    (.text+0x193): referencia a `FT_Load_Glyph' sin definir
    /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libfontconfig.a(fcfreetype.o): En la función `FcFreeTypeCharSetAndSpacingForSize':
    (.text+0x26d): referencia a `FT_Select_Charmap' sin definir
    (.text+0x285): referencia a `FT_Get_First_Char' sin definir
    (.text+0x3f9): referencia a `FT_Get_Next_Char' sin definir
    (.text+0x487): referencia a `FT_Get_Glyph_Name' sin definir
    (.text+0x699): referencia a `FT_Select_Charmap' sin definir
    (.text+0x6b1): referencia a `FT_Get_First_Char' sin definir
    (.text+0x80e): referencia a `FT_Select_Size' sin definir
    /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libfontconfig.a(fcfreetype.o): En la función `IA__FcFreeTypeCharIndex':
    (.text+0xa64): referencia a `FT_Select_Charmap' sin definir
    (.text+0xa76): referencia a `FT_Get_Char_Index' sin definir
    (.text+0xbbb): referencia a `FT_Get_Char_Index' sin definir
    (.text+0xbf6): referencia a `FT_Get_Glyph_Name' sin definir
    /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libfontconfig.a(fcfreetype.o): En la función `IA__FcFreeTypeCharSetAndSpacing':
    (.text+0xc68): referencia a `FT_Get_Sfnt_Table' sin definir
    /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libfontconfig.a(fcfreetype.o): En la función `IA__FcFreeTypeQueryFace':
    (.text+0xe59): referencia a `FT_Get_Sfnt_Table' sin definir
    (.text+0xe9b): referencia a `FT_Get_Sfnt_Name_Count' sin definir
    (.text+0xf26): referencia a `FT_Get_Sfnt_Name' sin definir
    (.text+0x17e6): referencia a `FT_Get_MM_Var' sin definir
    (.text+0x19a5): referencia a `FT_Get_Postscript_Name' sin definir
    (.text+0x1a24): referencia a `FT_Get_Sfnt_Table' sin definir
    (.text+0x1bcd): referencia a `FT_Load_Sfnt_Table' sin definir
    (.text+0x2082): referencia a `FT_Get_PS_Font_Info' sin definir
    (.text+0x227f): referencia a `FT_Get_BDF_Property' sin definir
    (.text+0x2305): referencia a `FT_Get_BDF_Property' sin definir
    (.text+0x24ee): referencia a `FT_Get_BDF_Property' sin definir
    (.text+0x258c): referencia a `FT_Get_BDF_Property' sin definir
    (.text+0x25ca): referencia a `FT_Get_X11_Font_Format' sin definir
    (.text+0x26ca): referencia a `FT_Get_PS_Font_Info' sin definir
    (.text+0x2704): referencia a `FT_Get_BDF_Property' sin definir
    (.text+0x2730): referencia a `FT_Get_BDF_Property' sin definir
    (.text+0x2a61): referencia a `FT_Get_BDF_Property' sin definir
    /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libfontconfig.a(fcfreetype.o): En la función `IA__FcFreeTypeQuery':
    (.text+0x2aed): referencia a `FT_Init_FreeType' sin definir
    (.text+0x2b09): referencia a `FT_New_Face' sin definir
    (.text+0x2b17): referencia a `FT_Done_FreeType' sin definir
    (.text+0x2b62): referencia a `FT_Done_Face' sin definir
    /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libX11.a(xcb_io.o): En la función `require_socket.part.1':
    (.text+0x6fa): referencia a `xcb_take_socket' sin definir
    /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libX11.a(xcb_io.o): En la función `poll_for_event':
    (.text+0x815): referencia a `xcb_poll_for_event' sin definir
    /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libX11.a(xcb_io.o): En la función `poll_for_response':
    (.text+0x935): referencia a `xcb_poll_for_reply64' sin definir
    /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libX11.a(xcb_io.o): En la función `_XSend':
    (.text+0xbb2): referencia a `xcb_writev' sin definir
    /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libX11.a(xcb_io.o): En la función `_XEventsQueued':
    (.text+0xc8d): referencia a `xcb_connection_has_error' sin definir
    /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libX11.a(xcb_io.o): En la función `_XReadEvents':
    (.text+0xdbe): referencia a `xcb_connection_has_error' sin definir
    (.text+0xe54): referencia a `xcb_wait_for_event' sin definir
    /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libX11.a(xcb_io.o): En la función `_XAllocIDs':
    (.text+0xfef): referencia a `xcb_generate_id' sin definir
    /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libX11.a(xcb_io.o): En la función `_XReply':
    (.text+0x1154): referencia a `xcb_wait_for_reply64' sin definir
    /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libXcursor.a(cursor.o): En la función `XcursorImageLoadCursor':
    (.text+0x82d): referencia a `XRenderCreateCursor' sin definir
    /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libXcursor.a(cursor.o): En la función `XcursorImagesLoadCursor':
    (.text+0x1175): referencia a `XRenderCreateAnimCursor' sin definir
    /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libXft.a(xftdraw.o): En la función `XftDrawSrcPicture':
    (.text+0x8ed): referencia a `XRenderFillRectangle' sin definir
    /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libXft.a(xftdraw.o): En la función `XftDrawRect':
    (.text+0x16f5): referencia a `XRenderFillRectangle' sin definir
    /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libXft.a(xftfreetype.o): En la función `_XftLockFile':
    (.text+0x3e): referencia a `FT_New_Face' sin definir
    (.text+0xfd): referencia a `FT_Done_Face' sin definir
    /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libXft.a(xftfreetype.o): En la función `_XftReleaseFile.part.3':
    (.text+0x1ba): referencia a `FT_Done_Face' sin definir
    /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libXft.a(xftfreetype.o): En la función `XftFontDestroy':
    (.text+0x324): referencia a `XRenderFreeGlyphSet' sin definir
    /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libXft.a(xftfreetype.o): En la función `_XftSetFace':
    (.text+0x438): referencia a `FT_Set_Char_Size' sin definir
    (.text+0x472): referencia a `FT_Set_Transform' sin definir
    (.text+0x58c): referencia a `FT_Set_Char_Size' sin definir
    (.text+0x628): referencia a `FT_Set_Char_Size' sin definir
    /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libXft.a(xftfreetype.o): En la función `XftFontOpenInfo':
    (.text+0xce0): referencia a `FT_Vector_Transform' sin definir
    (.text+0xd16): referencia a `FT_Vector_Transform' sin definir
    (.text+0xd6a): referencia a `FT_Vector_Transform' sin definir
    (.text+0xdb2): referencia a `FT_Vector_Transform' sin definir
    /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libXft.a(xftfreetype.o): En la función `XftInitFtLibrary':
    (.text+0x101a): referencia a `FT_Init_FreeType' sin definir
    /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libXft.a(xftglyphs.o): En la función `XftFontLoadGlyphs':
    (.text+0x16f): referencia a `FT_Library_SetLcdFilter' sin definir
    (.text+0x184): referencia a `FT_Load_Glyph' sin definir
    (.text+0x1a5): referencia a `FT_Load_Glyph' sin definir
    (.text+0x273): referencia a `FT_Vector_Transform' sin definir
    (.text+0x34b): referencia a `FT_Render_Glyph' sin definir
    (.text+0x361): referencia a `FT_Library_SetLcdFilter' sin definir
    (.text+0x3c6): referencia a `FT_Vector_Transform' sin definir
    (.text+0x834): referencia a `FT_GlyphSlot_Embolden' sin definir
    (.text+0xdd0): referencia a `XRenderAddGlyphs' sin definir
    (.text+0xfc9): referencia a `XRenderCreateGlyphSet' sin definir
    /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libXft.a(xftglyphs.o): En la función `XftFontUnloadGlyphs':
    (.text+0x127e): referencia a `XRenderFreeGlyphs' sin definir
    (.text+0x129b): referencia a `XRenderFreeGlyphs' sin definir
    /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libXft.a(xftglyphs.o): En la función `_XftFontUncacheGlyph':
    (.text+0x1621): referencia a `XRenderFreeGlyphSet' sin definir
    /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libXft.a(xftrender.o): En la función `XftGlyphRender':
    (.text+0x1eb): referencia a `XRenderCompositeString8' sin definir
    (.text+0x251): referencia a `XRenderCompositeString32' sin definir
    (.text+0x2b6): referencia a `XRenderCompositeString16' sin definir
    /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libXft.a(xftrender.o): En la función `XftGlyphSpecRender':
    (.text+0x592): referencia a `XRenderCompositeText32' sin definir
    (.text+0x878): referencia a `XRenderCompositeText8' sin definir
    (.text+0x934): referencia a `XRenderCompositeText16' sin definir
    /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libXft.a(xftrender.o): En la función `XftGlyphFontSpecRender':
    (.text+0x10af): referencia a `XRenderCompositeText8' sin definir
    (.text+0x1167): referencia a `XRenderCompositeText32' sin definir
    (.text+0x11fa): referencia a `XRenderCompositeText16' sin definir
    /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libfontconfig.a(fcdir.o): En la función `FcFileScanConfig':
    (.text+0x1c8): referencia a `FT_Init_FreeType' sin definir
    (.text+0x216): referencia a `FT_New_Face' sin definir
    (.text+0x24f): referencia a `FT_Done_Face' sin definir
    (.text+0x339): referencia a `FT_Done_FreeType' sin definir
    /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libfontconfig.a(fcxml.o): En la función `FcConfigMessage':
    (.text+0x335): referencia a `XML_GetCurrentLineNumber' sin definir
    (.text+0x3b1): referencia a `XML_GetCurrentLineNumber' sin definir
    /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libfontconfig.a(fcxml.o): En la función `FcConfigParseAndLoadFromMemoryInternal':
    (.text+0x1469): referencia a `XML_ParserCreate' sin definir
    (.text+0x14c6): referencia a `XML_SetUserData' sin definir
    (.text+0x14dc): referencia a `XML_SetDoctypeDeclHandler' sin definir
    (.text+0x14f2): referencia a `XML_SetElementHandler' sin definir
    (.text+0x1501): referencia a `XML_SetCharacterDataHandler' sin definir
    (.text+0x1511): referencia a `XML_GetBuffer' sin definir
    (.text+0x1574): referencia a `XML_ParseBuffer' sin definir
    (.text+0x1580): referencia a `XML_GetErrorCode' sin definir
    (.text+0x1587): referencia a `XML_ErrorString' sin definir
    (.text+0x15c4): referencia a `XML_ParserFree' sin definir
    (.text+0x166f): referencia a `XML_ParseBuffer' sin definir
    /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libX11.a(ClDisplay.o): En la función `XCloseDisplay':
    (.text+0xd3): referencia a `xcb_disconnect' sin definir
    /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libX11.a(OpenDis.o): En la función `OutOfMemory':
    (.text+0x3b4): referencia a `xcb_disconnect' sin definir
    /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libX11.a(OpenDis.o): En la función `XOpenDisplay':
    (.text+0x7fa): referencia a `xcb_get_setup' sin definir
    (.text+0xd88): referencia a `xcb_get_maximum_request_length' sin definir
    /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/libX11.a(xcb_disp.o): En la función `_XConnectXCB':
    (.text+0x16c): referencia a `xcb_parse_display' sin definir
    (.text+0x1e0): referencia a `xcb_connect_to_display_with_auth_info' sin definir
    (.text+0x200): referencia a `xcb_get_file_descriptor' sin definir
    (.text+0x21c): referencia a `xcb_generate_id' sin definir
    (.text+0x27b): referencia a `pthread_cond_init' sin definir
    (.text+0x28d): referencia a `pthread_cond_init' sin definir
    (.text+0x295): referencia a `xcb_connection_has_error' sin definir
    (.text+0x2b6): referencia a `xcb_connect' sin definir
    collect2: error: ld returned 1 exit status

  4. #4
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    Quote Originally Posted by an96 View Post
    Sorry for my late reply, here are the errors:
    Code:
    alfredo@alfredo-pc:~/bin$ g++ -static filex.cxx `fltk-config --cxxflags --ldstaticflags`
    /usr/lib/x86_64-linux-gnu/libfltk.a(Fl_Preferences.o): En la función `Fl_Plugin_Manager::load(char const*)':
    (.text+0x2a6a): aviso: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
    The error message is complaining about the gcc option "-static".

    Try building without it.

    Tim S.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

  5. #5
    Registered User an96's Avatar
    Join Date
    Jun 2015
    Posts
    10
    Quote Originally Posted by stahta01 View Post
    The error message is complaining about the gcc option "-static".

    Try building without it.

    Tim S.
    But then I would get a dynamically-linked executable, which is not useful for what I want to do

  6. #6
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    Quote Originally Posted by an96 View Post
    But then I would get a dynamically-linked executable, which is not useful for what I want to do
    Then you need to build all the Libraries that need the GCC dynamic library from scratch using the "-static" option.

    Tim S.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

  7. #7
    Registered User
    Join Date
    May 2010
    Posts
    4,632
    What exactly are you trying to link statically? FLTK, the standard libaries, or both?

    Edit: By the way were are your -L and -l flags telling the linker where to find the various libraries?
    Last edited by jimblumberg; 09-03-2018 at 03:18 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. SFML - Static Linking
    By c_lover in forum C++ Programming
    Replies: 1
    Last Post: 08-07-2015, 02:59 PM
  2. static library linking
    By jcfuller in forum C Programming
    Replies: 4
    Last Post: 10-07-2014, 10:43 AM
  3. RPM Depencies and static linking
    By SomeNYCGuy in forum Linux Programming
    Replies: 2
    Last Post: 12-06-2009, 12:58 PM
  4. static linking with Dev-c++/gcc
    By silk.odyssey in forum C Programming
    Replies: 6
    Last Post: 12-14-2003, 01:28 PM
  5. Static Linking/Borland
    By Unregistered in forum Windows Programming
    Replies: 1
    Last Post: 01-16-2002, 03:17 PM

Tags for this Thread