This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: .a file not linking correctly
- From: Jonathan Wakely <jwakely dot gcc at gmail dot com>
- To: Marcelo Utikawa da Fonseca <utikawa at gmail dot com>
- Cc: gcc-help <gcc-help at gcc dot gnu dot org>
- Date: Wed, 1 Apr 2015 14:20:37 +0100
- Subject: Re: .a file not linking correctly
- Authentication-results: sourceware.org; auth=none
- References: <CAFGkvJ4BB=6ETx=zLBQZGvqKyuLmOoW_Yz-f59hDZ-VFZ5H7TQ at mail dot gmail dot com>
On 1 April 2015 at 14:15, Marcelo Utikawa da Fonseca wrote:
> Hi!
>
> I am new to the list but I work with gcc and cross-compiling for
> several years. Now I am facing something new: I can generate a .elf
> file from *.o files. If I join the same files in a .a file and try to
> use it instead of *.o files, I always get an empty file. Please note:
> it is not an zero size file, just empty elf... It is a valid .elf file
> but without any sections.
Does anything in your poptools.c file actually refer to any symbols
defined in the .a archive?
If not, the linker will not need to search the archive and so will not
include any of the archive contents in the output.
You can use -Wl,--whole-archive libpop.a -Wl,--no-whole-archive to
force the linker to include everything in the archive even if it isn't
needed.