Functions for roomchanges in a text based game

Edit: oops, didn't see the beginners forum. feel free to move it :)

I've not been programming with c++ for long, but I'm wondering if this is the correct way to go about changing areas in a text based game.

Initializing the functions:
1
2
3
int gotoDarkCave();
int gotoDarkCaveStanding();
int gotoOutsideDarkCave();


//Main function is in between these.

gotoDarkCave function
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
int gotoDarkCave() {
    player.location="dark_cave";
    while (player.location=="dark_cave") {
        currentAction=""; //user input to decide what happens
        getline(cin,currentAction);
        if (currentAction=="look"||currentAction=="Look"||currentAction=="LOOK") {
            cout << "You can't see anything." << endl;
            currentTries++;
        }
        else if (currentAction=="smell"||currentAction=="Smell"||currentAction=="SMELL") {
            cout << "The smell of damp fills your nostrils." << endl;
            currentTries++;
        }
        else if (currentAction=="stand up"||currentAction=="stand"||currentAction=="get up"||currentAction=="Stand up"||currentAction=="Stand Up"||currentAction=="Get up"||currentAction=="Get Up"||currentAction=="STAND"||currentAction=="STAND UP"||currentAction=="GET UP") {cout << "You scramble to your feet, bumping your head on something hard above you.\nFrom this new angle you can see that you're in a cave, and your only exit is east." << endl;
            player.location="dark_cave_standing";
            gotoDarkCaveStanding();
        }
        else if (currentAction=="feel"||currentAction=="Feel"||currentAction=="FEEL") {
            cout << "You feel around on the floor, but find nothing useful." << endl;
            currentTries++;
        }
        else if (currentAction=="listen"||currentAction=="Listen"||currentAction=="LISTEN") {
            cout << "You hear nothing but the light patter of water close by." << endl;
            currentTries++;
        }
        else if(currentAction=="char"||currentAction=="Char"||currentAction=="CHAR"||currentAction=="Character"||currentAction=="character"||currentAction=="CHARACTER") {
            cout << "Name: " << player.name << endl << "Race: " << player.race << endl << "Level:" << player.level << endl;
        }
        else if(currentAction=="stats"||currentAction=="Stats"||currentAction=="STATS") {
            cout << "Strength: " << player.strength << endl << "Magic: " << player.magic << endl << "Ranged: " << player.ranged << endl;
        }
        
        else {
            if (currentAction!="") {
                cout << "You can't do that." << endl;
                currentTries++;
                currentAction=="";
            }
        }
        if (currentTries>=3) {
            cout << "Maybe you should try getting up." << endl;
            currentTries=0;
        }
    }
    return 0;
}


when player types get up, stand up, etc it calls the gotoDarkCaveStanding function, which is as follows:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
int gotoDarkCaveStanding() {
    player.location="dark_cave_standing";
    while (player.location=="dark_cave_standing") {
        currentAction="";
        getline(cin,currentAction);;
        if (currentAction=="east"||currentAction=="e"||currentAction=="E"||currentAction=="go east"||currentAction=="Go East"||currentAction=="GO EAST"||currentAction=="Go east"||currentAction=="go East") { 
            
           
            currentAction="";        
            cout << "You emerge from the cave, your eyes squinting as you look into the morning light.\nYou don't know where you are, nor do you remember how you got here." << endl;
            player.location="outside_dark_cave"; 
            gotoOutsideDarkCave(); 
        }
        else if (currentAction=="west"||currentAction=="w"||currentAction=="W"||currentAction=="north"||currentAction=="n"||currentAction=="N"||currentAction=="south"||currentAction=="s"||currentAction=="S") { 
            cout << "You can't go that way." << endl;
        }
        else if (currentAction=="look"||currentAction=="LOOK"||currentAction=="Look"||currentAction=="l"||currentAction=="L") {
            cout << "You are in a small, damp cave. The only exit is east." << endl;
        }
        else if(currentAction=="char"||currentAction=="Char"||currentAction=="CHAR"||currentAction=="Character"||currentAction=="character"||currentAction=="CHARACTER") {
            cout << "Name: " << player.name << endl << "Race: " << player.race << endl << "Level:" << player.level << endl;
        }
        else if(currentAction=="stats"||currentAction=="Stats"||currentAction=="STATS") {
            cout << "Strength: " << player.strength << endl << "Magic: " << player.magic << endl << "Ranged: " << player.ranged << endl;
        }
        else { cout << "You can't do that." << endl;}
        
        

        
    }
    return 0;
}

