Help for compile Stockfish with Microsoft Visual Studio 2013

Discussion of anything and everything relating to chess playing software and machines.

Moderator: Ras

Zerbinati
Posts: 125
Joined: Mon Aug 18, 2014 7:12 pm
Location: Trento (Italy)

Help for compile Stockfish with Microsoft Visual Studio 2013

Post by Zerbinati »

I own Visual Studio 2013 Ultimate..
I never used.. I would like to see differences with MinGW for my test
Could someone kindly explain step by step how to create a project and compile it?
Thanks in advance

Regards
Marco
User avatar
vittyvirus
Posts: 646
Joined: Wed Jun 18, 2014 2:30 pm
Full name: Fahad Syed

Re: Help for compile Stockfish with Microsoft Visual Studio

Post by vittyvirus »

Zerbinati wrote:I own Visual Studio 2013 Ultimate..
I never used.. I would like to see differences with MinGW for my test
Could someone kindly explain step by step how to create a project and compile it?
Thanks in advance

Regards
Marco
1. Open it.
2. Hit File -> New -> Project from existing code.
3. Choose "Visual C++" as your language
4. Now you've to choose the folder of SF source and name the project.
5. Choose Project Type -> Console application and click finish.
6. Hit F5 and bingo!
You might get some problems with compiling egtb code, though.
Zerbinati
Posts: 125
Joined: Mon Aug 18, 2014 7:12 pm
Location: Trento (Italy)

Re: Help for compile Stockfish with Microsoft Visual Studio

Post by Zerbinati »

vittyvirus wrote:
Zerbinati wrote:I own Visual Studio 2013 Ultimate..
I never used.. I would like to see differences with MinGW for my test
Could someone kindly explain step by step how to create a project and compile it?
Thanks in advance

Regards
Marco
1. Open it.
2. Hit File -> New -> Project from existing code.
3. Choose "Visual C++" as your language
4. Now you've to choose the folder of SF source and name the project.
5. Choose Project Type -> Console application and click finish.
6. Hit F5 and bingo!
You might get some problems with compiling egtb code, though.
Thx work well
But many errors in the compilation and does not produce executable ..
I think it will give up :?
User avatar
Eelco de Groot
Posts: 4723
Joined: Sun Mar 12, 2006 2:40 am
Full name:   Eelco de Groot

Re: Help for compile Stockfish with Microsoft Visual Studio

Post by Eelco de Groot »

Zerbinati wrote:
vittyvirus wrote:
Zerbinati wrote:I own Visual Studio 2013 Ultimate..
I never used.. I would like to see differences with MinGW for my test
Could someone kindly explain step by step how to create a project and compile it?
Thanks in advance

Regards
Marco
1. Open it.
2. Hit File -> New -> Project from existing code.
3. Choose "Visual C++" as your language
4. Now you've to choose the folder of SF source and name the project.
5. Choose Project Type -> Console application and click finish.
6. Hit F5 and bingo!
You might get some problems with compiling egtb code, though.
Thx work well
But many errors in the compilation and does not produce executable ..
I think it will give up :?
Maybe with trick?
m_ste...@yahoo.com
16-12-14

Andere ontvangers: m_ste...@yahoo.com, SNP_Ti...@hotmail.com
Bericht vertalen in het Nederlands

The trick as Joona pointed out is NOT to add tbcore.cpp to the project. It's essentially an include file with a .cpp extension. Hope that does it for u
was reported here, end of last year, "Errors compiling SF under MSVC":

https://groups.google.com/forum/?fromgr ... qoehC13kQJ
Debugging is twice as hard as writing the code in the first
place. Therefore, if you write the code as cleverly as possible, you
are, by definition, not smart enough to debug it.
-- Brian W. Kernighan
User avatar
Eelco de Groot
Posts: 4723
Joined: Sun Mar 12, 2006 2:40 am
Full name:   Eelco de Groot

Re: Help for compile Stockfish with Microsoft Visual Studio

Post by Eelco de Groot »

Also this, probably more relevant because the change to C++11 was not done yet, that was somewhere in february I believe? (you can search all Fishcooking for threads that mention "MSVC")
Marco Costalba
21 jan.

Andere ontvangers: m_ste...@yahoo.com, joona....@gmail.com, glin...@gmail.com, lucas....@gmail.com
Bericht vertalen in het Nederlands

You have to use MSVC 2013 update 4,as for the link I have posted.
- tekst uit het oorspronkelijke bericht verbergen -



On Tuesday, January 20, 2015, m_stembera via FishCooking <fishc...@googlegroups.com> wrote:
Just reporting the errors I currently get under MSVC 2013.

1> tbprobe.cpp
1>c:\projects\stockfishof3\src\syzygy\tbcore.cpp(67): error C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\string.h(112) : see declaration of 'strcpy'

