ファイルを読み込もうとしています。read() で ifstream を使用しようとしましたが、次のエラーが発生します。
std::basic_ifstreamへの未定義の参照
std::basic_ifstream<char, std::char_traits<char> >::basic_ifstream()' /home/ameya/Documents/computer_science/cs130B/prog2/prog2.cpp:24: undefined reference to
>::~basic_ifstream()' prog2.o:(.eh_frame+0x6b): `__gxx_personality_v0' への未定義の参照 collect2: エラー: ld が 1 の終了ステータスを返しました make: * [prog2] エラー 1
それはifstreamへの未定義の参照を言っていますが、私はそれを一番上に含めたので、なぜそのエラーが発生するのですか? 前もって感謝します
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ifstream>
using namespace std;
class DepthMap{
public:
int merge(int numbers[]);
int mergehelper(int left[], int right[]);
void read();
};
int DepthMap::merge(int numbers[]){
return -43;
}
int DepthMap::mergehelper(int left[], int right[]){
return -43;
}
void DepthMap::read(){
ifstream inputFile;
}
int main(int argc, char* argv[])
{
DepthMap depth;
printf("Here");
return 0;
}
ここに私のメイクファイルがあります
CXX = g++
CXXFLAGS = -Wall
all: prog2
prog2: prog2.o
clean:
rm -f prog2