and when the player types 'e, go east, east, etc', the gotoOutsideDarkCave function is called,

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
int gotoOutsideDarkCave() {
    player.location="outside_dark_cave";            
    int ratInArea=1;
    while (player.location=="outside_dark_cave") {
       getline(cin,currentAction); 
        if (ratInArea==1) {
        cout << "There is a small rat here." << endl;
            if (currentAction=="attack rat"||currentAction=="Attack Rat"||currentAction=="attack Rat"||currentAction=="ATTACK RAT"||currentAction=="kill rat"||currentAction=="Kill rat"||currentAction=="Kill Rat"||currentAction=="KILL RAT") {
                cout << "Fighting Rat YAY" << endl;
            }
        }
    
        
        if (currentAction=="west"||currentAction=="w"||currentAction=="W") {
            cout << "For some unknown reason you go back into the descolate cave you woke up in." << endl;
            player.location=="dark_cave_standing";
            gotoDarkCaveStanding();
            break;
        }
        else if (currentAction=="look"||currentAction=="LOOK"||currentAction=="Look") {
            cout << "You're in a vast, open landscape. The cave you were in is hardly noticable now.\nYou must've been hiding, but from what? Paths lead North, East and South." << endl << "The cave remains west." << endl;
            }
        else if(currentAction=="char"||currentAction=="Char"||currentAction=="CHAR"||currentAction=="Character"||currentAction=="character"||currentAction=="CHARACTER") {
            cout << "Name: " << player.name << endl << "Race: " << player.race << endl << "Level:" << player.level << endl;
        }
            else if(currentAction=="stats"||currentAction=="Stats"||currentAction=="STATS") {
                cout << "Strength: " << player.strength << endl << "Magic: " << player.magic << endl << "Ranged: " << player.ranged << endl;
            }
        
            
        }

    return 0;
}


I'm curious to know, if I go east and west repeatedly from the cave to outside, will I just build up a mass of functions and eventually overload the memory? or does the new function overwrite the previous one; or is there a way to end a function?
Or is there just a plain better way to move between rooms?

Thanks in advance,
Josh
Last edited on
With your design of having one function per room, you could do this.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
typedef enum {l_insideCave, l_outsideCave, etc...} Location;

Location doInsideCave() {
  //deal with being inside the cave
  //when you want to leave, return the location you will goto, eg
  return l_outsideCave;
}

Location doOutsideCave() {
  //Same principle
}

int main() {
  Location cur = l_insideCave;
  while(cur != l_endgame) {
    if(cur == l_insideCave) {
      cur = doInsideCave();
    } else if(cur == l_outsideCave) {
      cur = doOutsideCave();
    }
  }
  return 0;
}


Each function handles the logic of being in a single location. The function then returns the location to go to next.

If you passed a parameter into the functions, then this would let you do things like pick up items, etc.
This probably isn't what you want to hear... but here's my advice:


If you're hardcoding everything (like you are -- putting every possible condition in separate if statements like that), then you're probably doing it the wrong way. As you can imagine, writing a full game like this would become overwhelming.

Notice how you have to duplicate a lot of code for each location (ie: check to see if the player typed a certain command, like "look", etc). Not only is this tedious and repetitive, but it's also error prone. What if you forget to specify "look" for one area? Or mistype it as "looj" or something? This will confuse the player... they'll wonder why "look" works for some areas but not for others.

A better way to structure this would be to make classes to represent each area. Maybe even derive them from a common 'Location' class or something:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
struct Action
{
  // stuff to specify different actions to take, such as move to a new location
  //  quit the game, restart, etc...  whatever
};

// the generic "Location" abstract base class

class Location
{
public:
  virtual ~Location() { }

  // have functions for various commands the user can input
  virtual Action Look() = 0;
  virtual Action DoSomethingElse() = 0;
};


// then specialize individual locations:

class Location_OutsideDarkCave
{
public:
  Action Look()
  {
    cout << "You are outside the dark cave.  Blah blah blah";
    return no_action;
  }

  Action DoSomethingElse()
  {
    // do whatever else
  }
};


