LNK2019 while linking OpenGL program

I am following an OpenGL tutorial on https://open.gl/ . I am already stuck on creating context. I am using SFML 2.1 to create my context.
My code is currently:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <GL\glew.h>
#include <iostream>
#include <SFML\Window.hpp>

#pragma comment(lib,"glew32s.lib")
#pragma comment(lib,"sfml-graphics-d.lib")
#pragma comment(lib,"sfml-window-d.lib")
#pragma comment(lib,"sfml-system-d.lib")
#pragma comment(lib,"sfml-main-d.lib")

int main()
{
	sf::ContextSettings settings;
	settings.majorVersion = 3;
	settings.minorVersion = 2;
	settings.depthBits = 24;
	settings.stencilBits = 8;
	settings.antialiasingLevel = 2;

	sf::Window window(sf::VideoMode(800, 600), "OpenGL program", sf::Style::Default, settings);

	bool running = true;
	while (running)
	{
		sf::Event evt;
		while (window.pollEvent(evt))
		{
			switch (evt.type)
			{
			case sf::Event::Closed:
				running = false;
				break;
			case sf::Event::KeyPressed:
				if (evt.key.code == sf::Keyboard::Escape)
					running = false;
				break;
			}
		}
	}

	return 0;
}


This compiles fine, but I am getting 7 linker errors:


1>------ Build started: Project: opengl program, Configuration: Debug Win32 ------
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::String::String(char const *,class std::locale const &)" (__imp_??0String@sf@@QAE@PBDABVlocale@std@@@Z) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::String::~String(void)" (__imp_??1String@sf@@QAE@XZ) referenced in function _main
1>main.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>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::Window::Window(class sf::VideoMode,class sf::String const &,unsigned int,struct sf::ContextSettings const &)" (__imp_??0Window@sf@@QAE@VVideoMode@1@ABVString@1@IABUContextSettings@1@@Z) referenced in function _main
1>main.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>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: bool __thiscall sf::Window::pollEvent(class sf::Event &)" (__imp_?pollEvent@Window@sf@@QAE_NAAVEvent@2@@Z) referenced in function _main
1>d:\users\xxx\documents\visual studio 2012\Projects\opengl program\Debug\opengl program.exe : fatal error LNK1120: 6 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


I copied SFML 2.1\include folder contents to C:\Program Files (x86)\VC\include and SFML 2.1\lib contents to C:\Program Files (x86)\VC\lib.

#pragma s are here because I don't like to try finding an x-th option in an n-th tab in a 3rd window and setting it to proper settings.

I copied files from SFML 2.1\bin to D:\Windows\SysWOW64 and I think that's where I went wrong. (I was getting the error before trying to do this, and yes, my OS is on D: partition, my computer is a mess :( )

I am using 64-bit Windows 7 with Visual studio 2012 Express for desktop and SFML 2.1.

What went wrong?

Thanks in advance.

P.S. If someone can tell me how to properly move link libraries' DLLs to system folders?
I copied files from SFML 2.1\bin to D:\Windows\SysWOW64...

But which version of SFML did you download? Also, which platform are you compiling for? Which version of MSVS 2012 do you have installed? Both the IDE and the version of SFML you are using have 32 and 64-bit support. Right now the directories you have indicated tell me that you are trying to compile a 32-bit binary, and that would be fine as long as that is the architecture that your project is setup for. But if you are building your project for a 64-bit platform then WoW will never redirect the paths and so your project will never find those files. Have you tried enclosing the full UNC path in the double quotes of your pragma statements? This would eliminate any possible ambiguity on where to find them.

I also find this path to be suspicious:
C:\Program Files (x86)\VC\include
shouldn't it be:
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC
for the 32-bit version or
C:\Program Files\Microsoft Visual Studio 12.0\VC
for the 64-bit one? Otherwise you would never be able to install multiple versions of the compiler.
Oh, I am sorry, I forgot to note a few things.

1. I downloaded SFML 2.1 for Visual C++ 2012 (11.0) 64 bit. I am compiling for my needs so I don't need to "target a greater audience".

2. The path C:\Program files (x86 or not I haven't checked that)\VC\... is actually correct because I messed up my installation (about a couple of years ago) and my installation (Common7, VC, VB etc.) is scattered around the program files folder.

3. I don't think that it's necessary to put the absolute path in the pragma because the libs and includes are already in the default include path of the VC compiler, but I am gonna try that also.

4. About WoW redirection and stuff, I don't understand you because I am more familiar with Unix. I don't have a clue what are you talking here. :-(((

Thanks for helping.
1. If you have the 64-bit versions then you want to put those DLL files under 'C:\Windows', 'C:\Windows\SysWoW64' is used for 32-bit apps.

2. I'll take your word for it.

3. You are correct, it is not necessary. It is diagnostic.

4. Basically 32-bit applications are redirected to different folders and registry locations. This is so that there is no mix-up between the 32-bit and 64-bit versions of any drivers or libraries they might depend on. This redirection is hidden from them by WoW.
I am sorry for posting this on an old topic, but now I am trying to make a game just in SFML.
Same system, arch, config (debug) and SFML/VS version.

I wrote this code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <iostream>
#include <SFML\Graphics.hpp>
#include <SFML\Window.hpp>
#include <cmath>
#include <fstream>

int main(int argc,char** argv)
{
	sf::ContextSettings settings;
	settings.antialiasingLevel=4;

	sf::RenderWindow window(sf::VideoMode(800,600,32),"Smiley invasion",sf::Style::Default,settings);

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

		window.clear();

		window.display();
	}

	return 0;
}


Now I am getting also 12 unresolved externals:


1>------ Build started: Project: Smiley invasion, Configuration: Debug Win32 ------
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::String::String(char const *,class std::locale const &)" (__imp_??0String@sf@@QAE@PBDABVlocale@std@@@Z) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::String::~String(void)" (__imp_??1String@sf@@QAE@XZ) referenced in function _main
1>main.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>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall sf::Window::close(void)" (__imp_?close@Window@sf@@QAEXXZ) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: bool __thiscall sf::Window::isOpen(void)const " (__imp_?isOpen@Window@sf@@QBE_NXZ) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: bool __thiscall sf::Window::pollEvent(class sf::Event &)" (__imp_?pollEvent@Window@sf@@QAE_NAAVEvent@2@@Z) referenced in function _main
1>main.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>main.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>main.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>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::RenderWindow::RenderWindow(class sf::VideoMode,class sf::String const &,unsigned int,struct sf::ContextSettings const &)" (__imp_??0RenderWindow@sf@@QAE@VVideoMode@1@ABVString@1@IABUContextSettings@1@@Z) referenced in function _main
1>main.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>d:\users\xyz\documents\visual studio 2012\Projects\Smiley invasion\Debug\Smiley invasion.exe : fatal error LNK1120: 11 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========



At first, the problem appears to be that SFML libs in the VC default path and those in D:\SFML-2.1 are ambigous. I removed those from the default path and put the SFML DLLs in D:\Windows\System32. I added the lib paths to the project settings and tried to link using #pragma comment(lib,"sfml-...-d.lib") .

If this helps, I wasn't getting these errors when building on Ubuntu or 32 bit Windows (7, too).

Thanks in advance.
Topic archived. No new replies allowed.