• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

C++ Compiling Error (SFML)

Status
Not open for further replies.
Level 16
Joined
Mar 27, 2011
Messages
1,349
I'm making my second C++ program with SFML, a game/multimedia application library. Upon compiling my code, I get an error:

error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup


I have double checked and triple checked the Linker Input settings to make sure the libraries are included. No idea what this error means! Here's my code:


C++:
// This application will load a simple sprite.

#include <SFML/Graphics.hpp>

int main()
{

	// Create the program's main window.
	sf::RenderWindow window(sf::VideoMode(800, 600), "Stick Man Wave");

	while (window.isOpen())
	{
		sf::Event event;
		// Checks for any events that occured since last iteration of main loop
		while (window.pollEvent(event))
		{
			// Detects a window closed event.
			if (event.type == sf::Event::Closed)
				// Closes the window
				window.close();
		}

		// Clears the window with a black color.
		window.clear(sf::Color::Black);

		// Load the texure
		sf::Texture stick1Texture;
		stick1Texture.loadFromFile("C:\sprite test\stick figure 1.dds");
		
		// Load the texture into a sprite
		sf::Sprite stick1Sprite;
		stick1Sprite.setTexture(stick1Texture);

		// Draw the Sprite
		window.draw(stick1Sprite);


		// Sends drawing to the display
		window.display();
	}

	return 0;
}
 
Level 16
Joined
Mar 27, 2011
Messages
1,349
Thanks, I've finally got it to work.

Change the SubSystem to Console (guide)

This did not work for me. It cleared the error, but gave another. I ended up creating a new windows console project. I didn't really want to have a command console in the background though. After I get some more practice with SFML I might try figuring this sort of stuff out.
 

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,190
According to Microsoft guidelines you must (should?) be polling your application events in a separate thread. If the queue is not polled within a short period it will detect the application as unresponsive so might close it or fade the window out.

The general recommendation is that a separate high-priority thread poll and run only fast task event handlers. Any events that need to result in long tasks should outsource the task execution to a different slave thread, usually done by messaging using some kind of buffer. If the messaging buffer overflows then one could consider the slave thread as being unresponsive or simply discard the messages (if they are not critical).
 
Level 23
Joined
Apr 16, 2012
Messages
4,041
a.) you dont know if sfml does or doesnt pull it from different thread, and this is how it works in SFML, you poll the events in main thread where your main window is(you cant even pull it from different thread since according to the author of SFML the opengl context will only be active for that window on one thread, so the other thread has nothing to poll), and that timer is like 5 seconds or so.
 
Status
Not open for further replies.
Top