Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Just installed SFML into codeblocks.  (Read 5072 times)

0 Members and 1 Guest are viewing this topic.

Jayzan

  • Newbie
  • *
  • Posts: 8
    • View Profile
Just installed SFML into codeblocks.
« on: June 09, 2011, 01:27:51 am »
I was able to get SFML installed and working with codeblocks. Well, at least working with the first bit of code that it gave on the installation tutorial page http://www.sfml-dev.org/tutorials/1.6/start-cb.php
The code was:

Code: [Select]
#include <SFML/System.hpp>
#include <iostream>

int main()
{
    sf::Clock Clock;
    while (Clock.GetElapsedTime() < 5.f)
    {
        std::cout << Clock.GetElapsedTime() << std::endl;
        sf::Sleep(0.5f);
    }

    return 0;
}


This worked after I searched for the sfml-system.dll and put it in the path folder, but since this time, I have not been able to get get any of the code from the rest of the tutorials to compile, and they are all giving out of scope errors.  'sf3d' has not been declared, sf3d.hpp. no such file or directory, renderer was not declared in this scope.  I'm not sure what I need to do. The stuff from that tutorial link above has already been done, but it's not compiling the code examples from any of the code on the following tutorials.  Thanks for any help!

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Just installed SFML into codeblocks.
« Reply #1 on: June 09, 2011, 07:43:29 am »
Quote
'sf3d' has not been declared, sf3d.hpp. no such file or directory, renderer was not declared in this scope.

sf3d is not SFML. What tutorials did you read?
Laurent Gomila - SFML developer

Jayzan

  • Newbie
  • *
  • Posts: 8
    • View Profile
The tutorial
« Reply #2 on: June 09, 2011, 04:47:12 pm »
Quote from: "Laurent"
Quote
'sf3d' has not been declared, sf3d.hpp. no such file or directory, renderer was not declared in this scope.

sf3d is not SFML. What tutorials did you read?


The sf3d was from probably the third or fourth example code I tried, might have found it on a different site.  

The first tutorial I found is http://www.sfml-dev.org/tutorials/1.6/system-threads.php

So, the above link is for the first tutorial after the installation example code that worked for me.  The errors I get from the (system-threads.cpp)code downloaded from the bottom of that page are:


-------------- Build: Debug in test2 ---------------

Compiling: main.cpp
Linking console executable: bin\Debug\test2.exe
obj\Debug\main.o: In function `Z12MyThreadFuncPv':
C:/Users/Jason/Desktop/Programming/test2/main.cpp:21: undefined reference to `_imp___ZN2sf5Mutex4LockEv'
C:/Users/Jason/Desktop/Programming/test2/main.cpp:28: undefined reference to `_imp___ZN2sf5Mutex6UnlockEv'
obj\Debug\main.o: In function `main':
C:/Users/Jason/Desktop/Programming/test2/main.cpp:67: undefined reference to `_imp___ZN2sf6ThreadC1EPFvPvES1_'
C:/Users/Jason/Desktop/Programming/test2/main.cpp:68: undefined reference to `_imp___ZN2sf6Thread6LaunchEv'
C:/Users/Jason/Desktop/Programming/test2/main.cpp:71: undefined reference to `_imp___ZN2sf5Mutex4LockEv'
C:/Users/Jason/Desktop/Programming/test2/main.cpp:78: undefined reference to `_imp___ZN2sf5Mutex6UnlockEv'
C:/Users/Jason/Desktop/Programming/test2/main.cpp:81: undefined reference to `_imp___ZN2sf6Thread4WaitEv'
C:/Users/Jason/Desktop/Programming/test2/main.cpp:87: undefined reference to `_imp___ZN2sf6Thread6LaunchEv'
C:/Users/Jason/Desktop/Programming/test2/main.cpp:90: undefined reference to `_imp___ZN2sf5Mutex4LockEv'
C:/Users/Jason/Desktop/Programming/test2/main.cpp:97: undefined reference to `_imp___ZN2sf5Mutex6UnlockEv'
C:/Users/Jason/Desktop/Programming/test2/main.cpp:101: undefined reference to `_imp___ZN2sf6Thread4WaitEv'
C:/Users/Jason/Desktop/Programming/test2/main.cpp:107: undefined reference to `_imp___ZN2sf6ThreadD1Ev'
C:/Users/Jason/Desktop/Programming/test2/main.cpp:107: undefined reference to `_imp___ZN2sf6ThreadD1Ev'
obj\Debug\main.o: In function `_tcf_1':
C:/Users/Jason/Desktop/Programming/test2/main.cpp:9: undefined reference to `_imp___ZN2sf5MutexD1Ev'
obj\Debug\main.o: In function `_static_initialization_and_destruction_0':
C:/Users/Jason/Desktop/Programming/test2/main.cpp:9: undefined reference to `_imp___ZN2sf5MutexC1Ev'
obj\Debug\main.o:C:/Users/Jason/Desktop/Programming/test2/main.cpp:46: undefined reference to `_imp___ZN2sf5Mutex4LockEv'
obj\Debug\main.o:C:/Users/Jason/Desktop/Programming/test2/main.cpp:53: undefined reference to `_imp___ZN2sf5Mutex6UnlockEv'
obj\Debug\main.o: In function `MyThread':
C:/Users/Jason/Desktop/Programming/test2/main.cpp:36: undefined reference to `_imp___ZN2sf6ThreadC2Ev'
obj\Debug\main.o: In function `~MyThread':
C:/Users/Jason/Desktop/Programming/test2/main.cpp:36: undefined reference to `_imp___ZN2sf6ThreadD2Ev'
C:/Users/Jason/Desktop/Programming/test2/main.cpp:36: undefined reference to `_imp___ZN2sf6ThreadD2Ev'
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 1 seconds)
20 errors, 0 warnings

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Just installed SFML into codeblocks.
« Reply #3 on: June 09, 2011, 08:56:30 pm »
Can you show the linker settings of your project (what libraries do you link)?
Laurent Gomila - SFML developer

