SFML community forums

Help => General => Topic started by: Kyle on September 29, 2009, 07:02:13 pm

Title: Basic error
Post by: Kyle on September 29, 2009, 07:02:13 pm
When following the first window tutorials i encountered this error

1>SFML program.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall sf::Window::~Window(void)" (__imp_??1Window@sf@@UAE@XZ) referenced in function _main
1>SFML program.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall sf::Window::Display(void)" (__imp_?Display@Window@sf@@QAEXXZ) referenced in function _main
1>SFML program.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::Window::Window(class sf::VideoMode,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,unsigned long,struct sf::WindowSettings const &)" (__imp_??0Window@sf@@QAE@VVideoMode@1@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@KABUWindowSettings@1@@Z) referenced in function _main
1>SFML program.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::VideoMode::VideoMode(unsigned int,unsigned int,unsigned int)" (__imp_??0VideoMode@sf@@QAE@III@Z) referenced in function _main
1>C:\Documents and Settings\Kairu\Desktop\VC++ misc\cube\SFML program\Debug\SFML program.exe : fatal error LNK1120: 4 unresolved externals

Any ideas?
Title: Basic error
Post by: Laurent on September 29, 2009, 07:19:34 pm
You have to link to sfml-window.lib.
Title: Basic error
Post by: Kyle on September 29, 2009, 07:34:22 pm
Ah thank you :)
Title: Basic error
Post by: Kyle on September 29, 2009, 08:35:12 pm
I got more errors, i think i have not followed the instructions correctly xD

Quote
1>SFML program.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall sf::RenderWindow::~RenderWindow(void)" (__imp_??1RenderWindow@sf@@UAE@XZ) referenced in function _main
1>SFML program.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall sf::RenderTarget::Clear(class sf::Color const &)" (__imp_?Clear@RenderTarget@sf@@QAEXABVColor@2@@Z) referenced in function _main
1>SFML program.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::Color::Color(unsigned char,unsigned char,unsigned char,unsigned char)" (__imp_??0Color@sf@@QAE@EEEE@Z) referenced in function _main
1>SFML program.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::RenderWindow::RenderWindow(class sf::VideoMode,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,unsigned long,struct sf::WindowSettings const &)" (__imp_??0RenderWindow@sf@@QAE@VVideoMode@1@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@KABUWindowSettings@1@@Z) referenced in function _main
1>C:\Documents and Settings\Kairu\Desktop\VC++ misc\cube\SFML program\Debug\SFML program.exe : fatal error LNK1120: 4 unresolved externals


Here is code:

Code: [Select]
#include "stdafx.h"
#include <SFML/System.hpp>

#include <iostream>
#include <SFML/Graphics.hpp>

using namespace sf;
using namespace std;
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;
}
Title: Basic error
Post by: Laurent on September 29, 2009, 09:21:18 pm
You haven't linked to sfml-graphics.lib.

The rule is simple: if you include <SFML/Xxx.hpp> then you have to link to sfml-xxx.lib. SFML is split into modules, you have to adjust the compiler/linker options for each module that you use.
Title: Basic error
Post by: Kyle on September 29, 2009, 09:26:14 pm
First-chance exception at 0x43003d00 in SFML program.exe: 0xC0000005: Access violation reading location 0x43003d00.
A buffer overrun has occurred in SFML program.exe which has corrupted the program's internal state. Press Break to debug the program or Continue to terminate the program.

For more details please see Help topic 'How to debug Buffer Overrun Issues'.


it points to this piece of code:
  App.Clear(sf::Color(200, 0, 0));
Title: Basic error
Post by: Laurent on September 29, 2009, 09:27:45 pm
Link to the debug libraries (suffix "-d") when you compile in debug mode.

Hey, this one is written in the tutorials ;)
Title: Basic error
Post by: Kyle on September 29, 2009, 09:35:21 pm
Sorry, but your tutorials are very good but sometimes i become a bit confused, Is there some were i can look up more on Events?
Title: Basic error
Post by: Laurent on September 29, 2009, 09:42:30 pm
Quote
Sorry, but your tutorials are very good but sometimes i become a bit confused

