Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Link Error : Undefined symbols #7

Open
mohitmv opened this issue Mar 30, 2020 · 0 comments
Open

Link Error : Undefined symbols #7

mohitmv opened this issue Mar 30, 2020 · 0 comments

Comments

@mohitmv
Copy link

mohitmv commented Mar 30, 2020

Hi, I compiled following C++ code in linux machine using g++ -c code.cpp -o code.o

#include <iostream>
using namespace std;

int main() {
  cout << "ABC" << endl;
  return 0;
}

Then I converted code.o to code_mac.o using ./objconv -fmacho64 -nu code.o code_mac.o on mac.

Then I tried to build executable in mac using g++ code_mac.o -o code_mac

and I'm getting following error :

  "std::ostream::operator<<(std::ostream& (*)(std::ostream&))", referenced from:
      _main in mohit_1.o
  "std::ios_base::Init::Init()", referenced from:
      _main in mohit_1.o
  "std::ios_base::Init::~Init()", referenced from:
      _main in mohit_1.o
  "std::cout", referenced from:
      _main in mohit_1.o
  "std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)", referenced from:
      _main in mohit_1.o
  "std::basic_ostream<char, std::char_traits<char> >& std::operator<<<std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)", referenced from:
      _main in mohit_1.o
  "___mh_execute_header", referenced from:
      _main in mohit_1.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

What am i missing ?
Doesn't objconv change the standard library (libstdc++) when I converted a linux binary to mac binary ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant