问题
I had this in my .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;
}
And I was able to compile the driver file into a .o file without any errors
but when I run
g++ -o HW00.exe aag61HW00.o HW00Imp.o
I keep getting this confusing error:
"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)"
How do I fix this?
来源:https://stackoverflow.com/questions/32448016/error-linking-object-files