Первые шаги...
Первые шаги...
Пытаюсь скомпилить прогу следущего содержания:
#include <iostream.h>
#include <fstream.h>
int main(void)
{
ofstream out("test");
if(!out)
{
cout << "Can't open file";
return 0;
}
out << 10 << " " << 123.23 << "\n";
out << "This is a short text file.\n";
out.close();
return 0;
}
а gcc в ответ:
/home/kir/tmp/ccdmnz8t.o: In function `main':
/home/kir/tmp/ccdmnz8t.o(.text+0x22): undefined reference to `ofstream::ofstream(int, char const *, int, int)'
/home/kir/tmp/ccdmnz8t.o(.text+0x3b): undefined reference to `ios::operator!(void) const'
/home/kir/tmp/ccdmnz8t.o(.text+0x51): undefined reference to `cout'
/home/kir/tmp/ccdmnz8t.o(.text+0x56): undefined reference to `ostream::operator<<(char const *)'
/home/kir/tmp/ccdmnz8t.o(.text+0x6a): undefined reference to `ofstream::~ofstream(void)'
/home/kir/tmp/ccdmnz8t.o(.text+0xaf): undefined reference to `ostream::operator<<(int)'
/home/kir/tmp/ccdmnz8t.o(.text+0xba): undefined reference to `ostream::operator<<(char const *)'
/home/kir/tmp/ccdmnz8t.o(.text+0xc5): undefined reference to `ostream::operator<<(double)'
/home/kir/tmp/ccdmnz8t.o(.text+0xd0): undefined reference to `ostream::operator<<(char const *)'
/home/kir/tmp/ccdmnz8t.o(.text+0xec): undefined reference to `ostream::operator<<(char const *)'
/home/kir/tmp/ccdmnz8t.o(.text+0xfe): undefined reference to `fstreambase::close(void)'
/home/kir/tmp/ccdmnz8t.o(.text+0x112): undefined reference to `ofstream::~ofstream(void)'
/home/kir/tmp/ccdmnz8t.o(.text+0x12d): undefined reference to `ofstream::~ofstream(void)'
collect2: ld returned 1 exit status
Что бы это могло быть?
#include <iostream.h>
#include <fstream.h>
int main(void)
{
ofstream out("test");
if(!out)
{
cout << "Can't open file";
return 0;
}
out << 10 << " " << 123.23 << "\n";
out << "This is a short text file.\n";
out.close();
return 0;
}
а gcc в ответ:
/home/kir/tmp/ccdmnz8t.o: In function `main':
/home/kir/tmp/ccdmnz8t.o(.text+0x22): undefined reference to `ofstream::ofstream(int, char const *, int, int)'
/home/kir/tmp/ccdmnz8t.o(.text+0x3b): undefined reference to `ios::operator!(void) const'
/home/kir/tmp/ccdmnz8t.o(.text+0x51): undefined reference to `cout'
/home/kir/tmp/ccdmnz8t.o(.text+0x56): undefined reference to `ostream::operator<<(char const *)'
/home/kir/tmp/ccdmnz8t.o(.text+0x6a): undefined reference to `ofstream::~ofstream(void)'
/home/kir/tmp/ccdmnz8t.o(.text+0xaf): undefined reference to `ostream::operator<<(int)'
/home/kir/tmp/ccdmnz8t.o(.text+0xba): undefined reference to `ostream::operator<<(char const *)'
/home/kir/tmp/ccdmnz8t.o(.text+0xc5): undefined reference to `ostream::operator<<(double)'
/home/kir/tmp/ccdmnz8t.o(.text+0xd0): undefined reference to `ostream::operator<<(char const *)'
/home/kir/tmp/ccdmnz8t.o(.text+0xec): undefined reference to `ostream::operator<<(char const *)'
/home/kir/tmp/ccdmnz8t.o(.text+0xfe): undefined reference to `fstreambase::close(void)'
/home/kir/tmp/ccdmnz8t.o(.text+0x112): undefined reference to `ofstream::~ofstream(void)'
/home/kir/tmp/ccdmnz8t.o(.text+0x12d): undefined reference to `ofstream::~ofstream(void)'
collect2: ld returned 1 exit status
Что бы это могло быть?
Ещё раз в предыдущем почему-то не прошёл <iostream>
#include <iostream>
using namespace std;
#include <fstream>
int main(void)
{
ofstream out("test");
if(!out)
{
cout << "Can't open file";
return 0;
}
out << 10 << " " << 123.23 << "\n";
out << "This is a short text file.\n";
out.close();
return 0;
}
#include <iostream>
using namespace std;
#include <fstream>
int main(void)
{
ofstream out("test");
if(!out)
{
cout << "Can't open file";
return 0;
}
out << 10 << " " << 123.23 << "\n";
out << "This is a short text file.\n";
out.close();
return 0;
}