SFML community forums
Bindings - other languages => C => Topic started by: darekg11 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.
-
I get a wall of external linker errors.
Do you link to csfml-graphics?
-
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.
-
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?
-
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.
-
You must include the corresponding headers, like you did in your first post.
-
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.
-
and I still got that wall of errors
Which ones?
-
I will show You screenshots.
Include section:
(http://img828.imageshack.us/img828/7272/kod.png)
Additional:
(http://img718.imageshack.us/img718/8083/additional.jpg)
Preprocessor:
(http://img443.imageshack.us/img443/3593/preprocessor.jpg)
Errors:
(http://img201.imageshack.us/img201/3396/errorzk.jpg)
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.
-
In debug you must link to the debug build of CSFML (csfml-graphics-d.lib).
-
After linking csfml-graphics-d.lib nothing changed.
-
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 :?
-
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 >.>
-
This is because you use CSFML with a C++ compiler. Do this to solve your problem:
extern "C"
{
#include <SFML/Graphics.h>
... all your SFML includes ...
}
By the way, why don't you use the C++ version of SFML?
-
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?
-
In Debug mode I need to include libs with -d sufix right?
Yes.
And which libraries do I need to include when I want build it in Release?
The ones without the -d suffix ;)
And when I want to share that program with my friend I just need to give him right dll's right?
Yes.
And it's lagging my computer like hell, app is tkaing 100% CPU all the time, how Can I prevent that?
You have two simple ways of limiting the framerate:
- sfRenderWindow_UseVerticalSync(window, true)
- sfRenderWindow_SetFramerateLimit(window, 60)
-
I think it's not related to FPS, because Your solution did not help.
It laggs the whole computer not only the app.
Extra question:
How to get rid of that console background?
I found that I need to change in Linker's options In System to: Window I did but I can't find CSFML-main.lib so I can't link it and I get:
error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup
Thanks again man for help You are great big props.
-
I can't find CSFML-main.lib
Indeed it's missing from the CSFML 1.6 SDK. You'll have to handle it by yourself.
-
Yeah, I solved that problem.
I just can't come up with anything that could fix that 100% CPU use.
Code:
http://wklej.org/id/391461/
-
- sfRenderWindow_UseVerticalSync(window, true)
- sfRenderWindow_SetFramerateLimit(window, 60)
These two functions do reduce the CPU usage of your application. How did you try to use them?
-
I tried using after:
aaa = sfRenderWindow_Create(Mode, "Maslo", sfResize | sfClose, Settings);
sfRenderWindow_SetFramerateLimit(aaa, 60);
sfRenderWindow_Display(aaa);
I also tried to use that in loop but no effect.
-
What if you call sfSleep in your main loop?
-
It was lagging like hell because I placed:
sfRenderWindow_Clear(aaa, sfBlack);
In infinite loop so it was refresing it all the time, I placed it outside and it's all good.
Thanks again You can close now.
-
You're supposed to clear your window all the time. You'll probably come back to the same problem when you start drawing something.
-
God damn it, really?
SfSleep is not helping.
-
What's your graphics card? Are your drivers up-to-date?
-
Nvidia GeForce 7600GS 256MB DDR2.
Drivers are not the newest but they are also not the oldest.
Version of them: 6.14.11.9621
Hmm I can't come up with anything that could prevent it, damn.
-
Are you able to run games or OpenGL apps on this computer?
-
EDIT: Solved, I wasn't updating the window when I putted in a loop:
sfRenderWindow_Clear(aaa, sfRed);
sfRenderWindow_Display(aaa);
It is working great now, thank again mate.