Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9000951
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:22:26+00:00 2026-06-16T00:22:26+00:00

I’m trying to link a C++ file with my Fortran 90 program, but I’m

  • 0

I’m trying to link a C++ file with my Fortran 90 program, but I’m running into a link error when using gfortran.

My Fortran files are compiled with:
gfortran -c -o obj/file.o file.f90 -O0 -g3 -ffree-line-length-none -fcheck-array-temporaries -fbounds-check and my C++ file is compiled using g++-4.7 -c -o obj/cppfile.o cppfile.cpp -O0 -g3 -std=c++11

Then, all are linked together with gfortran:
gfortran -o program obj/file.o obj/cppfile.o -O0 -g3 -ffree-line-length-none -fcheck-array-temporaries -fbounds-check -lm -llapack -lc -lgfortran -lgcc -lstdc++

When doing this, I get the following link errors:

Undefined symbols for architecture x86_64:
“std::basic_string, std::allocator::basic_string(std::basic_string, std::allocator >&&)”, referenced from:

std::basic_string, std::allocator > std::operator+, std::allocator >(char const*, std::basic_string, std::allocator >&&) in cppfile.o
std::basic_string, std::allocator > std::operator+, std::allocator >(std::basic_string, std::allocator >&&, char const*) in cppfile.o
std::basic_string, std::allocator > std::operator+, std::allocator >(std::basic_string, std::allocator >&&, std::basic_string, std::allocator >&&) in cppfile.o
std::basic_string, std::allocator > std::operator+, std::allocator >(std::basic_string, std::allocator >&&, std::basic_string, std::allocator > const&) in cppfile.o
component::component(component&&) in cppfile.o “std::basic_string, std::allocator >::operator=(std::basic_string, std::allocator >&&)”, referenced from:
function in cppfile.o
component::operator=(component&&) in cppfile.o

ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
make: * [program] Error 1

My c++ file looks like this:

#include <iostream>
#include <string>
#include <fstream>
#include <iomanip>
#include <math.h>
#include <stdio.h>
#include <vector>

using namespace std;

struct component
{
    string num;     // numerator of component
    string den;     // denominator of component
    int ind;        // index of variable
};

extern "C"{
void subroutine_ (int num, const int* array)
{
    ...
    return;
}

Any thoughts as to why this would be happening? I made sure to link the -lstdc++ library. Could it have something to do with my use of the C++11 standard, related to the string library?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T00:22:26+00:00Added an answer on June 16, 2026 at 12:22 am

    One solution appears to be to remove the -std=c++11 from the compilation of the C++ code. With it, combining linking C++ code with a vector of strings (or structs that contain a string) causes the above errors.

    I’m going to file a bug in the GCC Bugzilla on this, and use my solution as a workaround in the meantime.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a French site that I want to parse, but am running into
I am trying to render a haml file in a javascript response like so:
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I have thousands of HTML files to process using Groovy/Java and I need to
I am currently running into a problem where an element is coming back from
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.