Menu

using fstream

2005-07-04
2012-09-26
  • Nobody/Anonymous

    I tried to compile a dll (wrote in c++) in DevCpp 4 in order to use this compiler instead of MS Visual Studio 6.0 and the compiler seems not to know the frstream class. The linker spats out:

    e:\samuel\programmierung\c++\visualc++\dll's\sgcommon4mitdevcpp\unitsgtimer.o(.text+0x122):unitsgtimer.cp: undefined reference to timeGetTime@0' e:\samuel\programmierung\c++\visualc++\dll's\sgcommon4mitdevcpp\unitsgfile.o(.text+0x44c):unitsgfile.cpp: undefined reference tofstreambase::close(void)'
    e:\samuel\programmierung\c++\visualc++\dll's\sgcommon4mitdevcpp\unitsgfile.o(.text+0x59e):unitsgfile.cpp: undefined reference to istream::tellg(void)' e:\samuel\programmierung\c++\visualc++\dll's\sgcommon4mitdevcpp\unitsgfile.o(.text+0x5bf):unitsgfile.cpp: undefined reference toistream::tellg(void)'
    e:\samuel\programmierung\c++\visualc++\dll's\sgcommon4mitdevcpp\unitsgfile.o(.text+0x751):unitsgfile.cpp: undefined reference to istream::read(char *, int)' e:\samuel\programmierung\c++\visualc++\dll's\sgcommon4mitdevcpp\unitsgfile.o(.text+0x9c2):unitsgfile.cpp: undefined reference toistream::read(char *, int)'
    e:\samuel\programmierung\c++\visualc++\dll's\sgcommon4mitdevcpp\unitsgfile.o(.text+0xbf7):unitsgfile.cpp: undefined reference to ostream::write(char const *, int)' e:\samuel\programmierung\c++\visualc++\dll's\sgcommon4mitdevcpp\unitsgfile.o(.text+0xd69):unitsgfile.cpp: undefined reference toistream::seekg(long, ios::seek_dir)'
    e:\samuel\programmierung\c++\visualc++\dll's\sgcommon4mitdevcpp\unitsgfile.o(.text+0xd83):unitsgfile.cpp: undefined reference to ostream::seekp(long, ios::seek_dir)' e:\samuel\programmierung\c++\visualc++\dll's\sgcommon4mitdevcpp\unitsgfile.o(.text+0xefe):unitsgfile.cpp: undefined reference toistream::seekg(long, ios::seek_dir)'
    e:\samuel\programmierung\c++\visualc++\dll's\sgcommon4mitdevcpp\unitsgfile.o(.text+0xf13):unitsgfile.cpp: undefined reference to istream::tellg(void)' e:\samuel\programmierung\c++\visualc++\dll's\sgcommon4mitdevcpp\unitsgfile.o(.text+0xf35):unitsgfile.cpp: undefined reference toistream::seekg(long, ios::seek_dir)'
    e:\samuel\programmierung\c++\visualc++\dll's\sgcommon4mitdevcpp\unitsgfile.o(.text+0xf7f):unitsgfile.cpp: undefined reference to istream::read(char *, int)' e:\samuel\programmierung\c++\visualc++\dll's\sgcommon4mitdevcpp\unitsgfile.o(.text+0x105a):unitsgfile.cpp: undefined reference toostream::seekp(long, ios::seek_dir)'
    e:\samuel\programmierung\c++\visualc++\dll's\sgcommon4mitdevcpp\unitsgfile.o(.text+0x106f):unitsgfile.cpp: undefined reference to ostream::tellp(void)' e:\samuel\programmierung\c++\visualc++\dll's\sgcommon4mitdevcpp\unitsgfile.o(.text+0x1091):unitsgfile.cpp: undefined reference toostream::seekp(long, ios::seek_dir)'
    e:\samuel\programmierung\c++\visualc++\dll's\sgcommon4mitdevcpp\unitsgfile.o(.text+0x11db):unitsgfile.cpp: undefined reference to fstreambase::close(void)' e:\samuel\programmierung\c++\visualc++\dll's\sgcommon4mitdevcpp\unitsgfile.o(.text+0x1294):unitsgfile.cpp: undefined reference toistream::seekg(long, ios::seek_dir)'
    e:\samuel\programmierung\c++\visualc++\dll's\sgcommon4mitdevcpp\unitsgfile.o(.text+0x12a9):unitsgfile.cpp: undefined reference to istream::tellg(void)' e:\samuel\programmierung\c++\visualc++\dll's\sgcommon4mitdevcpp\unitsgfile.o(.text+0x12cb):unitsgfile.cpp: undefined reference toistream::seekg(long, ios::seek_dir)'
    e:\samuel\programmierung\c++\visualc++\dll's\sgcommon4mitdevcpp\unitsgfile.o(.text+0x1315):unitsgfile.cpp: undefined reference to istream::read(char *, int)' e:\samuel\programmierung\c++\visualc++\dll's\sgcommon4mitdevcpp\unitsgfile.o(.text+0x13f0):unitsgfile.cpp: undefined reference toostream::seekp(long, ios::seek_dir)'
    e:\samuel\programmierung\c++\visualc++\dll's\sgcommon4mitdevcpp\unitsgfile.o(.text+0x1405):unitsgfile.cpp: undefined reference to ostream::tellp(void)' e:\samuel\programmierung\c++\visualc++\dll's\sgcommon4mitdevcpp\unitsgfile.o(.text+0x1427):unitsgfile.cpp: undefined reference toostream::seekp(long, ios::seek_dir)'
    e:\samuel\programmierung\c++\visualc++\dll's\sgcommon4mitdevcpp\unitsgfile.o(.text+0x161d):unitsgfile.cpp: undefined reference to fstreambase::close(void)' e:\samuel\programmierung\c++\visualc++\dll's\sgcommon4mitdevcpp\unitsgfile.o(.text$__7fstreami+0xaf):unitsgfile.cpp: undefined reference tofstreambase::fstreambase(int)'
    e:\samuel\programmierung\c++\visualc++\dll's\sgcommon4mitdevcpp\unitsgfile.o(.text$open__7fstreamPCcii+0x1a):unitsgfile.cpp: undefined reference to fstreambase::open(char const *, int, int)' e:\samuel\programmierung\c++\visualc++\dll's\sgcommon4mitdevcpp\unitsgfile.o(.text$_$_11fstreambase+0x60):unitsgfile.cpp: undefined reference tofilebuf::~filebuf(void)'
    Warning: no export definition file provided
    dllwrap will create one, but may not be what you want
    d:\ARBEIT~1\devcpp\Bin\dllwrap: gcc exited with status 1

    I didn't change any settings since the installation of DevCpp. What to do to solve this problem?

    Samuel G.

     
    • Nobody/Anonymous

      jes, the path is a bit unclear, but yes, I use DevCpp.

      Samuel G.

       
    • Nobody/Anonymous

      Is nobody able to help me? Some additional information needed?

      Samuel G.

       
    • Nobody/Anonymous

      I got it!

      You have to include
      <fstream.h> in DevCpp to use class fstream,

      other than in MS Visual C++ 6.0. In MS Visual C++ 6.0 you only have to include <iostream.h>!

       
      • Benjamin Lau

        Benjamin Lau - 2005-07-08

        Actually, you include fstream and then access fstream either by pre-qualifying the std namespace or through it, using std::fstream.

        fstream.h is a deprecated header that existed in the pre-standard days. There is no inherent benefit of using fstream.h over fstream, and for standards sake fstream is a much better option.

        Benjamin Lau

         
    • Nobody/Anonymous

      Yeah, you need to #include <fstream> when compiling with g++ if you want to use ifstream, ofstream, etc...

       
    • Rich

      Rich - 2005-07-08

      In other words:

      include <fstream>

      // .....

      using namespace std;

       
    • Nobody/Anonymous

      Maybe I erred, when I thought I solved the problem. I now changed my include directive to

      include <fstream>

      // .....
      using namespace std;

      as you said, but the same linker errors occur as listed above. Why is the definition of fstream not found? The declaration seems to be well known to the compiler (this means: the header include is the correct one(?)). Where are the definitions of the standard library functions and classes normally?

      Hoping for help

      Samuel G.

       
    • qWake

      qWake - 2005-07-13

      Uhh... the paths in your log start with "e:\samuel\programmierung\c++\visualc++..." Are you sure you are using Dev-C++ and not Visual C++?

      qWake

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.