Game flow would all run through the same function, then. Instead of being repeated for each location. Something like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
int main()
{
  //...
  Location* currentlocation = new Location_OutsideDarkCave; // start outside the cave
  Action nextaction = no_action;
  string userinput;

  while(nextaction.type != quit)
  {
    // get the user input
    getline(cin,userinput);

    // figure out what they want to do based on that input
    if( /* user wants to look */ )
      nextaction = currentlocation->Look();
    else if( /* user wants to do something else */ )
      nextaction = currentlocation->DoSomethingElse();

    // determine how that action changes game flow
    if(nextaction.type == move_to_new_area)
    {
      delete currentlocation;
      currentlocation = nextaction.newlocation;
    }
  }
}


Of course you might want to get clever with how you decipher string input. It looks like you will at least want "<verb> <noun>" semantics (as in "attack rat"), in which case you'd have to separate out each word, and determine whether or not they're a verb or a noun.

If you want to get really fancy, you can go "<verb> <noun> <preposition> <noun>", as in "attack rat with sword" or "use bandage on self".




Sound complicated?

IT IS

This is the thing newbies don't tend to realize. Text based adventure games are actually much, much harder than other types of simple games. If you're interested in making games, you're much better off starting with something simpler, like a Space Invaders or Snake clone.

See this article for more:

http://cplusplus.com/forum/articles/28558/
Last edited on
Thanks for the replies :) I kind of get your classes idea, and I know they're difficult; I'm not trying to actually make one and release it but I learn by doing, and this is the first thing that I thought I could do to start off with

@kev82, I'll read into that as well, thanks. I never thought about typedef

Josh

edit: howcome you put the destructor first in the Location class?
I know I'm a newbie, but I thought you had to start them with a constructor and end them with a destructor?

I also haven't even bagan to fathom how to use allegro or any graphics really, so I thought I'd stick to console coding before I went any further

More edits!: I read through that post and it was really informative, thanks :) I'll try SFML and see what happens
Last edited on
edit: howcome you put the destructor first in the Location class?
I know I'm a newbie, but I thought you had to start them with a constructor and end them with a destructor?


It doesn't matter what order you put the functions in. You can put any function you want first.

Note I included a virtual destructor because the object will be polymorphically destructed (ie: deleting a derived class object via a base class pointer). Until you fully understand what that means... a good rule of thumb is "if a class has any virtual functions, also give it a virtual destructor".


And yes, I recommend SFML. It might be difficult to set up, but once you get it working it will make your life much easier.
Ah right, okay :)

I've tried setting up SFML for the last hour and a half or so now, but i'm not getting on with it.
The first clock tutorial worked fine, but the graphical window tutorial gives me an overloaded buffer error.

"A buffer overrun has occurred in SFML.exe which has corrupted the program's internal state. Press Break to debug the program or Continue to terminate the program."

The additional dependencies are set up in this order
sfml-system.lib
sfml-graphics.lib
sfml-window.lib

The C/C++ Preprocessor definitons has SFML_DYNAMIC at the top

I copied all of the SFML dlls to the exe's directory as well.

I then followed the guide here:
http://ggammon.wordpress.com/2010/02/14/compiling-and-running-an-sfml-application-in-visual-studio-2010-rc/
but I keep getting the errors 4 succeeded, 1 failed, 1 up to date, or 0 succeeded, 1 failed, 5 up to date.

I tried adding the -d or -s to the libs but that still doesn't help.

Sorry for the continued/changed problems but I'm totally stumped


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include <SFML/System.hpp> 
#include <SFML/Graphics.hpp> 
#include <iostream> 

int main() 
{ 
    // Create the main rendering window 
    sf::RenderWindow App(sf::VideoMode(800, 600, 32), "SFML Graphics"); 
    
    // Start game loop 
    while (App.IsOpened()) 
    { 
        // Process events 
        sf::Event Event; 
        while (App.GetEvent(Event)) 
        { 
            // Close window : exit 
            if (Event.Type == sf::Event::Closed) 
                App.Close(); 
        } 

        // Clear the screen (fill it with black color) 
        App.Clear(); 

        // Display window contents on screen 
        App.Display(); 
    } 

    return EXIT_SUCCESS; 
} 
Last edited on
This thread seems to cover it:

http://www.sfml-dev.org/forum/viewtopic.php?p=8324&sid=129f5db780dd9d29e605ff839a7789a3

Basically you're mixing debug and release builds.

If this is a debug build of your program, you'd need to link to the -d version of the libs.


Or... if you're on MSVS... and if you're lazy like me... you can do what I do and put all that crap in a header file.