Jayzan

  • Newbie
  • *
  • Posts: 8
    • View Profile
Just installed SFML into codeblocks.
« Reply #4 on: June 09, 2011, 09:11:05 pm »
Quote from: "Laurent"
Can you show the linker settings of your project (what libraries do you link)?


On the Linker Settings, the -lsfml-system was missing from "Other Linker Options"  I added it back and the .cpp file above compiled and ran correctly.  Thank you!

I'm not sure why the settings weren't there anymore. I guess anytime I create a project and I want to use SFML I will have to add that -lsfml-system into that field.  At least now I can try out the other tutorial code and make sure that the codeblocks is running properly before I actually start learning how to use the library. =)  

Much appreciation for your help!

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Just installed SFML into codeblocks.
« Reply #5 on: June 09, 2011, 10:23:57 pm »
Quote
I'm not sure why the settings weren't there anymore. I guess anytime I create a project and I want to use SFML I will have to add that -lsfml-system into that field

Yes. These are the project's settings. So... new project, new settings ;)
Laurent Gomila - SFML developer

Jayzan

  • Newbie
  • *
  • Posts: 8
    • View Profile
more errors
« Reply #6 on: June 10, 2011, 04:32:14 pm »
I was able to build and run the tutorial code until I got to the one where you open a window.  It's window-window.cpp. Found at:
http://www.sfml-dev.org/tutorials/1.6/window-window.php

I checked the linker and library settings, but I'm using the same project and just putting the new code into it. The errors I get are:

-------------- Build: Debug in test2 ---------------

Linking console executable: bin\Debug\test2.exe
obj\Debug\main.o: In function `main':
C:/Users/Jason/Desktop/Programming/test2/main.cpp:17: undefined reference to `_imp___ZN2sf9VideoModeC1Ejjj'
C:/Users/Jason/Desktop/Programming/test2/main.cpp:17: undefined reference to `_imp___ZN2sf6WindowC1ENS_9VideoModeERKSsmRKNS_14WindowSettingsE'
C:/Users/Jason/Desktop/Programming/test2/main.cpp:17: undefined reference to `_imp___ZN2sf6WindowD1Ev'
C:/Users/Jason/Desktop/Programming/test2/main.cpp:23: undefined reference to `_imp___ZN2sf6Window7DisplayEv'
C:/Users/Jason/Desktop/Programming/test2/main.cpp:26: undefined reference to `_imp___ZN2sf6WindowD1Ev'
C:/Users/Jason/Desktop/Programming/test2/main.cpp:26: undefined reference to `_imp___ZN2sf6WindowD1Ev'
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 0 seconds)
6 errors, 0 warnings
 
any ideas?   -Thanks!

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Just installed SFML into codeblocks.
« Reply #7 on: June 10, 2011, 04:33:43 pm »
You're now using a new SFML module, sfml-window, so you must link to it in addition to sfml-system.
Laurent Gomila - SFML developer

Jayzan

  • Newbie
  • *
  • Posts: 8
    • View Profile
Just installed SFML into codeblocks.
« Reply #8 on: June 10, 2011, 04:51:29 pm »
Quote from: "Laurent"
You're now using a new SFML module, sfml-window, so you must link to it in addition to sfml-system.


Ok, I added -lsfml-window to the 'Other Linker Options' under 'Linker Settings' in the 'Global compliler and debugger settings' window.  And It gave me the missing sfml-window.dll error; so I searched my hard drive for that DLL and found it, and put it in the project folder and it now builds/runs and launches the window.  

Thank you for your help.  Is there a way to know what modules/dll's are usable?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Just installed SFML into codeblocks.
« Reply #9 on: June 10, 2011, 05:13:10 pm »
Quote
Is there a way to know what modules/dll's are usable?

Hum??
Laurent Gomila - SFML developer

Jayzan

  • Newbie
  • *
  • Posts: 8
    • View Profile
Just installed SFML into codeblocks.
« Reply #10 on: June 10, 2011, 10:10:32 pm »
Quote from: "Laurent"
You're now using a new SFML module, sfml-window, so you must link to it in addition to sfml-system.


In this post you knew that it needed the sfml-window module. For someone like me who knows nothing about sfml, is there a list of the modules that have to be included in the the linker settings? or a list of dll file names?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Just installed SFML into codeblocks.
« Reply #11 on: June 10, 2011, 10:28:35 pm »
Everything is made so that users can clearly identify SFML modules:
* name of modules: System, Window, Graphics, Network, Audio
* tutorial categories: System, Window, Graphics, Network, Audio (doh! they match :))
* library names: sfml-system, sfml-window, sfml-graphics, sfml-network, sfml-audio
* header names: System.hpp, Window.hpp, Graphics.hpp, Network.hpp, Audio.hpp
* forum categories: System, Window, Graphics, Network, Audio
* modules in API documentation (SFML 2 only): System, Window, Graphics, Network, Audio
...

Here you're reading a tutorial of the Window category, and you included Window.hpp -- so obviously you need to link to sfml-window ;)
Laurent Gomila - SFML developer

Jayzan

  • Newbie
  • *
  • Posts: 8
    • View Profile
Just installed SFML into codeblocks.
« Reply #12 on: June 10, 2011, 10:38:16 pm »
Ahh! Thank you very much!

 

anything