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

Author Topic: Can't compile sample code  (Read 18065 times)

0 Members and 1 Guest are viewing this topic.

darekg11

  • Full Member
  • ***
  • Posts: 127
    • View Profile
Can't compile sample code
« on: September 19, 2010, 07:56:52 pm »
Hello, I just downloaded SFML library, I placed lib and includes in right directories and when I try to compile sample source I get this:

c:\documents and settings\darek\moje dokumenty\visual studio 2008\projects\test\test\main.cpp(31) : error C3861: 'sfFont_CreateFromFile': identifier not found
c:\documents and settings\darek\moje dokumenty\visual studio 2008\projects\test\test\main.cpp(74) : error C3861: 'sfFont_Destroy': identifier not found

Anyway help really appreicate.

EDIT: When I include:
#include <SFML/Graphics/Font.h>

I get a wall of external linker errors.

Please help I would really like to solve this and start some coding, I also searched forum but couldn't find anything helpful.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Can't compile sample code
« Reply #1 on: September 19, 2010, 09:59:25 pm »
Quote
I get a wall of external linker errors.

Do you link to csfml-graphics?
Laurent Gomila - SFML developer

darekg11

  • Full Member
  • ***
  • Posts: 127
    • View Profile
Can't compile sample code
« Reply #2 on: September 20, 2010, 07:28:53 am »
When I add to Additional Dependies or whatever a name:
csfml-graphics without extensions I get one error:
LINK : fatal error LNK1104: cannot open file 'csfml-graphics.obj'
When I add csfml-graphics.lib I get the same wall of errors.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Can't compile sample code
« Reply #3 on: September 20, 2010, 08:01:13 am »
Quote
When I add csfml-graphics.lib I get the same wall of errors.

Did you tell your compiler where the csfml-xxx.lib files are located, so that it can find them?
Laurent Gomila - SFML developer

darekg11

  • Full Member
  • ***
  • Posts: 127
    • View Profile
Can't compile sample code
« Reply #4 on: September 20, 2010, 08:10:05 am »
I putted all lib's to VC/Lib folder I also putted it in options of linker.


Okay, I will tell what I have done from the begging.
First I downloaded full SDK for C 1.6v.
I copied SFML folder from include folder to VC/include.
I copied all libs from library folder to VC/lib

I tried to compile that sample code from documentation but I can't because of this two errors:
c:\documents and settings\darek\moje dokumenty\visual studio 2008\projects\test\test\main.cpp(31) : error C3861: 'sfFont_CreateFromFile': identifier not found
c:\documents and settings\darek\moje dokumenty\visual studio 2008\projects\test\test\main.cpp(74) : error C3861: 'sfFont_Destroy': identifier not found

Thanks for spending Your time to help me.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Can't compile sample code
« Reply #5 on: September 20, 2010, 08:43:19 am »
You must include the corresponding headers, like you did in your first post.
Laurent Gomila - SFML developer

darekg11

  • Full Member
  • ***
  • Posts: 127
    • View Profile
Can't compile sample code
« Reply #6 on: September 20, 2010, 12:29:50 pm »
I included Fonts/h like in my first post and now I also putted csfml-graphics.lib in Additional Dependieces and I still got that wall of errors.

Sorry for all this trouble but I would really like to use Your library since it's perfect for my project.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Can't compile sample code
« Reply #7 on: September 20, 2010, 12:32:09 pm »
Quote
and I still got that wall of errors

Which ones?
Laurent Gomila - SFML developer

darekg11

  • Full Member
  • ***
  • Posts: 127
    • View Profile
Can't compile sample code
« Reply #8 on: September 20, 2010, 01:35:37 pm »
I will show You screenshots.
Include section:

Additional:

Preprocessor:

Errors:



That's how it looks, anyway if You have any better thing to do than trying to solve it out then just leave this topic and I will try to handle it by my own.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Can't compile sample code
« Reply #9 on: September 20, 2010, 01:42:57 pm »
In debug you must link to the debug build of CSFML (csfml-graphics-d.lib).
Laurent Gomila - SFML developer

darekg11

  • Full Member
  • ***
  • Posts: 127
    • View Profile
Can't compile sample code
« Reply #10 on: September 20, 2010, 01:56:56 pm »
After linking csfml-graphics-d.lib nothing changed.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Can't compile sample code
« Reply #11 on: September 20, 2010, 04:29:03 pm »
I'm not sure about the C-Binding, but normally, you have to link the system and window package as well, if you use the graphics package.

But, according to the errors, the definitions in the graphics package aren't found... Weird :?
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

darekg11

  • Full Member
  • ***
  • Posts: 127
    • View Profile
Can't compile sample code
« Reply #12 on: September 20, 2010, 04:40:36 pm »
After adding system and windows package I got this:
E:\Program Files\Microsoft Visual Studio 9.0\VC\lib\csfml-system.dll : fatal error LNK1107: invalid or corrupt file: cannot read at 0x2C0

Well that same error goes when I try to link csfml-system-d.dll instead of normal, god damn it why it just can't compile right fack >.>

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Can't compile sample code
« Reply #13 on: September 20, 2010, 04:40:40 pm »
This is because you use CSFML with a C++ compiler. Do this to solve your problem:

Code: [Select]
extern "C"
{
    #include <SFML/Graphics.h>
    ... all your SFML includes ...
}


By the way, why don't you use the C++ version of SFML?
Laurent Gomila - SFML developer

darekg11

  • Full Member
  • ***
  • Posts: 127
    • View Profile
Can't compile sample code
« Reply #14 on: September 20, 2010, 04:51:48 pm »
Man, fack jeah that was that thing.
Now it working.

Thanks and I don't like C++ and I am using C++ compilator because I was learning basic of programming at it.
Well it works now but I have like 3 more questions to You:

In Debug mode I need to include libs with -d sufix right?
And which libraries do I need to include when I want build it in Release?
And when I want to share that program with my friend I just need to give him right dll's right?

I also made a simple window and code of it looks like that:
http://wklej.org/id/391461/

And it's lagging my computer like hell, app is tkaing 100% CPU all the time, how Can I prevent that?