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

Author Topic: Program doesn't start (using CodeBlocks)  (Read 3712 times)

0 Members and 1 Guest are viewing this topic.

maliklund87

  • Newbie
  • *
  • Posts: 4
    • View Profile
Program doesn't start (using CodeBlocks)
« on: July 26, 2011, 02:52:31 pm »
Hi

I'm new to C++ and I'm having a hard time getting to grips with compilers and linkers and whatnot (I have been programming in Java for a few years).

I have had SFML up and running, but I just started a new project and now my programs won't start up at all. It compiles without issues, but when I start the program the cmd-prompt appears and nothing happens.

I tried putting a cout at the beginning of the main-method but that isn't even run.

Anyone knows what's going on?

thePyro_13

  • Full Member
  • ***
  • Posts: 156
    • View Profile
Program doesn't start (using CodeBlocks)
« Reply #1 on: July 26, 2011, 03:01:06 pm »
Do you have an ATI video card?

I just moved across from an Nvidia to ATI and my previously working project exhibits the same behaviour.

I'm heard this is a glitch in the 1.6 version of the library that only effects ATI cards.

I'd recommend moving to a stable revision of the 2.0 library.

maliklund87

  • Newbie
  • *
  • Posts: 4
    • View Profile
Program doesn't start (using CodeBlocks)
« Reply #2 on: July 26, 2011, 03:14:24 pm »
I do actually have an ATI card, but I've had it throughout my SFML-tinkering and I've had code working before.

I have two projects, each with nearly identical code, and the program starts fine with one project but won't start in the other. o.O

OniLinkPlus

  • Hero Member
  • *****
  • Posts: 500
    • View Profile
Program doesn't start (using CodeBlocks)
« Reply #3 on: July 26, 2011, 10:41:13 pm »
Quote from: "maliklund87"
I do actually have an ATI card, but I've had it throughout my SFML-tinkering and I've had code working before.

I have two projects, each with nearly identical code, and the program starts fine with one project but won't start in the other. o.O
I'm going to assume that in the working one, you statically linked with SFML, and in the not working one, you dynamically linked. Am I right?
I use the latest build of SFML2

maliklund87

  • Newbie
  • *
  • Posts: 4
    • View Profile
Program doesn't start (using CodeBlocks)
« Reply #4 on: July 27, 2011, 12:19:48 am »
@OniLink10
Yes, you're right. I hadn't thought about that. Thank you.

Though, now I get some undefined reference-errors (are those related to the compiler or to the linker settings?) and I can't see what I'm doing differently from the tutorial :?

My code is just supposed to display a sprite in a RenderWindow. Am I right in assuming I then need to link to -lsfml-graphics-s-d, -lsfml-window-s-d and -lsfml-system-s-d?

Would you mind explaining what the difference is between using the static and the dynamic versions of the library?

OniLinkPlus

  • Hero Member
  • *****
  • Posts: 500
    • View Profile
Program doesn't start (using CodeBlocks)
« Reply #5 on: July 27, 2011, 06:39:51 am »
Quote from: "maliklund87"
Though, now I get some undefined reference-errors (are those related to the compiler or to the linker settings?) and I can't see what I'm doing differently from the tutorial :?
Mind posting the exact contents of the errors?

Quote
My code is just supposed to display a sprite in a RenderWindow. Am I right in assuming I then need to link to -lsfml-graphics-s-d, -lsfml-window-s-d and -lsfml-system-s-d?
Only in debug mode. In release mode, remove the -d.

Quote
Would you mind explaining what the difference is between using the static and the dynamic versions of the library?
Static includes all of the contents of SFML in your program. Dynamic puts all of SFML's stuff into separate files. Why this causes errors with ATi has to do with drivers and the way SFML is set up in 1.x. Ask Laurent. If you don't want to worry about the error, use SFML2 instead.
I use the latest build of SFML2

maliklund87

  • Newbie
  • *
  • Posts: 4
    • View Profile
Program doesn't start (using CodeBlocks)
« Reply #6 on: July 27, 2011, 09:49:01 am »
Thanks for reply :)

I get errors no matter what I try to use from SFML. The complete list is below (minus directory):

undefined reference to `_imp___ZN2sf9VideoModeC1Ejjj'
undefined reference to '_imp___ZN2sf12RenderWindowC1ENS_9VideoModeERKSsmRKNS_14WindowSettingsE
undefined reference to `_imp___ZN2sf5ImageC1Ev'
undefined reference to `_imp___ZN2sf12RenderWindowD1Ev'
undefined reference to `_imp___ZN2sf5Image12LoadFromFileERKSs'
undefined reference to `_imp___ZN2sf5Image9SetSmoothEb'
undefined reference to `_imp___ZN2sf5ColorC1Ehhhh'
undefined reference to `_imp___ZN2sf6SpriteC1ERKNS_5ImageERKNS_7Vector2IfEES7_fRKNS_5ColorE'
undefined reference to `_imp___ZN2sf8Drawable11SetPositionEff'
undefined reference to `_imp___ZN2sf8Drawable8SetScaleEff'
undefined reference to `_imp___ZN2sf6Window5CloseEv'
undefined reference to `_imp___ZN2sf6Window5CloseEv'
undefined reference to `_imp___ZN2sf6Window8GetEventERNS_5EventE'
undefined reference to `_imp___ZN2sf5ColorC1Ehhhh'
undefined reference to `_imp___ZN2sf12RenderTarget5ClearERKNS_5ColorE'
undefined reference to `_imp___ZN2sf12RenderTarget4DrawERKNS_8DrawableE'
undefined reference to `_imp___ZN2sf6Window7DisplayEv'
undefined reference to `_imp___ZNK2sf6Window8IsOpenedEv'
undefined reference to `_imp___ZN2sf5ImageD1Ev'
undefined reference to `_imp___ZN2sf5ImageD1Ev'
undefined reference to `_imp___ZN2sf12RenderWindowD1Ev'
undefined reference to `_imp___ZN2sf12RenderWindowD1Ev'

Sprite.hpp:
undefined reference to `_imp___ZTVN2sf6SpriteE'
undefined reference to `_imp___ZN2sf8DrawableD2Ev'
undefined reference to `_imp___ZN2sf8DrawableD2Ev'

OniLinkPlus

  • Hero Member
  • *****
  • Posts: 500
    • View Profile
Program doesn't start (using CodeBlocks)
« Reply #7 on: July 27, 2011, 08:14:50 pm »
You're using SFML 1.6, correct? If so, add SFML_DYNAMIC to your compiler's #defines
I use the latest build of SFML2