Again with the annoying string conversion error.

IDE - Microsoft Visual C++ Express Edition (2008, I think.)
SDK/Library/whateverit'scalled - SFML

Putting/removing 'L' doesn't seem to do much good... & I couldn't find anything of use on the web; so I'd appreciate somebody telling me why the compiler is hating on me. :)

1
2
3
4
5
6
#include <SFML/System.hpp>
#include <SFML/Window.hpp>
#include <iostream>
void main(){
	sf::Window App(sf::VideoMode(800,600,32), L"T_T"); //cannot convert from 'const wchar_t [4]' to 'const std::string'
	std::cout << ">SDKLFJS:LDKFJ" << std::endl;}


1>c:\users\papa\desktop\c++\sfml_console_learning\sfml_console_learning\main.cpp(5) : error C2664: 'sf::Window::Window(sf::VideoMode,const std::string &,unsigned long,const sf::WindowSettings &)' : cannot convert parameter 2 from 'const wchar_t [4]' to 'const std::string &'
1>        Reason: cannot convert from 'const wchar_t [4]' to 'const std::string'
1>        No constructor could take the source type, or constructor overload resolution was ambiguous
1>Build log was saved at "file://c:\Users\papa\Desktop\C++\SFML_Console_Learning\SFML_Console_Learning\Debug\BuildLog.htm"
1>SFML_Console_Learning - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
if you look at this
sf::Window::Window(sf::VideoMode,const std::string &,unsigned long,const sf::WindowSettings &)
you see that the constructor wants more parameter than you supplied. Additionally
unsigned long,const sf::WindowSettings &


The 'L' is wrong. Just give it what it wants and it will be satisfied.
1
2
3
4
5
#include <SFML/System.hpp>
#include <SFML/Window.hpp>
#include <iostream>
void main(){
	sf::Window App(sf::VideoMode(800,600,32), L"T_T", sf::Style::Fullscreen); //cannot convert from 'const wchar_t [4]' to 'const std::string' 


By removing the L, it generates 4 errors instead of one. :/

1>main.obj : error LNK2019: unresolved external symbol "public: virtual __thiscall sf::Window::~Window(void)" (??1Window@sf@@UAE@XZ) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "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 &)" (??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>main.obj : error LNK2019: unresolved external symbol "public: __thiscall sf::VideoMode::VideoMode(unsigned int,unsigned int,unsigned int)" (??0VideoMode@sf@@QAE@III@Z) referenced in function _main
1>C:\Users\papa\Desktop\C++\SFML_Console_Learning\Debug\SFML_Console_Learning.exe : fatal error LNK1120: 3 unresolved externals'


But if I DO use the L...

1>c:\users\papa\desktop\c++\sfml_console_learning\sfml_console_learning\main.cpp(5) : error C2664: 'sf::Window::Window(sf::VideoMode,const std::string &,unsigned long,const sf::WindowSettings &)' : cannot convert parameter 2 from 'const wchar_t [4]' to 'const std::string &'
Last edited on
Yes, but you're thru. Now the compiler is satisfied and the linker whinges. You must provide the appropriate library
Topic archived. No new replies allowed.