CMake IA64 FPIC problem: Difference between revisions
From KitwarePublic
Jump to navigationJump to search
(Add explicit preformat markup) |
(Remove leading space rectangles from preformatted blocks) |
||
Line 1: | Line 1: | ||
bar.c: | bar.c: | ||
<pre> | <pre> | ||
int i = 0; | |||
void bar() | |||
{ | |||
i = 5; | |||
} | |||
</pre> | </pre> | ||
foo.c: | foo.c: | ||
<pre> | <pre> | ||
extern void bar(); | |||
void foo() | |||
{ | |||
bar(); | |||
} | |||
</pre> | </pre> | ||
Line 20: | Line 20: | ||
<pre> | <pre> | ||
rm -f libbar.a *.o | |||
gcc -c bar.c | |||
ar cr libbar.a bar.o | |||
gcc -c foo.c | |||
gcc -shared -o libfoo.so foo.o -L. -lbar | |||
</pre> | </pre> | ||
Will fail: | Will fail: | ||
<pre> | <pre> | ||
/usr/bin/ld: bar.o: @gprel relocation against dynamic symbol i collect2: ld returned 1 exit status | |||
</pre> | </pre> | ||
Line 35: | Line 35: | ||
<pre> | <pre> | ||
gcc -fPIC -c bar.c | |||
</pre> | </pre> | ||
Revision as of 21:04, 20 April 2018
bar.c:
int i = 0; void bar() { i = 5; }
foo.c:
extern void bar(); void foo() { bar(); }
Compiled with
rm -f libbar.a *.o gcc -c bar.c ar cr libbar.a bar.o gcc -c foo.c gcc -shared -o libfoo.so foo.o -L. -lbar
Will fail:
/usr/bin/ld: bar.o: @gprel relocation against dynamic symbol i collect2: ld returned 1 exit status
But, putting:
gcc -fPIC -c bar.c
works.