Skip to content

"relocation R_X86_64_PC32 against undefined symbol ..." #9085

Closed
@zmodem

Description

@zmodem
Bugzilla Link 8713
Resolution FIXED
Resolved on Dec 09, 2010 21:00
Version trunk
OS Linux
CC @asl,@nico,@rjmccall

Extended Description

Trying to compile and link the following into a shared library fails:

#include

extern std::ostream& get_ostream();

void f() {
get_ostream() << "foo";
}

$ clang++ -fno-exceptions -fvisibility=hidden -fPIC -fno-rtti -fno-threadsafe-statics -fvisibility-inlines-hidden -c a.cc -o fail.o
$ clang++ -shared -o fail.so fail.o
/usr/bin/ld: fail.o: relocation R_X86_64_PC32 against undefined symbol `_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@@GLIBCXX_3.4' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value
clang: error: linker command failed with exit code 1 (use -v to see invocation)

If g++ is used in the first step, the link step succeeds.

$ clang++ -v
clang version 2.9 (trunk 120563)
Target: x86_64-unknown-linux-gnu
Thread model: posix

gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzillaclangClang issues not falling into any other category

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions