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

Author Topic: Linker warning, linker error :P  (Read 3312 times)

0 Members and 1 Guest are viewing this topic.

NPS

  • Newbie
  • *
  • Posts: 31
    • View Profile
Linker warning, linker error :P
« on: January 18, 2013, 12:41:24 am »
I'm using SFML 2.0, downloaded compiled version from website but when I compiled my project (VS 2010) I got this warning (I've shortened the paths):
Warning 1       warning LNK4099: PDB 'sfml-main-d.pdb' was not found with 'sfml-main-d.lib(SFML_Main.cpp.obj)' or at 'C:\...\Debug\sfml-main-d.pdb'; linking object as if no debug info C:\...\sfml-main-d.lib(SFML_Main.cpp.obj)
I know what it means, I've read on this forum that it's harmless yet I'm just the kind of guy that hates warnings and likes his project compile with none. So I've tried compiling SFML myself and replacing *.lib files (debug version). This rid me of the linker warning but later when I used this:
sf::Font::getDefaultFont()
I got following linker error:
Error   1       error LNK2019: unresolved external symbol "__declspec(dllimport) public: static class sf::Font const & __cdecl sf::Font::getDefaultFont(void)" (__imp_?getDefaultFont@Font@sf@@SAABV12@XZ) referenced in function "public: __thiscall PopupText::PopupText(void)" (??0PopupText@@QAE@XZ)        C:\...\PopupText.obj
which doesn't occur with the *.lib files downloaded from the website (already compiled).

Am I doing something wrong?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10901
    • View Profile
    • development blog
    • Email
Re: Linker warning, linker error :P
« Reply #1 on: January 18, 2013, 12:59:20 am »
sf::Font::getDefaultFont()

Am I doing something wrong?
The default font was removed a few month ago, but the RC still has it and the online documentation represent the RC version.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

NPS

  • Newbie
  • *
  • Posts: 31
    • View Profile
Re: Linker warning, linker error :P
« Reply #2 on: January 18, 2013, 01:16:42 am »
Oh, yeah, my bad, I forgot to mention. I was following this topic: http://en.sfml-dev.org/forums/index.php?topic=6130.0 as I had crashes after closing the window (probably the default font bug). I tried this:
And one more thing, though this might be already known. I didn't want to have to include font with my program and as the built-in arial was pretty good, I just did:
Code: [Select]
sf::Font font = sf::Font::GetDefaultFont();and this one I passed into sf::Text constructor. The result is same as before, but no crash anymore.
Hence the "sf::Font::getDefaultFont()" line in my code. What should I do then (to avoid linker error and window-close-crash)?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10901
    • View Profile
    • development blog
    • Email
Re: Linker warning, linker error :P
« Reply #3 on: January 18, 2013, 01:25:14 am »
As I said the default font got removed in the latest SFML revision, exactly due to such problems from the linked post.

Thus if you want to use a font, you need to load your own font (see here for the official thread about it).
« Last Edit: January 18, 2013, 01:27:04 am by eXpl0it3r »
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

NPS

  • Newbie
  • *
  • Posts: 31
    • View Profile
Re: Linker warning, linker error :P
« Reply #4 on: January 18, 2013, 01:48:11 am »
I'm not sure - how am I supposed to do that? Load my font before the constructor of ANY sf::Text instance gets called?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10901
    • View Profile
    • development blog
    • Email
Re: Linker warning, linker error :P
« Reply #5 on: January 18, 2013, 01:59:45 am »
The default font got removed, the problem described in the other thread only applies to a SFML version with the default font... ::)

Edit: Am I in the right assumption that you're now using your self-built version directly from GitHub?
« Last Edit: January 18, 2013, 02:07:43 am by eXpl0it3r »
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

NPS

  • Newbie
  • *
  • Posts: 31
    • View Profile
Re: Linker warning, linker error :P
« Reply #6 on: January 18, 2013, 02:11:38 am »
Precisely "SFML 2.0 snapshot" (so I guess - yeah).

I asked about the constructor and sf::Text instances because when I don't use sf::Font:getDefaultFont() (and don't provide any font, just instantiate sf::Text and not even use it) I still get a crash after closing the window.

Edit: Actually, that's not true. I get the crash even with no sf::Text objects in the program. I don't know what the problem is.
« Last Edit: January 18, 2013, 02:20:39 am by NPS »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10901
    • View Profile
    • development blog
    • Email
Re: Linker warning, linker error :P
« Reply #7 on: January 18, 2013, 02:20:18 am »
So the following code crashes at exit?
Are you 100% sure your VS setup is using the SFML version you've compiled on your own and not the old RC version?
What's you PC specs?

#include <SFML/Graphics.hpp>

int main()
{
    sf::RenderWindow window(sf::VideoMode(800, 600), "Rotate Test");
    window.setFramerateLimit(60);

    sf::Text text;

    sf::Event event;

    while(window.isOpen())
    {
        while(window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close();

        }

        window.clear();
        window.display();
    }
}
« Last Edit: January 18, 2013, 02:25:41 am by eXpl0it3r »
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

NPS

  • Newbie
  • *
  • Posts: 31
    • View Profile
Re: Linker warning, linker error :P
« Reply #8 on: January 18, 2013, 02:27:58 am »
Nope, this code works fine. Yep, pretty sure it's using "my" version of the library.

I don't wanna copy my whole code here (since it's multiple files already) but does SFML have any restrictions about global objects or the time when objects should be created/deleted/allocated/loaded/feed/etc? :P I'm just guessing now.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10901
    • View Profile
    • development blog
    • Email
Re: Linker warning, linker error :P
« Reply #9 on: January 18, 2013, 02:38:43 am »
For my part I try to avoid global variables as much as possible, which means that I actually haven't used any globals in any of my more or less active projects. In nearly all cases they can be avoided and using them often has more downs than ups, especially in the long term.

In general though one should never instantiate variables globally, because the destruction order of globals isn't defined by C++. You 'can' (but shouldn't) use globals, but make sure you only declare them globally but define them locally.
And as for SFML I'd never use global resources (i.e. windows, textures, fonts, audio, etc.). I'm not sure though if this should also apply to sf::Text... Probably, but then again it's better to actually get rid of the globals rather than trying to cure the symptoms.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

NPS

  • Newbie
  • *
  • Posts: 31
    • View Profile
Re: Linker warning, linker error :P
« Reply #10 on: January 18, 2013, 10:41:29 am »
Ok, turns out it's a completely different problem (either I didn't notice it before, or I did have different problem then, not sure now :P). Sounds/music cause crashes at exit now, probably bug #30. So what should I do now?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10901
    • View Profile
    • development blog
    • Email
Re: Linker warning, linker error :P
« Reply #11 on: January 18, 2013, 11:12:45 am »
Sounds/music cause crashes at exit now, probably bug #30. So what should I do now?
Well if it's bug #30, then you can try to play around with the OpenAL32.dll as suggested in the comments for the issue and if that doesn't help, I guess you can't do anything about it, until it's fixed.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

NPS

  • Newbie
  • *
  • Posts: 31
    • View Profile
Re: Linker warning, linker error :P
« Reply #12 on: January 18, 2013, 11:35:57 am »
Yeeeah, 2.0 is stable as hell. :P