Ar an 15u la de mi 10, scriobh John P. Looney :
> -fpic, or not to -fpic ?
>
> I just noticed that I had a Makefile of shared lib I was using without
> any mention of "-fpic". Does GCC generate it by default now or something ?
> Because it was working fine, and "gcc -shared" didn't moan at me...
>
Depends on the architecture, I think. Ah, here we are ... OpenBSD
sparc,
12:37PM ~ > make c.o
cc -Wall -W -Wshadow -Wformat -pedantic -O3 -g -c c.c
c.c: In function `our_main':
c.c:12: warning: flag `#' used with type `p'
12:37PM ~ > cc -shared -o c.so c.o
ld: c.o: RRS text relocation at 0x30 for "_malloc"
ld: c.o: RRS text relocation at 0x40 for "_printf"
12:38PM ~ > # (fails) .
12:38PM ~ > cc -Wall -W -Wshadow -Wformat -pedantic -O3 -g -fPIC -c c.c
c.c: In function `our_main':
c.c:12: warning: flag `#' used with type `p'
12:38PM ~ > cc -shared -o c.so c.o
12:38PM ~ > file c.so
c.so: OpenBSD/sparc demand paged shared library not stripped
12:38PM ~ >
vs. Red Hat Linux release 6.1 ;
7:40am ~ > cc -Wall -W -Wshadow -Wformat -pedantic -O3 -g -c c.c
c.c: In function `our_main':
c.c:12: warning: flag `#' used with type `p'
7:40am ~ > cc -shared -o c.so c.o
7:40am ~ > file c.so
c.so: ELF 32-bit LSB shared object, Intel 80386, version 1, not stripped
7:40am ~ >
Has someone got Linux on another architecture kicking around to
verify that?
--
`... when the elephant man broke strong men's necks, when he'd had too
many Powers, ...'
Maintained by the ILUG website team. The aim of Linux.ie is to
support and help commercial and private users of Linux in Ireland. You can
display ILUG news in your own webpages, read backend
information to find out how. Networking services kindly provided by HEAnet, server kindly donated by
Dell. Linux is a trademark of Linus Torvalds,
used with permission. No penguins were harmed in the production or maintenance
of this highly praised website. Looking for the
Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!