Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #104805
| From | BartC <bc@freeuk.com> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: How to produce standalone executable using Code::Blocks/Clang ? |
| Date | 2017-02-27 01:04 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <o8vtqu$39t$1@dont-email.me> (permalink) |
| References | <o8u3kk$vs$1@dont-email.me> <o8uloa$l66$1@dont-email.me> <20170227011240.c55a6462c9edd21774c2892e@gmail.com> |
On 27/02/2017 00:12, GOTHIER Nathan wrote: > On Sun, 26 Feb 2017 14:40:17 +0100 > David Brown <david.brown@hesbynett.no> wrote: > >> The "-static" flag for gcc asks it to use static linking rather than >> using dynamic .so libraries. You have to have the right static >> libraries available, of course. Static linking can result in >> executables that are marginally faster, and they become independent of >> the .so files - but they are /much/ bigger. (On my system, a "Hello >> world" with dynamic linking is about 8.6K, with static linking it is 900K.) > > Maybe 900 kilo-octets is sensibly bigger than 8,6 kilo-octets but it is > ridiculous to save 891,4 kilo-octets with common storage medias over > 1 Tera-octets while wasting processor's time in loading libraries. That doesn't follow. Maybe the libraries in question are already loaded. Then there is no extra overhead to use them when dynamically linked. Or maybe the libraries are already loaded, and the statically linked executable then loads its own copies too! And maybe there are a dozen programs all statically linked that have a dozen copies of the libraries between them. Maybe those programs are also loaded thousands of times a day. Or, assuming dynamic libraries are loaded on-demand (as happens in my apps; the loading happens the first time a function in the library is called), then it could be that 90% of the time, the library is not needed, or is not needed immediately. But a statically linked executable would effectively load it anyway and delay start-up. Multiply that by the number of programs linked like that, and by the number of times they are loaded. And the 900KB example was for Hello World. A real application might be a lot bigger. There would need to be a good reason to statically link like this, for example if the libraries in question were not standard, so as to save some hassle for the user. But then they could just be bundled with the program instead of being part of it. -- bartc
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
How to produce standalone executable using Code::Blocks/Clang ? MehdiAmini <atorrses@gmail.com> - 2017-02-26 12:01 +0330
Re: How to produce standalone executable using Code::Blocks/Clang ? fir <profesor.fir@gmail.com> - 2017-02-26 01:55 -0800
Re: How to produce standalone executable using Code::Blocks/Clang ? fir <profesor.fir@gmail.com> - 2017-02-26 03:35 -0800
Re: How to produce standalone executable using Code::Blocks/Clang ? David Brown <david.brown@hesbynett.no> - 2017-02-26 14:40 +0100
Re: How to produce standalone executable using Code::Blocks/Clang ? BartC <bc@freeuk.com> - 2017-02-26 14:13 +0000
Re: How to produce standalone executable using Code::Blocks/Clang ? David Brown <david.brown@hesbynett.no> - 2017-02-26 17:26 +0100
Re: How to produce standalone executable using Code::Blocks/Clang ? BartC <bc@freeuk.com> - 2017-02-26 16:56 +0000
Re: How to produce standalone executable using Code::Blocks/Clang ? David Brown <david.brown@hesbynett.no> - 2017-02-26 19:00 +0100
Re: How to produce standalone executable using Code::Blocks/Clang ? scott@slp53.sl.home (Scott Lurndal) - 2017-02-27 15:16 +0000
Re: How to produce standalone executable using Code::Blocks/Clang ? scott@slp53.sl.home (Scott Lurndal) - 2017-02-27 15:12 +0000
Re: How to produce standalone executable using Code::Blocks/Clang ? David Brown <david.brown@hesbynett.no> - 2017-02-27 16:43 +0100
Re: How to produce standalone executable using Code::Blocks/Clang ? GOTHIER Nathan <nathan.gothier@gmail.com> - 2017-02-27 01:12 +0100
Re: How to produce standalone executable using Code::Blocks/Clang ? BartC <bc@freeuk.com> - 2017-02-27 01:04 +0000
Re: How to produce standalone executable using Code::Blocks/Clang ? GOTHIER Nathan <nathan.gothier@gmail.com> - 2017-02-27 06:05 +0100
Re: How to produce standalone executable using Code::Blocks/Clang ? David Brown <david.brown@hesbynett.no> - 2017-02-27 10:27 +0100
Re: How to produce standalone executable using Code::Blocks/Clang ? GOTHIER Nathan <nathan.gothier@gmail.com> - 2017-02-27 12:21 +0100
Re: How to produce standalone executable using Code::Blocks/Clang ? BartC <bc@freeuk.com> - 2017-02-27 12:14 +0000
Re: How to produce standalone executable using Code::Blocks/Clang ? GOTHIER Nathan <nathan.gothier@gmail.com> - 2017-02-27 14:27 +0100
Re: How to produce standalone executable using Code::Blocks/Clang ? David Brown <david.brown@hesbynett.no> - 2017-02-27 13:55 +0100
Re: How to produce standalone executable using Code::Blocks/Clang ? Ike Naar <ike@iceland.freeshell.org> - 2017-02-27 08:26 +0000
Re: How to produce standalone executable using Code::Blocks/Clang ? GOTHIER Nathan <nathan.gothier@gmail.com> - 2017-02-27 12:25 +0100
Re: How to produce standalone executable using Code::Blocks/Clang ? Ike Naar <ike@iceland.freeshell.org> - 2017-02-27 15:24 +0000
Re: How to produce standalone executable using Code::Blocks/Clang ? David Brown <david.brown@hesbynett.no> - 2017-02-27 10:22 +0100
Re: How to produce standalone executable using Code::Blocks/Clang ? scott@slp53.sl.home (Scott Lurndal) - 2017-02-27 15:20 +0000
Re: How to produce standalone executable using Code::Blocks/Clang ? fir <profesor.fir@gmail.com> - 2017-02-27 07:45 -0800
Re: How to produce standalone executable using Code::Blocks/Clang ? fir <profesor.fir@gmail.com> - 2017-02-27 08:12 -0800
Re: How to produce standalone executable using Code::Blocks/Clang ? MehdiAmini <atorrses@gmail.com> - 2017-02-27 10:54 +0330
csiph-web