Advertisement

Why wont it work?

Started by June 23, 2002 06:24 AM
17 comments, last by Morthvargr 22 years, 5 months ago
There''s got to be something wrong with my copy of VC++, nothing works, not even the simplest codes will work, even if I set all preferences right and all. It always complains about some error in some of the include files. How come there are errors in the standard include files??
stupid smiley..
Advertisement
The errors are what??
Are you sure you have it set up correctly?

CEO Plunder Studios
[email=esheppard@gmail.com]esheppard@gmail.com[/email]
there are like hundreds of errors in different include files, most of them aren''t even used in my code, and I''ve set everything up correctly, I''m sure of that. I don''t understand it...
VC++ often complains about "unresolved external symbol" and stuff like that, how do I solve that kind of stuff?
First: There''s nothing wrong with your VC++. Just check a few times if you''ve installed it properly and then learn how to use the compiler. Read The ******* Manual.
Advertisement
I have a constructive idea. Why don''t you try to not include the same include file multiple times. For example if you include windows.h, don''t include any other windows related headers unless they are not included in windows.h. If your lazy, you can try the obsolete "#pragma once" (without the quotes) definition.
We can't really help you unless you say what errors you get (if there are alot of similar errors, don't post them all, a sample will probably do).

What code have you tested with?
Does the following compile?

    #include <iostream> using namespace std; // thanks to the people below for pointing this out. int main(){    cout << "Hello World!" << endl;}    

[EDIT: I fixed the "using namespace std"-thing. It completely slipped my mind, sorry about that. I compiled the code under gcc 2.95.3, and since it compiled and ran fine I didn't think that I had forgotten anything ]

[edited by - Dactylos on June 24, 2002 10:33:29 AM]
Ok, none of the above worked (but that might be simply because I suck at C++). Here''s a sample that should initialize DirectDraw, that doesn''t work for me (but then again, I suck ass at programming, which might be the reason):





#include <ddraw.h>
// globals (ugh)
LPDIRECTDRAW lpDD; // DirectDraw object defined in DDRAW.H

/*
* Function to initialize DirectDraw
* Demonstrates:
* 1) Creating the Direct Draw Object
* 2) Setting the Cooperative level
* 3) Setting the Display mode
*
*/
bool DirectDrawInit(HWND hwnd)
{
HRESULT ddrval;

/*
* Create the main DirectDraw object.
*
* This function takes care of initializing COM and Constructing
* the DirectDraw object.
*/
ddrval = DirectDrawCreate( NULL, &lpDD, NULL );
if( ddrval != DD_OK )
{
return(false);
}

/*
* The cooperative level determines how much control we have over the
* screen. This must at least be either DDSCL_EXCLUSIVE or DDSCL_NORMAL
*
* DDSCL_EXCLUSIVE allows us to change video modes, and requires
* the DDSCL_FULLSCREEN flag, which will cause the window to take over
* the fullscreen. This is the preferred DirectDraw mode because it allows
* us to have control of the whole screen without regard for GDI.
*
* DDSCL_NORMAL is used to allow the DirectDraw app to run windowed.
*/
ddrval = lpDD->SetCooperativeLevel( hwnd, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN );
if( ddrval != DD_OK )
{
lpDD->Release();
return(false);
}

/*
* Set the video mode to 640x480x8
* This is allowed because we have set exclusive mode above
*/
ddrval = lpDD->SetDisplayMode( 640, 480, 8);
if( ddrval != DD_OK )
{
lpDD->Release();
return(false);
}

return(true);
}






And these are the errors I get:


--------------------Configuration: init - Win32 Debug--------------------
Linking...
init.obj : error LNK2001: unresolved external symbol _DirectDrawCreate@12
LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/init.exe : fatal error LNK1120: 2 unresolved externals
Error executing link.exe.

init.exe - 3 error(s), 0 warning(s)






There are no errors when compiling, just linking.
You get that error because you are using a "win32 console application" as the project type instead of "win32 application". You selected this when you started a new project.

Really, I can only recommend that you forget all about DirectX before you feel comfortable with programming in C++ in general. You will break your neck if you try to walk before you can crawl.
Jacob Marner, M.Sc.Console Programmer, Deadline Games

This topic is closed to new replies.

Advertisement