Hello,
I'm having trouble linking with SFML on the command line when compiling with MSVC.
It works fine with GCC, but MSVC gives linking errors.
I made a test program just including system as it shouldn't depend on anything else.
"System does not depend on anything and can be used by itself." from
https://github.com/SFML/SFML/wiki/FAQ#grl-dependenciessf_main.cpp
#include <SFML/System.hpp>
int main()
{
sf::Clock clock;
}
command line:
cl -Z7 sf_main.cpp -DSFML_STATIC -Id:\SFML\vc11_64\SFML-2.1\include /link d:\SFML\vc11_64\SFML-2.1\lib\sfml-system-s-d.lib
here is the output:
Microsoft (R) C/C++ Optimizing Compiler Version 18.00.31101 for x64
Copyright (C) Microsoft Corporation. All rights reserved.
sf_main.cpp
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE\xlocale(337) : warning C4530: C++ exception handler
used, but unwind semantics are not enabled. Specify /EHsc
Microsoft (R) Incremental Linker Version 12.00.31101.0
Copyright (C) Microsoft Corporation. All rights reserved.
/out:sf_main.exe
/debug
-libpath:d:\SFML\vc11_64\SFML-2.1\lib
sfml-system-s-d.lib
sf_main.obj
MSVCRTD.lib(ti_inst.obj) : error LNK2005: "private: __cdecl type_info::type_info(class type_info const &)" (??0type
_info@@AEAA@AEBV0@@Z) already defined in LIBCMT.lib(typinfo.obj)
MSVCRTD.lib(ti_inst.obj) : error LNK2005: "private: class type_info & __cdecl type_info::operator=(class type_info
const &)" (??4type_info@@AEAAAEAV0@AEBV0@@Z) already defined in LIBCMT.lib(typinfo.obj)
LINK : warning LNK4098: defaultlib 'MSVCRTD' conflicts with use of other libs; use /NODEFAULTLIB:library
sf_main.exe : fatal error LNK1169: one or more multiply defined symbols found
Why does this happen?