Compiling Engine on Windows

Discussion of chess software programming and technical issues.

Moderator: Ras

oriyonay
Posts: 32
Joined: Tue Jun 01, 2021 5:46 am
Full name: ori yonay

Compiling Engine on Windows

Post by oriyonay »

Hi friends - it's been a while :) I've been working on my engine and it seems like it's ~2500 elo!!
Anyway, I've been trying to compile it for Windows, which has been an absolute headache since I've been developing it on Mac. Can anyone please give me some pointers on how to do it? I've been getting linking errors left and right, but it works perfectly fine on Mac.

As a sanity check, I've been able to run my exact code on repl.it (github here).

I'd appreciate any help :)
oriyonay
Posts: 32
Joined: Tue Jun 01, 2021 5:46 am
Full name: ori yonay

Re: Compiling Engine on Windows

Post by oriyonay »

I was able to compile an EXE on my friend's PC just now, by removing the #ifdef in utils.h, but while the code compiles and links it gives a floating-point exception?? Even when I remove all of the code except for 'return 0'??

I wish I could donate all the hair I've been pulling out today haha
User avatar
Bo Persson
Posts: 257
Joined: Sat Mar 11, 2006 8:31 am
Location: Malmö, Sweden
Full name: Bo Persson

Re: Compiling Engine on Windows

Post by Bo Persson »

The ifdef is a bit odd. First of all, the predefined macro is _WIN32, not WIN32.

And second, I would avoid including the HUGE Windows.h in any header file. It is quite enough to add it to the cpp-file.
abulmo2
Posts: 467
Joined: Fri Dec 16, 2016 11:04 am
Location: France
Full name: Richard Delorme

Re: Compiling Engine on Windows

Post by abulmo2 »

Bo Persson wrote: Thu Jan 13, 2022 10:59 am The ifdef is a bit odd. First of all, the predefined macro is _WIN32, not WIN32.

And second, I would avoid including the HUGE Windows.h in any header file. It is quite enough to add it to the cpp-file.
I guess it is possible to avoid the windows/unix headers entirely everywhere. As I understand, it is used to access the GetTickCount function, but since C++11, C++ provides high resolution monotonic timers that can be used instead of getTickCount.
Richard Delorme
oriyonay
Posts: 32
Joined: Tue Jun 01, 2021 5:46 am
Full name: ori yonay

Re: Compiling Engine on Windows

Post by oriyonay »

Thank you to both of you for your valuable feedback - I just made the changes you suggested. The engine now compiles on my friend's Windows machine (after changing std=c++11 to std=gnu++0x in the makefile), but gives a floating-point exception, even when I remove all #includes and all code from the main function. Any ideas why that would happen? It has to be some compiler error the way I see it. It's driving me nuts lol
User avatar
mvanthoor
Posts: 1784
Joined: Wed Jul 03, 2019 4:42 pm
Location: Netherlands
Full name: Marcel Vanthoor

Re: Compiling Engine on Windows

Post by mvanthoor »

Also: if a program is not specifically written for MS VC++, I just compile it in MSYS2. I've never failed to build an engine MSYS2 if it builds in Linux. (Assuming I have/can find all the dependencies.) If an engine has a .vsproj or .sln file and no clear instructions on how to compile it on Linux (if this is even possible) then I don't even touch it. I don't have Visual Studio installed on my personal system (and I never will, as the main OS has been Linux for at least 8 months now).
Author of Rustic, an engine written in Rust.
Releases | Code | Docs | Progress | CCRL