链接目标文件时出错

时间:2015-09-08 01:36:37

标签: c++ compilation compiler-errors

我在.cpp

中有这个
#include <iostream>
#include <string>
#include <vector>
#include "HW00.h"

using namespace std;


int main()
{
  string netId = "aag61";
  HW00 hw00(netId);
  hw00.printMyAnswer();

  return 0;
}

我能够将驱动程序文件编译成.o文件,没有任何错误

但是当我跑步时

g++ -o HW00.exe aag61HW00.o HW00Imp.o 

我不断收到这个令人困惑的错误:

"ld: warning: ignoring file HW00Imp.o, file was built for unsupported file format ( 0x7F 0x45 0x4C 0x46 0x02 0x01 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 ) which is not the architecture being linked (x86_64): HW00Imp.o
Undefined symbols for architecture x86_64:

  "HW00::printMyAnswer()", referenced from:

      _main in aag61HW00.o

  "HW00::HW00(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)", referenced from:

      _main in aag61HW00.o

  "HW00::~HW00()", referenced from:

      _main in aag61HW00.o

ld: symbol(s) not found for architecture x86_64

clang: error: linker command failed with exit code 1 (use -v to see invocation)" 

我该如何解决这个问题?

0 个答案:

没有答案