
2009/12/2 OvermindDL1 <overminddl1@gmail.com>:
On Wed, Dec 2, 2009 at 9:02 AM, David Bergman I do the same for Visual Studio, I have debugging turned on in both Debug and Release, thankfully the debug data is stored in a separate file and not in the application file so when I distribute then I do not have to include that usually massive debug file. Is there not a way to make it an external information file in GCC as in VS?
There is a way. From the manpage for "strip": ---- 1. Link the executable as normal. Assuming that is is called "foo" then... 2. Run "objcopy --only-keep-debug foo foo.dbg" to create a file containing the debugging info. 3. Run "objcopy --strip-debug foo" to create a stripped executable. 4. Run "objcopy --add-gnu-debuglink=foo.dbg foo" to add a link to the debugging info into the stripped executable. Note---the choice of ".dbg" as an extension for the debug info file is arbitrary. Also the "--only-keep-debug" step is optional. You could instead do this: 1. Link the executable as normal. 2. Copy "foo" to "foo.full" 3. Run "strip --strip-debug foo" 4. Run "objcopy --add-gnu-debuglink=foo.full foo" i.e., the file pointed to by the --add-gnu-debuglink can be the full executable. It does not have to be a file created by the --only-keep-debug switch.