<div dir="ltr"><div>Hi everyone,</div><div><br></div><div><b>1.</b> I had a file called server.cpp that i can run using:</div><div> g++ -o server server.cpp -lrpc -ldl -lpthread</div><div><br></div><div><b>2.</b>
 Converted the file into LLVM IR, modified it and saved to file using 
the WriteBitcodeToFile function. The name of resulting file is "output".<br></div><div><br></div><div><b>3.</b> Used llc command for generation of "output.o" file as:<br></div><div> llc -filetype=obj output</div><div><br></div><div><b>4.</b> Used gcc command to create executable as:</div><div>gcc -lrpc -ldl -lpthread output.o</div><div><br></div><div><b>Running gcc command gives me errors:</b></div><div>/usr/bin/ld:
 output.o: relocation R_X86_64_32 against `.rodata.str1.1' can not be 
used when making a PIE object; recompile with -fPIC<br>/usr/bin/ld: final link failed: nonrepresentable section on output<br>collect2: error: ld returned 1 exit status</div><div><br></div><div><b>5.</b>
 Tried it by giving "--relocation-model=pic" flag to llc command. But if
 i run gcc command after that I get so many "<b>undefined reference to</b>" 
errors like:</div><div>/usr/bin/ld: output.o: in function `main':<br>llvm-link:(.text+0x41): undefined reference to `rpc::server::server(unsigned short)'<br>/usr/bin/ld: llvm-link:(.text+0x4d): undefined reference to `std::allocator<char>::allocator()'<br>/usr/bin/ld: llvm-link:(.text+0x60): undefined reference to `std::__cxx11::basic_string<char,
 std::char_traits<char>, std::allocator<char> 
>::basic_string(char const*, std::allocator<char> const&)'<br>/usr/bin/ld: llvm-link:(.text+0x81): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'<br>/usr/bin/ld: llvm-link:(.text+0x8a): undefined reference to `std::allocator<char>::~allocator()'<br>/usr/bin/ld: llvm-link:(.text+0x93): undefined reference to `rpc::server::run()'<br>/usr/bin/ld: llvm-link:(.text+0xa5): undefined reference to `rpc::server::~server()'<br>/usr/bin/ld: llvm-link:(.text+0xc8): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'</div><div><br></div><div>Someone please help me with this. Been stuck on it for so long.</div><div>If i don't have any external libraries, I can run a simple program after modifications using the above steps easily.</div></div>