I encountered the following error with "-fprofile-instr-generate". Rate your entries to resolve this error.
Thank,
Error:
clang++ -O2 -fprofile-instr-generate hello.cpp
/tmp/hello-58ef5f.o:hello.cpp:function __llvm_profile_init: error: undefined reference to '__llvm_profile_register_function'
/tmp/hello-58ef5f.o:hello.cpp:function __llvm_profile_init: error: undefined reference to '__llvm_profile_register_function'
/tmp/hello-58ef5f.o:hello.cpp:function __llvm_profile_init: error: undefined reference to '__llvm_profile_register_function'
/tmp/hello-58ef5f.o:hello.cpp:function __llvm_profile_init: error: undefined reference to '__llvm_profile_register_function'
/tmp/hello-58ef5f.o:hello.cpp:function __llvm_profile_runtime_user: error: undefined reference to '__llvm_profile_runtime'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Clang Version: Printable Version 3.5.0
OS: Ubuntu 14.04
LD version: GNU gold (GNU Binutils 2.24.51.20140522) 1.11
LLVM configuration : configure --enable-profiling --enable-optimized --enable-shared --disable-debug-runtime --enable-target = all --prefix = / install --with-Binutils-include = / gold_linker / binutils / enable
Above the error says: use -v. The output of -v is as follows
"/usr/local/bin/ld" -z relro --hash-style=gnu --build-id --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o a.out /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/crt1.o /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/crti.o /usr/lib/gcc/x86_64-linux-gnu/4.8/crtbegin.o -L/usr/lib/gcc/x86_64-linux-gnu/4.8 -L/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu -L/lib/x86_64-linux-gnu -L/lib/../lib64 -L/usr/lib/x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/4.8/../../.. -L/home/LLVM_install/bin/../lib -L/lib -L/usr/lib /tmp/hello-c8552f.o /home/LLVM_install/bin/../lib/clang/3.5.0/lib/linux/libclang_rt.profile-x86_64.a -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/lib/gcc/x86_64-linux-gnu/4.8/crtend.o /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/crtn.o
/tmp/hello-c8552f.o:hello.cpp:function __llvm_profile_init: error: undefined reference to '__llvm_profile_register_function'
/tmp/hello-c8552f.o:hello.cpp:function __llvm_profile_init: error: undefined reference to '__llvm_profile_register_function'
/tmp/hello-c8552f.o:hello.cpp:function __llvm_profile_init: error: undefined reference to '__llvm_profile_register_function'
/tmp/hello-c8552f.o:hello.cpp:function __llvm_profile_init: error: undefined reference to '__llvm_profile_register_function'
/tmp/hello-c8552f.o:hello.cpp:function __llvm_profile_runtime_user: error: undefined reference to '__llvm_profile_runtime'
clang: error: linker command failed with exit code 1 (use -v to see invocation)