Re: PCH creation in the presence of linker flags

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Cesar Strauss <cstrauss@xxxxxxxxxxx> writes:

> Consider a simple header file like:
>
> echo "extern int test;" > test.h
>
> For generating a precompiled header, I find both methods below to work:
>
> gcc -c test.h
> gcc test.h
>
> If, however, I happen to use a linker flag on the command line:
>
> gcc -Wl,-s -c test.h
> gcc -Wl,-s test.h
>
> then, the first method works, but the second one (without -c) gives
> the following error:
>
> /usr/lib/gcc/i486-linux-gnu/4.4.1/../../../../lib/crt1.o: In function
> _start':
> /build/buildd/eglibc-2.10.1/csu/../sysdeps/i386/elf/start.S:115:
> undefined reference to `main'
> collect2: ld returned 1 exit status
>
> Is this supposed to work?

No.

Normally if you compile a .h file, gcc will not invoke the linker.
Also, when you use the -c option, gcc will not invoke the linker.
However, when you use an explicit -Wl option, and you do not use -c,
then gcc will invoke the linker, and running the linker on a
precompiled header does not work.

Ian

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux