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

Author Topic: error lnk2019 unresolved external symbol public __thiscall  (Read 6706 times)

0 Members and 1 Guest are viewing this topic.

theo Richard

  • Newbie
  • *
  • Posts: 8
    • View Profile
Hi ! Im having great troubles compiling a simple test project using with SFML. I have seen many errors similar to the ones Im getting on the internet but everything i tried failed.

I am static linking sfml.

In the project's properties, I added the path to the SFML headers and the SFML libraries.

I have define the SFML_STATIC macro in the preprocessor options of my project.

I added modules and their dependencies like so :

sfml-audio-s-d.lib sfml-graphics-s-d.lib sfml-window-s-d.lib sfml-system-s-d.lib opengl32.lib freetype.lib jpeg.lib winmm.lib flac.lib vorbis.lib vorbisenc.lib vorbisfile.lib ogg.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib

I even added the dll files in my executable folder even though its not necessary when static building.

here is my code :

#include "stdafx.h"
#include <SFML/Audio.hpp>
#include <iostream>
#include <stdlib.h>

int _tmain(int argc, _TCHAR* argv[])
{
    std::cout << "helloo" << std::endl;
    sf::SoundBuffer buffer;
    if (!buffer.loadFromFile("A4.wav"))
        std::cout << "cant open file" << std::endl;
    sf::Sound sound;
    sound.setBuffer(buffer);
    sound.play();
    std::string test;
    std::cin >> test;
    return 42;
}
And now here is the errors I get :

EDIT

1>------ start of the global generation : Projet : AudioTest, Configuration : Debug Win32 ------
1>  Compilateur d'optimisation Microsoft (R) 32 bits C/C++ version 16.00.30319.01 for 80x86
1>  Copyright (C) Microsoft Corporation. Tous droits réservés.
1> 
1>  cl /c /I"C:\Users\theo-richard\Documents\Visual Studio 2010\SFML-2.0\include" /ZI /nologo- /W3 /WX- /Od /Oy- /D SFML_STATIC /D WIN32 /D _DEBUG /D _CONSOLE /D _UNICODE /D UNICODE /Gm /EHsc /RTC1 /MD /GS /fp:precise /Zc:wchar_t /Zc:forScope /Yc"StdAfx.h" /Fp"Debug\AudioTest.pch" /Fo"Debug\\" /Fd"Debug\vc100.pdb" /Gd /TP /analyze- /errorReport:prompt stdafx.cpp
1>cl :command line warning D9035: l'option 'nologo-' est déconseillée et sera supprimée dans une version ultérieure
1> 
1>  stdafx.cpp
1>  Compilateur d'optimisation Microsoft (R) 32 bits C/C++ version 16.00.30319.01 pour 80x86
1>  Copyright (C) Microsoft Corporation. Tous droits réservés.
1> 
1>  cl /c /I"C:\Users\theo-richard\Documents\Visual Studio 2010\SFML-2.0\include" /ZI /nologo- /W3 /WX- /Od /Oy- /D SFML_STATIC /D SFML_STATIC /D WIN32 /D _DEBUG /D _CONSOLE /D _UNICODE /D UNICODE /Gm /EHsc /RTC1 /MD /GS /fp:precise /Zc:wchar_t /Zc:forScope /Yu"StdAfx.h" /Fp"Debug\AudioTest.pch" /Fo"Debug\\" /Fd"Debug\vc100.pdb" /Gd /TP /analyze- /errorReport:prompt AudioTest.cpp
1>cl : Ligne de commande warning D9035: l'option 'nologo-' est déconseillée et sera supprimée dans une version ultérieure
1> 
1>  AudioTest.cpp
1>  Microsoft (R) Incremental Linker Version 10.00.30319.01
1>  Copyright (C) Microsoft Corporation.  All rights reserved.
1> 
1>  "/OUT:C:\Users\theo-richard\Documents\Visual Studio 2010\Projects\AudioTest\Debug\AudioTest.exe" /INCREMENTAL:NO "/LIBPATH:C:\Users\theo-richard\Documents\Visual Studio 2010\SFML-2.0\lib" "sfml-audio-s-d.lib" "sfml-graphics-s-d.lib" "sfml-window-s-d.lib" "sfml-system-s-d.lib" opengl32.lib freetype.lib jpeg.lib winmm.lib flac.lib vorbis.lib vorbisenc.lib vorbisfile.lib ogg.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /MANIFEST "/ManifestFile:Debug\AudioTest.exe.intermediate.manifest" "/MANIFESTUAC:level='asInvoker' uiAccess='false'" /DEBUG "/PDB:C:\Users\theo-richard\Documents\Visual Studio 2010\Projects\AudioTest\Debug\AudioTest.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT "/IMPLIB:C:\Users\theo-richard\Documents\Visual Studio 2010\Projects\AudioTest\Debug\AudioTest.lib" /MACHINE:X86 Debug\AudioTest.obj
1>  Debug\stdafx.obj

1>AudioTest.obj : error LNK2019: unresolved external symbol "public: __thiscall sf::SoundBuffer::~SoundBuffer(void)" (??1SoundBuffer@sf@@QAE@XZ)  referenced in function _wmain

