makefile:簡単な入門
簡単な入門操作、達人は無視してください.
C.hファイル
C.cppファイル
main.cppファイル
Makefileファイル
現在のディレクトリに入る、makeを実行することで実行可能ファイルmainを生成する.
完了
C.hファイル
#ifndef __C__HEADER
#define __C__HEADER
class C
{
public:
C();
C(C& c);
};
#endif
C.cppファイル
#include "C.h"
#include <iostream>
using namespace std;
C::C()
{
}
C::C(C& c)
{
cout << "copy constructor." << endl;
}
main.cppファイル
#include <iostream>
#include "C.h"
using namespace std;
int main()
{
C time2;
cout << "main run...." << endl;
return 0;
}
Makefileファイル
#
cc=g++
#
exe=main
#
obj=main.o C.o
#
$(exe):$(obj)
$(cc) -o $(exe) $(obj)
#
main.o:main.cpp C.h
$(cc) -c main.cpp
C.o:C.cpp C.h
$(cc) -c C.cpp
# make clean
clean:
rm -fr *.o $(exe)
現在のディレクトリに入る、makeを実行することで実行可能ファイルmainを生成する.
./main
.
完了