I am using mac osx yosemite, xcode 6.1.1. I wrote this simple piece of code. When I compile and link it with gcc, I kept getting error: symbol(s) not found for architecture x86_64
But the same code compiles successfully in xcode, or using g++, clang++. I wonder what is the difference? the project is a single file contain:
#include <string>
#include <vector>
#include <map>
#include <iostream>
#include <stdio.h>
using namespace std;
struct ListNode {
int val;
ListNode *next;
ListNode(int x) : val(x), next(NULL) {}
};
int main(int argc, char** argv){
vector<ListNode *> vec;
vec.push_back(new ListNode(0));
vec.push_back(new ListNode(1));
cout<<vec[0]->val<<vec[1]->val<<endl;
return 0;
}