1>AudioTest.obj : error LNK2019: unresolved external symbol "public: virtual __thiscall sf::Sound::~Sound(void)" (??1Sound@sf@@UAE@XZ) referenced in function _wmain

1>AudioTest.obj : error LNK2019: unresolved external symbol "public: void __thiscall sf::Sound::play(void)" (?play@Sound@sf@@QAEXXZ) referenced in function _wmain

1>AudioTest.obj : error LNK2019: unresolved external symbol "public: void __thiscall sf::Sound::setBuffer(class sf::SoundBuffer const &)" (?setBuffer@Sound@sf@@QAEXABVSoundBuffer@2@@Z) referenced in function _wmain

1>AudioTest.obj : error LNK2019: unresolved external symbol "public: __thiscall sf::Sound::Sound(void)" (??0Sound@sf@@QAE@XZ) referenced in function _wmain

1>AudioTest.obj : error LNK2019: unresolved external symbol "public: bool __thiscall sf::SoundBuffer::loadFromFile(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?loadFromFile@SoundBuffer@sf@@QAE_NABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function _wmain

1>AudioTest.obj : error LNK2019: unresolved external symbol "public: __thiscall sf::SoundBuffer::SoundBuffer(void)" (??0SoundBuffer@sf@@QAE@XZ) referenced in function _wmain
additionnal infos :

Im using visual studio 2010 express.

I downloaded "SFML 2.3 Visual C++ 10 (2010) - 64-bit".

any help appreciated.
« Last Edit: June 13, 2015, 08:00:28 pm by theo Richard »

JackPS9

  • Newbie
  • *
  • Posts: 28
    • View Profile
Re: error lnk2019 unresolved external symbol public __thiscall
« Reply #1 on: June 13, 2015, 07:18:07 pm »
Odd little question first, why _tmain?
Only asking cause its a MS extension so not all compilers will like it which if you ever wanted forces you to windows only.

2)  use std::cin instead of sleep
3)  Have you tried cleaning the project and solution and trying again?
« Last Edit: June 13, 2015, 07:36:42 pm by JackPS9 »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: error lnk2019 unresolved external symbol public __thiscall
« Reply #2 on: June 13, 2015, 07:39:55 pm »
Are you actually using a 64-bit compiler? If not, you shouldn't get the 64-bit SFML binaries.

If that didn't help, you should provide the verbose build command when you do a complete rebuild.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

theo Richard

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: error lnk2019 unresolved external symbol public __thiscall
« Reply #3 on: June 13, 2015, 07:40:24 pm »
Hi ! I used _tmain because that was the function already in the .cpp file created by visual studio.
As Im fairly new to cpp and visual studio i left it like that. 
Thanks for the input on std::cin, I updated my code.  :)

theo Richard

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: error lnk2019 unresolved external symbol public __thiscall
« Reply #4 on: June 13, 2015, 07:52:30 pm »
hi eXpl0it3r ! yes Im using a 64-bit compiler (im pretty sure, I will try to be 100% sure)
as for the complete log i didnt bother to put it all since my visual studio prints logs in french, I put what I thought was usefull.
Im going to update my post with the complete logs translated as much as I can.

EDIT
it seems like im actually using a 32-bit compiler, Im going to get the 32-bit SFML binaries.
« Last Edit: June 13, 2015, 07:59:24 pm by theo Richard »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: error lnk2019 unresolved external symbol public __thiscall
« Reply #5 on: June 13, 2015, 07:57:28 pm »
We don't need to full log, what we need is the full build command and the first two or three compiler errors.

Also I highly recommend you start with an empty project instead of a Win32 one, because that adds the odd _tmain and stdafx which only make sense if you know what you're doing.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

theo Richard

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: error lnk2019 unresolved external symbol public __thiscall
« Reply #6 on: June 13, 2015, 08:05:36 pm »
Thanks a lot, Im am going to provide you the full build command and start in a new project.
I'll let you know how this went tomorrow.

Thanks again.

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: error lnk2019 unresolved external symbol public __thiscall
« Reply #7 on: June 13, 2015, 08:26:48 pm »
use std::cin instead of sleep
I'd say that you could use sf::Sleep instead of sleep, but looping until the sound finishes makes more sense.

I downloaded "SFML 2.3 Visual C++ 10 (2010) - 64-bit".
Is it possible that you're trying to compile it as a 32-bit version using those 64-bit libraries?
Also, are you compiling in debug or release mode?
Bah - eXpl0it3r beat me to it...

Odd little question first, why _tmain?
I have to agree with this.
You can just use main() for console application (including ones that open windows) or WinMain() for direct windows applications. Even better, link sfml-main.lib and you can keep main().
Remember to - as eXpl0it3r just mentioned - to start with an empty project.
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

theo Richard

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: error lnk2019 unresolved external symbol public __thiscall
« Reply #8 on: June 14, 2015, 05:44:44 pm »
Thanks a LOT guys ! I was completly lost and desperate but I did all your suggestions and now it works !!

Much Love, see you soon.