関数を持つtemp1.cファイルがあります
int add(int a, int b){ return (a+b); }
temp1.h ファイル
int add(int,int)
コンパイルして.oファイルを作成しました
g++ -o temp1.o -c temp1.cpp
ここで、別のディレクトリに配置された temp2.cpp で add 関数を使用する必要があります。私はやった
#include "temp1.h"
int main(){
int x = add(5,2);
}
関数 add を呼び出すことができる temp2.exe を作成できるように、temp1.o で temp2.cpp をコンパイルする必要があります。それをコンパイルする方法は?