Hello All,
I am trying to learning the in and out of compiling from the command line (I feel its a good thing to know). I want to get a simple SFML test case working but am running into a snag. Currently, I think I am linking to all the static libraries correctly but ending up with a Link 2019 error. I dumped all the necessary files in a directory named SFML at the same level as the sfml_test.cpp. I am using VS2014 32 bit and downloaded the 32 bit SFML tools. Below is the Test case, the batch file and output error. I went through the tutorials and can get it to compile in Visual Studio. I went through the forums but couldn't find an answer to the command line compile. I must be missing a dependency but I am not seeing it, Thanks!
CPP file: (mostly commented except for the first line call to render window)
#include <SFML/Graphics.hpp>
int main()
{
sf::RenderWindow window(sf::VideoMode(640, 480), "SFML Test");
//sf::CircleShape shape;
//shape.setRadius(40.f);
//shape.setPosition(100.f, 100.f);
//shape.setFillColor(sf::Color::Cyan);
//while (window.isOpen())
//{
// sf::Event event;
// while (window.pollEvent(event))
// {
// if (event.type == sf::Event::Closed)
// {
// window.close();
// }
// }
// window.clear();
// window.draw(shape);
// window.display();
//}
return 0;
}
Batch file for compiling:@echo off
set INC_SFML="SFML\include"
set LIB_SFML="SFML\lib"
call C:\"Program Files (x86)"\"Microsoft Visual Studio 14.0"\VC\vcvarsall.bat
cl /EHsc /I %INC_SFML% test_sfml.cpp
link /MACHINE:x86 /SUBSYSTEM:CONSOLE /LIBPATH:%LIB_SFML%^
sfml-system-s.lib^
sfml-window-s.lib^
sfml-graphics-s.lib^
opengl32.lib^
freetype.lib^
jpeg.lib^
winmm.lib^
gdi32.lib^
/OUT:test_sfml.exe test_sfml.obj
cmd/k
Output errors:Microsoft (R) C/C++ Optimizing Compiler Version 19.00.24210 for x86
Copyright (C) Microsoft Corporation. All rights reserved.
test_sfml.cpp
Microsoft (R) Incremental Linker Version 14.00.24210.0
Copyright (C) Microsoft Corporation. All rights reserved.
/out:test_sfml.exe
test_sfml.obj
test_sfml.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
test_sfml.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::String::~String(void)" (__imp_??1String@sf@@QAE@XZ) referenced in function _main
test_sfml.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
test_sfml.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
test_sfml.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall sf::RenderWindow::~RenderWindow(void)" (__imp_??1RenderWindow@sf@@UAE@XZ) referenced in function _main
test_sfml.exe : fatal error LNK1120: 5 unresolved externals
Microsoft (R) Incremental Linker Version 14.00.24210.0
Copyright (C) Microsoft Corporation. All rights reserved.
LINK : warning LNK4001: no object files specified; libraries used
LINK : fatal error LNK1159: no output file specified
'freetype.lib' is not recognized as an internal or external command,
operable program or batch file.
'jpeg.lib' is not recognized as an internal or
external command,
operable program or batch file.