This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/55696] New: Error linking using gfortran with C++ code compiled with -std=c++11
- From: "kyle.niemeyer at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 14 Dec 2012 20:04:59 +0000
- Subject: [Bug fortran/55696] New: Error linking using gfortran with C++ code compiled with -std=c++11
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55696
Bug #: 55696
Summary: Error linking using gfortran with C++ code compiled
with -std=c++11
Classification: Unclassified
Product: gcc
Version: 4.7.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: kyle.niemeyer@gmail.com
Created attachment 28968
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=28968
main.f90 holds Fortran program that calls C++ subroutine in sub.cpp
I'm running into a linker error when mixing Fortran 90 code with C++ code
compiled using "-std=c++11".
The attached code compiles and links fine with:
gfortran -c main.f90
g++ -c sub.cpp
gfortran -o prog main.o sub.o -lstdc++
But, if I compile the C++ code with:
g++ -c sub.cpp -std=c++11
then linking fails with the error:
Undefined symbols for architecture x86_64:
"std::basic_string<char, std::char_traits<char>, std::allocator<char>
>::basic_string(std::basic_string<char, std::char_traits<char>,
std::allocator<char> >&&)", referenced from:
__ZN9__gnu_cxx13new_allocatorISsE9constructISsISsEEEvPT_DpOT0_ in sub.o
__ZSt10_ConstructISsISsEEvPT_DpOT0_ in sub.o
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
I'm using gfortran and g++ 4.7.2.