Hi,
I am new to LLVM. I am trying to read a plain text file in a llvm
pass. But getting an error -
llvm[0]: Linking Release Loadable Module LLVMHello.so
/usr/bin/ld:
/home/abhirup/llvm/llvm2.8_Install/llvm-2.8/lib/Transforms/Hello/Release/Hello.o:
relocation R_X86_64_PC32 against undefined symbol `(anonymous
namespace)::Hello::update_sec_read(char const*)' can not be used when
making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value
collect2: ld returned 1 exit status
I have used simple ifstream code -
void update_sec_read (const char* Filename)
{
std::ifstream In(Filename);
if (!In.good()) {
errs() << "couldn't load file '" << Filename
<< "'!\n";
return;
}
while (In) {
}
}
Can anyone please help me out?
- Abhirup Ghosh
M. Tech
Department of Computer Science & Engg.
IIT, Bombay,
Mumbai, India
email - abhirupju at gmail.com , abhirup at cse.iitb.ac.in
Hi Abhirup, `(anonymous> namespace)::Hello::update_sec_read(char const*)' can not be used when > making a shared object; recompile with -fPICdid you compile it with -fPIC ? Ciao, Duncan.
Hi Abhirup, please reply to the mailing list and not just to me personally (that way others can answer too, and the discussion is archived which helps other people with the same problem).> How to compile with -fPIC? I am new to llvm so can you please elaborate?This has nothing to do with LLVM: -fPIC is a gcc option needed to build code that is to be part of a dynamic library. So just add it to the other options you use when compiling your program. Best wishes, Duncan.> > Abhirup Ghosh > M. Tech > Department of Computer Science& Engg. > IIT, Bombay > email - abhirupju at gmail.com , abhirup at cse.iitb.ac.in > > > > On Mon, Jan 17, 2011 at 2:41 PM, Duncan Sands<baldrick at free.fr> wrote: >> Hi Abhirup, >> >> `(anonymous >>> namespace)::Hello::update_sec_read(char const*)' can not be used when >>> making a shared object; recompile with -fPIC >> >> did you compile it with -fPIC ? >> >> Ciao, Duncan. >> _______________________________________________ >> LLVM Developers mailing list >> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >>