http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51484
Bug #: 51484 Summary: Can't create C++ executable with -profile-generate Classification: Unclassified Product: gcc Version: 4.7.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: gcov-profile AssignedTo: unassig...@gcc.gnu.org ReportedBy: veks...@il.ibm.com Hello, How can I turn profile driven optimizations with gcc-4.7.0 development version? It used to work with gcc-4.6.x and before. I am trying to use the latest GCC trunk: $ /opt/gcc47-20111207/bin/g++ -v Using built-in specs. COLLECT_GCC=/opt/gcc47-20111207/bin/g++ COLLECT_LTO_WRAPPER=/opt/gcc47-20111207/libexec/gcc/x86_64-unknown-linux-gnu/4.7.0/lto-wrapper Target: x86_64-unknown-linux-gnu Configured with: ../gcc-source/configure --prefix=/opt/gcc47-20111207 --enable-languages='c++ c' Thread model: posix gcc version 4.7.0 20111206 (experimental) (GCC) I have got two files: // t.cpp #include<iostream> void f() { std::cout<< "hello\n"; } // t.cpp void f(); int main() { f(); return 0; } I compile them with: $ rm -rf prof $ /opt/gcc47-20111207/bin/g++ -c t.cpp -g -O2 -m32 -fprofile-generate=prof $ /opt/gcc47-20111207/bin/g++ -c t2.cpp -g -O2 -m32 -fprofile-generate=prof $ /opt/gcc47-20111207/bin/g++ -O2 t2.o t.o -g -m32 -fprofile-generate=prof and I get: ========= begin ==== /home/me/t2.cpp:3: undefined reference to `__gcov0__ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc' /home/me/t2.cpp:3: undefined reference to `__gcov0__ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc' t2.o: In function `operator<< <std::char_traits<char> >': /opt/gcc47-20111207/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/ostream:515: undefined reference to `__gcov0__ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc' /opt/gcc47-20111207/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/ostream:515: undefined reference to `__gcov0__ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc' collect2: error: ld returned 1 exit status ========== end ==== Neither adding -lgcov at the end nor adding /opt/gcc47-20111207/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/32/libgcov.a helps.