> I would like to distribute my application and therefore I > would like to create a statically linked executable (to the > extent possible) to minimize dependency problems. > > I'm able to link everything statically except -X11 and > -lpthread. Trying to statically link these is causing me > serious headache.
I would recommend that you do not link statically to pthread, or indeed X11. Now, in general, I'm a big fan of static linking, but where your code has to interact with the underlying operating system, then it is best to try and use the libs that match the OS versions, so dynamic linking is the best option. This is particularly true of pthread, for example. That said, both X11 and pthread have stable API's, so static linking *can* work, but the same fact makes it less immediately useful as you are unlikely to encounter dependency issues with these libs, since they are stable... > Perhaps a more general question -- am I following the right > way by trying to statically link everything or is there a better way? It really depends on what you are hoping to achieve, and what platform you are targeting. - If you know your targets always have, for example, libpng installed, then linking to the shared version is probably fine. But if you suspect that some targets (e.g. win32 hosts) might not have libpng, then static linking makes sense as the png lib is fairly small and linking to it will make your application more portable. - But, if the lib is GPL'd, then dynamic linking may be your only option, as statically linking to a GPL'd lib may not be practical for your deployment use. - System libs (e.g. pthread, X11, etc.) it probably makes sense to dynamic link to, to ensure you get what matches the running host. - fltk itself I usually static link - most distros still push out a very ancient version (if they have it at all) so that's the safest bet. - Don't get confused by the size issue. Many folks will tell you that dynamic linking makes for smaller executables with lower memory footprints. DO NOT believe them. If you are *really* worried about memory and storage space, measure it on a case by case basis, it will vary. In particular, if your app is binding dynamically to a shared object, quite a lot of linkage information has to be retained in the exe to do that, which can often be bigger than you would have got by static linking then stripping the final exe... - and so on... SELEX Sensors and Airborne Systems Limited Registered Office: Sigma House, Christopher Martin Road, Basildon, Essex SS14 3EL A company registered in England & Wales. Company no. 02426132 ******************************************************************** This email and any attachments are confidential to the intended recipient and may also be privileged. If you are not the intended recipient please delete it from your system and notify the sender. You should not copy it or use it for any purpose nor disclose or distribute its contents to any other person. ******************************************************************** _______________________________________________ fltk mailing list [email protected] http://lists.easysw.com/mailman/listinfo/fltk

