A bunch of LNK error! Please help!

I always get these dumb link errors. Can you guys tell me how to read them so i can fix it by myself nexttime? And how to fix it.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
1
1>  main.cpp
1>  IntroAnimation.cpp
1>  Generating Code...
1>MSVCRTD.lib(cinitexe.obj) : warning LNK4098: defaultlib 'msvcrt.lib' conflicts with use of other libs; use /NODEFAULTLIB:library
1>IntroAnimation.obj : error LNK2019: unresolved external symbol "public: struct SDL_Surface * __thiscall Graphics::LoadImage(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?LoadImage@Graphics@@QAEPAUSDL_Surface@@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function "public: __thiscall Intro::Intro(struct Environment *)"(??0Intro@@QAE@PAUEnvironment@@@Z)
1>Menu.obj : error LNK2001: unresolved external symbol "public: struct SDL_Surface * __thiscall Graphics::LoadImage(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?LoadImage@Graphics@@QAEPAUSDL_Surface@@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
1>IntroAnimation.obj : error LNK2019: unresolved external symbol "public: void __thiscall Graphics::FreeSurface(struct SDL_Surface *)" (?FreeSurface@Graphics@@QAEXPAUSDL_Surface@@@Z) referenced in function "public: __thiscall Intro::~Intro(void)" (??1Intro@@QAE@XZ)
1>IntroAnimation.obj : error LNK2019: unresolved external symbol "public: void __thiscall Graphics::UpdateScreen(void)" (?UpdateScreen@Graphics@@QAEXXZ) referenced in function "public: virtual void __thiscall Intro::Render(void)" (?Render@Intro@@UAEXXZ)
1>Menu.obj : error LNK2001: unresolved external symbol "public: void __thiscall Graphics::UpdateScreen(void)" (?UpdateScreen@Graphics@@QAEXXZ)
1>IntroAnimation.obj : error LNK2019: unresolved external symbol "public: void __thiscall Graphics::ApplySurface(int,int,struct SDL_Surface *,struct SDL_Surface *,struct SDL_Rect *)" (?ApplySurface@Graphics@@QAEXHHPAUSDL_Surface@@0PAUSDL_Rect@@@Z) referenced in function "public: virtual void __thiscall Intro::Render(void)" (?Render@Intro@@UAEXXZ)
1>Menu.obj : error LNK2001: unresolved external symbol "public: void __thiscall Graphics::ApplySurface(int,int,struct SDL_Surface *,struct SDL_Surface *,struct SDL_Rect *)" (?ApplySurface@Graphics@@QAEXHHPAUSDL_Surface@@0PAUSDL_Rect@@@Z)
1>IntroAnimation.obj : error LNK2019: unresolved external symbol "public: void __thiscall Graphics::ClearScreen(int,int,int)" (?ClearScreen@Graphics@@QAEXHHH@Z) referenced in function "public: virtual void __thiscall Intro::Render(void)" (?Render@Intro@@UAEXXZ)
1>Menu.obj : error LNK2001: unresolved external symbol "public: void __thiscall Graphics::ClearScreen(int,int,int)" (?ClearScreen@Graphics@@QAEXHHH@Z)
1>main.obj : error LNK2019: unresolved external symbol "public: __thiscall Graphics::~Graphics(void)" (??1Graphics@@QAE@XZ) referenced in function _SDL_main
1>main.obj : error LNK2019: unresolved external symbol "public: void __thiscall Timer::CapFrameRate(int)" (?CapFrameRate@Timer@@QAEXH@Z) referenced in function _SDL_main
1>main.obj : error LNK2019: unresolved external symbol "public: void __thiscall Timer::Start(void)" (?Start@Timer@@QAEXXZ) referenced in function _SDL_main
1>main.obj : error LNK2019: unresolved external symbol "public: __thiscall Timer::Timer(void)" (??0Timer@@QAE@XZ) referenced in function _SDL_main
1>main.obj : error LNK2019: unresolved external symbol "public: __thiscall Graphics::Graphics(int,int,int,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (??0Graphics@@QAE@HHHV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function _SDL_main
1>C:\Users\david\documents\visual studio 2010\Projects\MyGame\Debug\MyGame.exe : fatal error LNK1120: 10 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
99 times out of 100, "unresolved external symbol" means you make a function prototype, but never gave that function a body.

This error:

IntroAnimation.obj : error LNK2019: unresolved external symbol "public: struct SDL_Surface * __thiscall Graphics::LoadImage(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?LoadImage@Graphics@@QAEPAUSDL_Surface@@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function "public: __thiscall Intro::Intro(struct Environment *)"(??0Intro@@QAE@PAUEnvironment@@@Z)


Means:

1) IntroAnimation.cpp is trying to call the function:
SDL_Surface* Graphics::LoadImage(string)

2) That function was prototyped, but has no function body.

Last edited on
It does has a body though. I dont have to include the .cpp right? Graphics.h and Graphics.cpp are in a different folder but at the top of IntroAnimation.h i have

#include "SDL_GameEngine\Graphics.h"
This is Visual Studio, right?

Is the cpp file that has those function bodies part of your project?

(and yes you're right: don't include the cpp files)


EDIT: I seem to be replying to lots of your posts. lol
Last edited on
This is Visual c++ 2010

the project folder is like this

-Debug Folder
-ipch Folder
-Media Folder
-SDL_GameEngine Folder
-Defines.h
-Enums.h
etc...


Graphics.cpp is in the SDL_GameEngine folder. so yeah its part of the project
When you build the project it lists all the files that it compiles in the output screen.

Is Graphics.cpp being listed?

Make a minor change to it just to make it dirty, then rebuild and check.
Last edited on
lol dirty.

its not there.
"dirty" is a standard term for files that have been modified =P

Go in the Project menu. Select "Add Existing Item"

Select all the cpp files in all your folders.

Rebuild.


In the future, when adding new files to the project, to go Project | Add New Item (don't use File | New)
I love you Disch. Its been a week since i told myself i was going to make a game engine and make a game, and now it finally works. Well, the intro animation anyways. Thank you so much!!!

"dirty" is a standard term for files that have been modified =P


Well in Linux/Unix we make it "dirty" by "touch"-ing the files :P
@sohguanh:

That sounds so wrong XD
Well maybe you can feedback to the developers who has this fetish to name the command as touch. It could have been other worse naming those developers can think. Maybe penetrate, copulate, spawn (oops this is used already) and many others :P

In general Unix developers are either very creative namers or lame namers. Can you imagine AWK is actually the initials of three developers? How creative is that name but it take the Unix world by storm back in the 70's isn't it?

Lastly, the name C C++ isn't very creative names for programming language either. Perl, Java, Python, Ruby sound so much better :)
Topic archived. No new replies allowed.