1> material.cpp
1>c:\projects\stockfishof3\src\endgame.h(85): error C2975: '_Test' : invalid template argument for 'std::conditional', expected compile-time constant expression
1> C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xtr1common(77) : see declaration of '_Test'
1>..\src\material.cpp(147): error C2440: '=' : cannot convert from 'Endgame<KXK,ScaleFactor> *' to 'EndgameBase<Value> *'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>..\src\material.cpp(153): error C2440: '=' : cannot convert from 'Endgame<KXK,ScaleFactor> *' to 'EndgameBase<Value> *'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

1> endgame.cpp
1>..\src\endgame.cpp(110): error C2783: 'void Endgames::add(const std::string &)' : could not deduce template argument for 'T'
1> c:\projects\stockfishof3\src\endgame.h(106) : see declaration of 'Endgames::add'
1>c:\projects\stockfishof3\src\endgame.h(85): error C2975: '_Test' : invalid template argument for 'std::conditional', expected compile-time constant expression
1> C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xtr1common(77) : see declaration of '_Test'
1>..\src\endgame.cpp(167): error C2556: 'Value Endgame<KXK,ScaleFactor>::operator ()(const Position &) const' : overloaded function differs only by return type from 'ScaleFactor Endgame<KXK,ScaleFactor>::operator ()(const Position &) const'
1> c:\projects\stockfishof3\src\endgame.h(90) : see declaration of 'Endgame<KXK,ScaleFactor>::operator ()'
1>..\src\endgame.cpp(167): error C2371: 'Endgame<KXK,ScaleFactor>::operator ()' : redefinition; different basic types
1> c:\projects\stockfishof3\src\endgame.h(90) : see declaration of 'Endgame<KXK,ScaleFactor>::operator ()'
1>..\src\endgame.cpp(343): error C2556: 'Value Endgame<KNNK,ScaleFactor>::operator ()(const Position &) const' : overloaded function differs only by return type from 'ScaleFactor Endgame<KNNK,ScaleFactor>::operator ()(const Position &) const'
1> c:\projects\stockfishof3\src\endgame.h(90) : see declaration of 'Endgame<KNNK,ScaleFactor>::operator ()'
1>..\src\endgame.cpp(343): error C2371: 'Endgame<KNNK,ScaleFactor>::operator ()' : redefinition; different basic types
1> c:\projects\stockfishof3\src\endgame.h(90) : see declaration of 'Endgame<KNNK,ScaleFactor>::operator ()'
m_ste...@yahoo.com
22 jan.

Andere ontvangers: m_ste...@yahoo.com, joona....@gmail.com, glin...@gmail.com, lucas....@gmail.com
Bericht vertalen in het Nederlands

On Tuesday, January 20, 2015 at 9:38:04 PM UTC-8, Marco Costalba wrote:
> You have to use MSVC 2013 update 4,as for the link I have posted.
>
I can confirm that all errors I previously posted went away after installing service pack 4 except for this one..

1> tbprobe.cpp
1>c:\projects\stockfishof3\src\syzygy\tbcore.cpp(67): error C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\string.h(112) : see declaration of 'strcpy'

Thanks Marco
m_ste...@yahoo.com
22 jan.

Andere ontvangers: chi...@gmail.com, m_ste...@yahoo.com, joona....@gmail.com, glin...@gmail.com, lucas....@gmail.com
Bericht vertalen in het Nederlands

It did block compilation for me until I read this
https://stackoverflow.com/questions/204 ... r-on-c4996
and went into the project settings and manually changed SDL checks to No.
In thread "c++11 branch"

https://groups.google.com/forum/?fromgr ... ArJ2wK6ykJ
Last edited by Eelco de Groot on Mon Jun 29, 2015 10:39 pm, edited 1 time in total.
Debugging is twice as hard as writing the code in the first
place. Therefore, if you write the code as cleverly as possible, you
are, by definition, not smart enough to debug it.
-- Brian W. Kernighan
Joost Buijs
Posts: 1704
Joined: Thu Jul 16, 2009 10:47 am
Location: Almere, The Netherlands

Re: Help for compile Stockfish with Microsoft Visual Studio

Post by Joost Buijs »

I've made a 64 bit Visual Studio project for you which compiles without problems although I didn't test the executable for correctness.

You can download it here:

https://www.dropbox.com/s/vgaoagztkk9uv ... v.rar?dl=0
Joost Buijs
Posts: 1704
Joined: Thu Jul 16, 2009 10:47 am
Location: Almere, The Netherlands

Re: Help for compile Stockfish with Microsoft Visual Studio

Post by Joost Buijs »

Maybe you have to change the defines a little to suit your processor.

/D "USE_PEXT" /D "USE_POPCNT" /D "IS_64BIT" /D "USE_PREFETCH" /D "_CRT_SECURE_NO_WARNINGS"

Depending upon your processor you probably have to remove the USE_PEXT and the USE_POPCNT otherwise it will crash at startup.
Zerbinati
Posts: 125
Joined: Mon Aug 18, 2014 7:12 pm
Location: Trento (Italy)

Re: Help for compile Stockfish with Microsoft Visual Studio

Post by Zerbinati »

I upgraded (Update 4)
and I removed from the project tbcore.cpp
now everything works fine
thanks a lot to everyone.

Regards

Marco