Skip to main content
GameDev.net gamedev.net
🔒 Locked

'stream' Causing Compiler Errors

Started by brooksyd22 Sep 19, 2005 at 4:49 PM 7 replies 550+ views
Original Post
brooksyd22
brooksyd22
I am trying to make a simple terrain engine and have come across a problem in opening a bitmap to read in the heightdata. However when using fstream I seem to be getting unresolved external symbols as below;

Assignment1 error LNK2001: unresolved external symbol "void * __cdecl operator new[](unsigned int,int,char const *,int)" (??_U@YAPAXIHPBDH@Z)
Assignment1 error LNK2019: unresolved external symbol "void * __cdecl operator new(unsigned int,int,char const *,int)" (??2@YAPAXIHPBDH@Z) referenced in function "public: __thiscall ofstream::ofstream(void)" (??0ofstream@@QAE@XZ)
Assignment1 error LNK2019: unresolved external symbol "void * __cdecl operator new[](unsigned int,int,char const *,int)" (??_U@YAPAXIHPBDH@Z) referenced in function "public: class filebuf * __thiscall filebuf::attach(int)" (?attach@filebuf@@QAEPAV1@H@Z)
Assignment1 fatal error LNK1120: 2 unresolved externals

To throw this error up I simply have to set a variable wih the ifstream method, nothing more than that. Does anybody know why I am getting this error? I have double checked that I have the correct files in my include directory and everything seems in place.
ukdeveloper
ukdeveloper
The AP is right - we really need to see your code if at all possible if we're going to be able to help you, I'm afraid.
orcfan32
orcfan32
If you have a linker error, then you are most likely not including something, or your linker parameters are incorrect. Of course, there can be other problems as well.
The best thing to do is just choose whatever you think you'd prefer, and go for it. -Promit
brooksyd22
brooksyd22
I am literally not putting much code into it at all, I have included the headers and then just tried to make an ifstream variable. Everything runs fine if I dont make the variable but as soon as I do then I get the linker errors. This below is literally what I have;

#include <fstream.h>#include <ostream.h>#include <process.h>bool GetHeightData(){    ifstream File;}


I havent included the rest of the class as I am at work now and dont have it, but it all works fine apart from making that damn variable!
SiCrane
SiCrane
Try switching to the standard versions of the stream headers. i.e. instead of .
Enigma
Enigma
You're including non-existant headers. It should be:
#include <fstream>#include <ostream>#include <process.h>bool GetHeightData(){    std::ifstream File;}
The standard C++ headers have no ".h" on them.

Enigma
brooksyd22
brooksyd22
ok thanks a lot for the replies. I forgot to mention though that I am using C and not C++ so I guess that is why ifstream isnt working. I have decided to go with a different route and am using the fopen function to open my file (of type FILE*). Does anybody know of how to transfer the whole of the file (in this case a 128x128 RAW file) into a 1D buffer?

Zahlman
Zahlman
Quote:
Original post by brooksyd22
ok thanks a lot for the replies. I forgot to mention though that I am using C and not C++


Oh. On your head be it, then.

Quote:
so I guess that is why ifstream isnt working.


Right. That functionality simply isn't part of C.

Quote:
I have decided to go with a different route and am using the fopen function to open my file (of type FILE*).


Yep; that's what you'll need.

Quote:
Does anybody know of how to transfer the whole of the file (in this case a 128x128 RAW file) into a 1D buffer?


Look up fread().

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.