Take this and save it as "sfml.h" and put it in whatever include directory. Then #include <sfml.h> instead of <SFML/Whatever.hpp>:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#pragma once
#ifndef SFMLFULL_INCLUDED
#define SFMLFULL_INCLUDED

#include <SFML/Audio.hpp>
#include <SFML/Graphics.hpp>
#include <SFML/Network.hpp>
#include <SFML/System.hpp>
#include <SFML/Window.hpp>

#if defined(SFML_STATIC)

    #if defined(_DEBUG) || defined(DEBUG)
        #pragma comment(lib,"sfml-graphics-s-d.lib")
        #pragma comment(lib,"sfml-audio-s-d.lib")
        #pragma comment(lib,"sfml-network-s-d.lib")
        #pragma comment(lib,"sfml-window-s-d.lib")
        #pragma comment(lib,"sfml-system-s-d.lib")
        #pragma comment(lib,"sfml-main-d.lib")
    #else
        #pragma comment(lib,"sfml-graphics-s.lib")
        #pragma comment(lib,"sfml-audio-s.lib")
        #pragma comment(lib,"sfml-network-s.lib")
        #pragma comment(lib,"sfml-window-s.lib")
        #pragma comment(lib,"sfml-system-s.lib")
        #pragma comment(lib,"sfml-main.lib")
    #endif

#elif defined(SFML_DYNAMIC)

    #if defined(_DEBUG) || defined(DEBUG)
        #pragma comment(lib,"sfml-graphics-d.lib")
        #pragma comment(lib,"sfml-audio-d.lib")
        #pragma comment(lib,"sfml-network-d.lib")
        #pragma comment(lib,"sfml-window-d.lib")
        #pragma comment(lib,"sfml-system-d.lib")
        #pragma comment(lib,"sfml-main-d.lib")
    #else
        #pragma comment(lib,"sfml-graphics.lib")
        #pragma comment(lib,"sfml-audio.lib")
        #pragma comment(lib,"sfml-network.lib")
        #pragma comment(lib,"sfml-window.lib")
        #pragma comment(lib,"sfml-system.lib")
        #pragma comment(lib,"sfml-main.lib")
    #endif

#else
    #error "Neither SFML_STATIC nor SFML_DYNAMIC defined.  WTF"
#endif

#endif // SFMLFULL_INCLUDED 


Note:
- I never actually tried this with dynamic libs as I pretty much always just use static libs on Windows when feasible. So the above is untested for your case. But I don't see any reason why it wouldn't work.

- This would be suboptimal for release builds because you're linking to all libs (even those you aren't necessarily using). Again this is a non-issue for static libs, but it might be an issue for dynamic ones. It won't stop anything from working, it will just add unnecessary dependencies.

