CMake IA64 FPIC problem: Difference between revisions

From KitwarePublic
Jump to navigationJump to search
No edit summary
(Add explicit preformat markup)
Line 1: Line 1:
bar.c:
bar.c:
<pre>
  int i = 0;
  int i = 0;
  void bar()
  void bar()
Line 5: Line 6:
   i = 5;
   i = 5;
   }
   }
</pre>


foo.c:
foo.c:
<pre>
  extern void bar();
  extern void bar();
  void foo()
  void foo()
Line 12: Line 15:
   bar();
   bar();
   }
   }
</pre>


Compiled with
Compiled with


<pre>
  rm -f libbar.a *.o
  rm -f libbar.a *.o
  gcc -c bar.c
  gcc -c bar.c
Line 20: Line 25:
  gcc -c foo.c
  gcc -c foo.c
  gcc -shared -o libfoo.so foo.o -L. -lbar
  gcc -shared -o libfoo.so foo.o -L. -lbar
</pre>


Will fail:
Will fail:
<pre>
  /usr/bin/ld: bar.o: @gprel relocation against dynamic symbol i collect2: ld returned 1 exit status
  /usr/bin/ld: bar.o: @gprel relocation against dynamic symbol i collect2: ld returned 1 exit status
</pre>


But, putting:
But, putting:


<pre>
  gcc -fPIC -c bar.c
  gcc -fPIC -c bar.c
</pre>


works.
works.


{{CMake/Template/Footer}}
{{CMake/Template/Footer}}

Revision as of 18: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.



CMake: [Welcome | Site Map]