Makefile 을 통해 compile 을 하는데 error 가 생겨서 진행을 못하고있습니다.
.hpp 는 처음 써봐서 어떻게 compile 해야 하는지 모르겠네요.
먼저 source code 는,
===================================================================
ST.hpp
#include "main.h"
template <class keyT, class valT>
class ST
{
public :
void put(keyT ikey, valT ival);
valT get(keyT ikey);
private :
...
};
template <class keyT, class valT>
void
ST<keyT,valT>::put(keyT ikey, valT ival)
{
...
}
template <class keyT, class valT>
valT
ST<keyT,valT>::get(keyT ikey)
{
...
}
===================================================================
main.cpp
#include "main.h"
#include "ST.hpp"
int
main()
{
ST<string, string> st;
st.put("aaaa","AAAA");
cout << st.get("aaaa") << endl;
return 0;
}
===================================================================
main.h
#include <iostream>
#include <vector>
#include <string>
using namespace std;
===================================================================
이렇게 이고,
Makefile 은
===================================================================
CC = g++
OBJECT = ST.o main.o
all : run
run : $(OBJECT)
$(CC) -g $(OBJECT) -o run
main.o :
$(CC) -g -c main.cpp -o main.o
ST.o :
$(CC) -g -c ST.hpp -o ST.o
clean :
rm -f *.o run
===================================================================
입니다.
compile error 는
ST.o: file not recognized: File format not recognized
collect2: error: ld returned 1 exit status
make: *** [run] Error 1
이렇게 발생합니다.
해결책 아시는분 부탁드릴게요...