Hi Guys.
This is a bit of a newbiee question, but ive googled for ages and still no luck. When I comile all my souce files it works fine, its when I link it that it stuffs up. It comes up with these errors.
The trouble is that I've tried almost everything. Dont know how to use DUMPBIN, ive triedCode:winmain.obj : error LNK2001: unresolved external symbol "void __fastcall Game_Run(struct HWND__ *)" (?Game_Run@@YIXPAUHWND__@@@Z) winmain.obj : error LNK2001: unresolved external symbol "int __fastcall Game_Init(struct HWND__ *)" (?Game_Init@@YIHPAUHWND__@@@Z) Debug/Trans_Sprite.exe : fatal error LNK1120: 2 unresolved externals Error executing link.exe.etc but it wont workCode:extern "C" ...
Heres my code
And the header file that has the prototypes for those functionsCode:// Beging Game Programing // Chapter 7 // winmain.cpp -- windows code framework // header files #include <d3d9.h> #include <d3dx9.h> #include <time.h> #include <stdio.h> #include "dxgraphics.h" #include "game.h" //windows event call back function LRESULT WINAPI WinProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam ) { switch ( msg ) { case WM_DESTROY: //release the direct 3d device if (d3ddev != NULL) d3ddev->Release(); //release the direct 3d object if (d3d != NULL) d3d->Release(); //call the 'front end' shut-down function Game_End(hWnd); // tell windows to kill this program PostQuitMessage(0); return 0; } return DefWindowProc (hWnd, msg, wParam, lParam); } //helper function to set up the window properties ATOM MyRegisterClass(HINSTANCE hInstance) { //create the window class structure WNDCLASSEX wc; wc.cbSize = sizeof(WNDCLASSEX); //fill the struct with info wc.style = CS_HREDRAW | CS_VREDRAW; wc.lpfnWndProc = (WNDPROC)WinProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInstance; wc.hIcon = NULL; wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); wc.lpszMenuName = NULL; wc.lpszClassName = APPTITLE; wc.hIconSm = NULL; //set up the window with the class info return RegisterClassEx(&wc); } //entry point for a windows program int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { MSG msg; HWND hWnd; //Register the class MyRegisterClass(hInstance); //set up the screen in windowed or full-screen mode? DWORD style; if (FULLSCREEN) style = WS_EX_TOPMOST | WS_VISIBLE | WS_POPUP; else style = WS_OVERLAPPED; //Create new window hWnd = CreateWindow( APPTITLE, //window class APPTITLE, //title bar style, //window style CW_USEDEFAULT, //x position of window CW_USEDEFAULT, //y position of window SCREEN_WIDTH, //width of the window SCREEN_HEIGHT, //height of the window NULL, //parent window NULL, //menu hInstance, //application instance NULL); //window parameters //Was there an error creating the window? if (!hWnd) return false; //display the window ShowWindow(hWnd, nCmdShow); UpdateWindow(hWnd); if (!Init_Direct3D(hWnd, SCREEN_WIDTH, SCREEN_HEIGHT, FULLSCREEN)) { MessageBox(hWnd, "Error initializing Direct 3D", "Error", MB_OK); return 0; } //initalize the game if (!Game_Init(hWnd)) { MessageBox(hWnd, "Error initializing the game", "Error", MB_OK); return 0; } //main message loop int done = 0; while (!done) { if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { //look for quit message if (msg.message == WM_QUIT) done = 1; //decode and pass messages on to WndProc TranslateMessage(&msg); DispatchMessage(&msg); } else //process game loop ('else' prevents running after close) Game_Run(hWnd); } return msg.wParam; }
Any help would be appreciatedCode://game.h #ifndef _GAME_H #define _GAME_H #include <d3d9.h> #include <d3dx9.h> #include <d3dx9core.h> #include <d3dx9math.h> #include <time.h> #include <stdio.h> #include <stdlib.h> #include "dxgraphics.h" //app title #define APPTITLE "Trans_Sprite" //screen setup #define FULLSCREEN 0 //0 = windowed, 1 = fullscreen #define SCREEN_WIDTH 640 #define SCREEN_HEIGHT 480 //macros to read the keyboard asynchronously #define KEY_DOWN(vk_code) ((GetAsyncKeyState(vk_code) & 0x8000) ? 1 : 0) #define KEY_UP(vk_code) ((GetAsyncKeyState(vk_code) & 0x8000) ? 1 : 0) //function prototypes int Game_Init(HWND); void Game_Run(HWND); void Game_End(HWND); //sprite structure typedef struct { int x,y; int width,height; int movex,movey; int curframe,lastframe; int animdelay,animcount; } SPRITE; #endif
Cheers
Manaxter



LinkBack URL
About LinkBacks



I used to be an adventurer like you... then I took an arrow to the knee.