- If you do this, you don't need to link to any libs in VS's project settings (that's kind of the point... I hate doing that for every new project I make).
Thanks for the continued help
I tried it, but on running I got an error about Windows\SysWOW64\kernel.dll's saying they couldnt find or open the PDB file.

Running as adminstrator fixed that, but I still get it with sfml-graphics-d.dll. I've tried redownloading it, recopying it, copying it from the vs2008 folder instead.
Confusion :(

I read somewhere that the 2.0 beta was better with 2010? I'm not sure if trying to get that will be easier or not

'sfmltest.exe': Loaded 'C:\Users\Josh\Documents\Visual Studio 2010\Projects\sfmltest\Debug\sfmltest.exe', Symbols loaded.
'sfmltest.exe': Loaded 'C:\Windows\SysWOW64\ntdll.dll', Symbols loaded (source information stripped).
'sfmltest.exe': Loaded 'C:\Windows\SysWOW64\kernel32.dll', Symbols loaded (source information stripped).
'sfmltest.exe': Loaded 'C:\Windows\SysWOW64\KernelBase.dll', Symbols loaded (source information stripped).
'sfmltest.exe': Loaded 'C:\Users\Josh\Documents\Visual Studio 2010\Projects\sfmltest\Debug\sfml-graphics-d.dll', Cannot find or open the PDB file
The program '[4132] sfmltest.exe: Native' has exited with code -1072365566 (0xc0150002).


Don't try to use the .lib/.dll files that come with SFML. Rebuild it yourself and use your own binaries. SFML has weird problems if the compiler versions don't exactly match, so sharing the libs is a little difficult (part of the reason why I prefer static libs). What's probably happening is you're using libs that were built with VS 2008 in VS 2010, which won't work.


SFML 2.0 is certainly better, but it's still in development (not even in beta yet), so if you use it, you have to expect some API changes. It's actually quite stable, though so I would recommend it.


For 2.0, follow this guide:
http://www.sfml-dev.org/tutorials/2.0/compile-with-cmake.php

For 1.6, delete any .lib / .dll files you have, then follow the "Compiling SFML" steps at the bottom of this page:
http://www.sfml-dev.org/tutorials/1.6/start-vc.php



EDIT:

And yes, I realize getting this all set up is kind of tricky for a beginner. But trust me, it's worth it! Stick with it! =D
Last edited on
Awesome I'll look for a 2.0 download

Yeah I tried rebuilding them all but I kept getting a 5 succeeded 1 failed error, hmmm I'll work on it and edit this with any updates

Thanks again :)


Edit: On debugging the sfml.sln file I get an error
Unable to start progream
'C:\Users\Josh\Desktop\SFML-1.6\build\vc2008\..\..\Temp\vc2008\sfml-audio\Debug DLL\sfml-audio.dll

The system cannot find the file specified

Edit2: I think the SFML installation is clashing with an Allegro installation I tried a couple of weeks ago. Uninstalling/Reinstalling Visual Studio now to see if it helps.

Edit3: I can now build Release and Debug Static, but the DLL's give this:


1>------ Build started: Project: sfml-system, Configuration: Release DLL Win32 ------
1>Build started 20/07/2011 14:30:19.
1>InitializeBuildStatus:
1> Creating "C:\Users\Josh\Desktop\SFML-1.6\build\vc2008\..\..\Temp\vc2008\sfml-system\Release DLL\sfml-system.unsuccessfulbuild" because "AlwaysCreate" was specified.
1>ClCompile:
1> All outputs are up-to-date.
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets(990,5): warning MSB8012: TargetPath(C:\Users\Josh\Desktop\SFML-1.6\build\vc2008\..\..\Temp\vc2008\sfml-system\Release DLL\sfml-system.dll) does not match the Linker's OutputFile property value (C:\Users\Josh\Desktop\SFML-1.6\lib\vc2008\sfml-system.dll). This may cause your project to build incorrectly. To correct this, please make sure that $(OutDir), $(TargetName) and $(TargetExt) property values match the value specified in %(Link.OutputFile).
2>------ Build started: Project: sfml-network, Configuration: Release DLL Win32 ------
2>Build started 20/07/2011 14:30:20.
2>InitializeBuildStatus:
2> Creating "C:\Users\Josh\Desktop\SFML-1.6\build\vc2008\..\..\Temp\vc2008\sfml-network\Release DLL\sfml-network.unsuccessfulbuild" because "AlwaysCreate" was specified.
1>LINK : fatal error LNK1181: cannot open input file 'sfml-system-d.lib'
2>ClCompile:
2> All outputs are up-to-date.
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:00.19
2>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets(990,5): warning MSB8012: TargetPath(C:\Users\Josh\Desktop\SFML-1.6\build\vc2008\..\..\Temp\vc2008\sfml-network\Release DLL\sfml-network.dll) does not match the Linker's OutputFile property value (C:\Users\Josh\Desktop\SFML-1.6\lib\vc2008\sfml-network.dll). This may cause your project to build incorrectly. To correct this, please make sure that $(OutDir), $(TargetName) and $(TargetExt) property values match the value specified in %(Link.OutputFile).
2>LINK : fatal error LNK1181: cannot open input file 'sfml-system-d.lib'
2>
2>Build FAILED.
2>
2>Time Elapsed 00:00:00.12
3>------ Build started: Project: sfml-window, Configuration: Release DLL Win32 ------
3>Build started 20/07/2011 14:30:20.
3>InitializeBuildStatus:
3> Creating "C:\Users\Josh\Desktop\SFML-1.6\build\vc2008\..\..\Temp\vc2008\sfml-window\Release DLL\sfml-window.unsuccessfulbuild" because "AlwaysCreate" was specified.
3>ClCompile:
3> All outputs are up-to-date.
3> All outputs are up-to-date.
3>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets(990,5): warning MSB8012: TargetPath(C:\Users\Josh\Desktop\SFML-1.6\build\vc2008\..\..\Temp\vc2008\sfml-window\Release DLL\sfml-window.dll) does not match the Linker's OutputFile property value (C:\Users\Josh\Desktop\SFML-1.6\lib\vc2008\sfml-window.dll). This may cause your project to build incorrectly. To correct this, please make sure that $(OutDir), $(TargetName) and $(TargetExt) property values match the value specified in %(Link.OutputFile).
3>LINK : fatal error LNK1181: cannot open input file 'sfml-system-d.lib'
4>------ Build started: Project: sfml-audio, Configuration: Release DLL Win32 ------
3>
3>Build FAILED.
3>
3>Time Elapsed 00:00:00.14
4>Build started 20/07/2011 14:30:20.
4>InitializeBuildStatus:
4> Creating "C:\Users\Josh\Desktop\SFML-1.6\build\vc2008\..\..\Temp\vc2008\sfml-audio\Release DLL\sfml-audio.unsuccessfulbuild" because "AlwaysCreate" was specified.
4>ClCompile:
4> All outputs are up-to-date.
4> All outputs are up-to-date.
4>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets(990,5): warning MSB8012: TargetPath(C:\Users\Josh\Desktop\SFML-1.6\build\vc2008\..\..\Temp\vc2008\sfml-audio\Release DLL\sfml-audio.dll) does not match the Linker's OutputFile property value (C:\Users\Josh\Desktop\SFML-1.6\lib\vc2008\sfml-audio.dll). This may cause your project to build incorrectly. To correct this, please make sure that $(OutDir), $(TargetName) and $(TargetExt) property values match the value specified in %(Link.OutputFile).
5>------ Build started: Project: sfml-graphics, Configuration: Release DLL Win32 ------
5>Build started 20/07/2011 14:30:20.
5>InitializeBuildStatus:
5> Touching "C:\Users\Josh\Desktop\SFML-1.6\build\vc2008\..\..\Temp\vc2008\sfml-graphics\Release DLL\sfml-graphics.unsuccessfulbuild".
4>LINK : fatal error LNK1181: cannot open input file 'sfml-system-d.lib'
4>
4>Build FAILED.
4>
4>Time Elapsed 00:00:00.14
5>ClCompile:
5> stb_image_aug.c
5> glew.c
5> Color.cpp
5> Drawable.cpp
5> Font.cpp
5> FontLoader.cpp
5> GraphicsContext.cpp
5> Image.cpp
5> Matrix3.cpp
5> PostFX.cpp
5> RenderTarget.cpp
5> RenderWindow.cpp
5> Shape.cpp
5> Sprite.cpp
5> String.cpp
5> View.cpp
5> ImageLoader.cpp
5>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets(990,5): warning MSB8012: TargetPath(C:\Users\Josh\Desktop\SFML-1.6\build\vc2008\..\..\Temp\vc2008\sfml-graphics\Release DLL\sfml-graphics.dll) does not match the Linker's OutputFile property value (C:\Users\Josh\Desktop\SFML-1.6\lib\vc2008\sfml-graphics.dll). This may cause your project to build incorrectly. To correct this, please make sure that $(OutDir), $(TargetName) and $(TargetExt) property values match the value specified in %(Link.OutputFile).
5>LINK : fatal error LNK1181: cannot open input file 'sfml-system-d.lib'
5>
5>Build FAILED.
5>
5>Time Elapsed 00:00:06.69
========== Build: 0 succeeded, 5 failed, 1 up-to-date, 0 skipped ==========
Last edited on
bump, just incase you get an email x-)
Sorry for the slow reply. I totally didn't see your earliest post.

You need to add a path for the libs in VS, just like you specify the path for the headers.

It looks like you're using VS, so see this page:
http://sfml-dev.org/tutorials/1.6/start-vc.php

Specifically the section called "Leave the SFML files where you want, and setup Visual Studio so that it can find them". The section with those pictures.

Make sure you put in both the Header and Library paths, then rebuild.
I didn't think about that, I've been trying to find the right place to put the files haha. I've got 2.0 now and it seems to be working okay :)

The only problem is though, both the debug and release configurations have these under inherited values

sfml-system-d.lib
sfml-graphics-d.lib
sfml-window-d.lib
kernel32.lib
user32.lib
gdi32.lib
winspool.lib
comdlg32.lib
advapi32.lib
shell32.lib
ole32.lib
oleaut32.lib
uuid.lib
odbc32.lib
odbccp32.lib

and I have no idea how to change them. It seems to be working at the moment, but I'm only using debug and to be honest am not sure how to build a release haha

Topic archived. No new replies allowed.