That's why this piece of information is written in the "getting started tutorial", with the word "important" in bold/blue font to start the paragraph.

Quote
Is there some were i can look up more on Events?

In the "Handling events" tutorial :roll:
And in the API documentation, of course.
Title: Basic error
Post by: Kyle on September 29, 2009, 09:48:57 pm
Microsoft Visual Studio C Runtime Library has detected a fatal error in SFML program.exe.

Press Break to debug the program or Continue to terminate the program.
Title: Basic error
Post by: Kyle on September 29, 2009, 10:19:15 pm
Is it another obvious reason it is not working that i am missing xD
Title: Basic error
Post by: phear- on September 29, 2009, 10:24:55 pm
Do you even know C++? If not I would highly recommend you read some books or tutorials on it.
Title: Basic error
Post by: Kyle on September 29, 2009, 10:27:46 pm
Ok now, i can see where this is going, yes i do.
Title: Basic error
Post by: phear- on September 29, 2009, 10:37:39 pm
The reason I ask is because you use:

Code: [Select]

using namespace sf;


but then later on in your code you use
Code: [Select]

sf::
Title: Basic error
Post by: Kyle on September 29, 2009, 10:40:40 pm
Yea, i was wondering if i was not understanding correctly, and i was told why it was like that.

Why does the error i have now point to this line?

while (App.GetEvent(Event))

EDIT:
oh sorry i thought you were referring to one of my earlier topics, no i do that because i was testing something  and forgot to remove it xD
Title: Basic error
Post by: Laurent on September 29, 2009, 11:09:45 pm
Can you upload your project file so that we can take a look at it?
Title: Basic error
Post by: Kyle on September 30, 2009, 05:27:32 pm
How to i upload an attachment, cant seem to find it, or do i use something external like rapidshare
Title: Basic error
Post by: Laurent on September 30, 2009, 05:56:42 pm
Quote
How to i upload an attachment, cant seem to find it

You can't upload anything directly with the forum.

Quote
or do i use something external like rapidshare

Yes, you can use rapidshare or megaupload to upload your files.
Title: Basic error
Post by: Kyle on September 30, 2009, 06:05:58 pm
http://rapidshare.com/files/286964540/SFML_program.sln.html
Title: Basic error
Post by: Laurent on September 30, 2009, 07:27:30 pm
The .sln file only references the project files (.vcproj), it's completely useless ;)

You should rather upload the .vcproj file.
Title: Basic error
Post by: Kyle on September 30, 2009, 07:35:01 pm
http://rapidshare.com/files/286999792/SFML_program.vcproj.html
Title: Basic error
Post by: Laurent on September 30, 2009, 08:28:27 pm
Quote
sfml-system.lib. sfml-window.lib. sfml-graphics-d.lib.

You're correctly linking the debug version of the graphics module, but the release version of the window and system modules.
Title: Basic error
Post by: ARodrigues on October 10, 2009, 05:43:05 pm
Hello everyone,

I already link the libs but still with this error:

1>MSVCRT.lib(crtexew.obj) : error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup

What should I do?
Title: Basic error
Post by: Tank on October 10, 2009, 06:05:12 pm
Link to sfml-main-d. Did you read the tutorials? :)
Title: Basic error
Post by: ARodrigues on October 10, 2009, 06:20:55 pm
Gave this error in the first tutorial :?
Ups I forgot sfml-main lib :oops:

Thanks   :D

edit: but for some reason can't find sfml-window.dll  :(
Title: Basic error
Post by: Laurent on October 11, 2009, 02:20:09 pm
Quote
but for some reason can't find sfml-window.dll

Is it in the same folder as the executable? Does it find other DLLs?
Title: Basic error
Post by: ARodrigues on October 11, 2009, 02:38:00 pm
Yes is in the same directory. It gives error with no more DLL
Title: Basic error
Post by: Laurent on October 11, 2009, 02:53:23 pm
Can you upload an archive containing the executable and the DLLs?
Title: Basic error
Post by: ARodrigues on October 11, 2009, 02:58:22 pm
Already solved.
I have placed the wrong dll xD

Thanks for help  :lol: