Author Topic: Build on Windows without VS  (Read 19068 times)

Offline Bubuskac

  • Sergeant
  • **
  • Posts: 21
    • View Profile
Build on Windows without VS
« on: February 04, 2018, 01:41:16 am »
Hi Everyone!

I'm trying to build a version of my own, but first I try to build the source without any change. I managed to build all the dependencies (or download them), but they seems to be broken. I am able to start my build, but I cannot start a new game, because it crashes or freeze or simply exits depending the dlls I put in the path. I have several questions:
 - how can I figure out which dll to use, or which version of the dependencies are the good ones to build from?
 - SupSuper's nightly build does not require any dlls, how could I achieve that? The nightly is a bit smaller than my build.
 - I build with mingw32-make (MSYS), because that what I know is free. Is there a free version of Visual Studio? Should I use it?

Thank you!

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9094
    • View Profile
Re: Build on Windows without VS
« Reply #1 on: February 04, 2018, 01:51:54 am »
- how can I figure out which dll to use, or which version of the dependencies are the good ones to build from?

You can use SupSuper's pre-compiled dependencies for VS2010 and VS2013.
For VS2015 and VS2017, you can use my pre-compiled dependencies if you want: https://openxcom.org/forum/index.php/topic,3937.msg80377.html#msg80377

If you want to use something else, you will need to compile them yourself.

- SupSuper's nightly build does not require any dlls, how could I achieve that? The nightly is a bit smaller than my build.

You can achieve that by linking the libraries statically, not dynamically.

- I build with mingw32-make (MSYS), because that what I know is free. Is there a free version of Visual Studio? Should I use it?

Yes, both VS2015 Community Edition and VS2017 Community Edition are free... you can use them.

Offline Bubuskac

  • Sergeant
  • **
  • Posts: 21
    • View Profile
Re: Build on Windows without VS
« Reply #2 on: February 04, 2018, 02:26:33 am »
Ok, thanks, I'll try visual studio tomorrow.

Offline Bubuskac

  • Sergeant
  • **
  • Posts: 21
    • View Profile
Re: Build on Windows without VS
« Reply #3 on: February 04, 2018, 02:39:42 pm »
I download VS2017 and a tried the build. I set the include and lib path, and I have 4 unresolved external symbols.

With DLL linking there is only one.

Severity   Code   Description   Project   File   Line   Suppression State
Error   LNK2001   unresolved external symbol "public: static class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > YAML::detail::node_data::empty_scalar" (?empty_scalar@node_data@detail@YAML@@2V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@A)   OpenXcom   C:\Users\aron116\Downloads\OpenXcom-master\OpenXcom-master\src\AIModule.obj   1   

This is for both.

Severity   Code   Description   Project   File   Line   Suppression State
Error   LNK2001   unresolved external symbol __imp__freopen   OpenXcom   C:\Users\aron116\Downloads\OpenXcom-master\OpenXcom-master\src\SDLmain.lib(SDL_win32_main.obj)   1   
Severity   Code   Description   Project   File   Line   Suppression State
Error   LNK2001   unresolved external symbol __imp__remove   OpenXcom   C:\Users\aron116\Downloads\OpenXcom-master\OpenXcom-master\src\SDLmain.lib(SDL_win32_main.obj)   1   
Severity   Code   Description   Project   File   Line   Suppression State
Error   LNK2001   unresolved external symbol __imp__setbuf   OpenXcom   C:\Users\aron116\Downloads\OpenXcom-master\OpenXcom-master\src\SDLmain.lib(SDL_win32_main.obj)   1   

These are for static linking. Am I missing something? Is it hard to build these libs? Shall I give it a try?

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9094
    • View Profile
Re: Build on Windows without VS
« Reply #4 on: February 04, 2018, 04:14:40 pm »
With DLL linking there is only one.

Severity   Code   Description   Project   File   Line   Suppression State
Error   LNK2001   unresolved external symbol "public: static class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > YAML::detail::node_data::empty_scalar" (?empty_scalar@node_data@detail@YAML@@2V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@A)   OpenXcom   C:\Users\aron116\Downloads\OpenXcom-master\OpenXcom-master\src\AIModule.obj   1   

Did you put YAML_CPP_DLL in the pre-processor directives as mentioned here: https://openxcom.org/forum/index.php/topic,3937.msg80377.html#msg80377 ?

Offline Bubuskac

  • Sergeant
  • **
  • Posts: 21
    • View Profile
Re: Build on Windows without VS
« Reply #5 on: February 04, 2018, 05:16:12 pm »
No...

But the other three still a problem. I switch back to Multi threaded DLL /MD from /MT, so hopefully it will build now. Any other way to do static linking? Sorry for the noob questions, but I didn't touch c/c++ code since university, so I am a noob in this. :)

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9094
    • View Profile
Re: Build on Windows without VS
« Reply #6 on: February 04, 2018, 05:27:21 pm »
Sorry for the noob questions, but I didn't touch c/c++ code since university, so I am a noob in this. :)

Same here :)
I'll let someone more competent answer the question about static/dynamic linking...

Offline Bubuskac

  • Sergeant
  • **
  • Posts: 21
    • View Profile
Re: Build on Windows without VS
« Reply #7 on: February 04, 2018, 06:35:48 pm »
Thanks for your help! It works! Compiled, built and runs as expected.
So now I can focus on enhancing my idea. :D

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9094
    • View Profile
Re: Build on Windows without VS
« Reply #8 on: February 04, 2018, 06:39:14 pm »
Please do share your ideas with the community too... it's beneficial to everyone :)

Offline Bubuskac

  • Sergeant
  • **
  • Posts: 21
    • View Profile
Re: Build on Windows without VS
« Reply #9 on: February 08, 2018, 02:57:57 pm »
It's not a "new" idea, it's rather backporting one from the newest XCOM. :) Basically use fixed characters instead of random.

Offline BTAxis

  • Colonel
  • ****
  • Posts: 149
    • View Profile
Re: Build on Windows without VS
« Reply #10 on: August 19, 2018, 03:02:46 pm »
To stay on topic, I have in fact succeeded in building on Windows without VS. For this I used msys2/MinGW-w64.

I did have to edit some files to get it to work:

- src/Makefile.gcc-pch
On line 25, change
Code: [Select]
CXXFLAGS ?= -Wall -Wextra -Wno-unused-function -O2 -rdynamic -g -D_DEBUGto
Code: [Select]
CXXFLAGS ?= -Wall -Wextra -Wno-unused-function -O2 -g -D_DEBUGThe -rdynamic flag apparently doesn't exist in MinGW.

On line 30, change
Code: [Select]
LIBS = $(shell $(PKG-CONFIG) --libs sdl yaml-cpp) -lSDL_gfx -lSDL_mixer -lSDL_image -lGLto
Code: [Select]
LIBS = $(shell $(PKG-CONFIG) --libs sdl yaml-cpp) -lSDL_gfx -lSDL_mixer -lSDL_image -lopengl32 -lshlwapi
- src/Engine/Zoom.cpp
Find the following lines
Code: [Select]
#ifdef __GNUC__
#if (__i386__ || __x86_64__)
#include <cpuid.h>
#endif
#endif
and delete them. I built using the x86_64 toolchain, which causes a problem with this. Chalk it up to A Windows Thing.

To build, go into src/ and invoke
Code: [Select]
make -f Makefile.gcc-pch

Unfortunately, this process does not at this time seem to work for OpenXComExtended+. When linking it errors out with
Spoiler:
C:/Programs/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ../obj/linux/WarningMessage.o: in function `OpenXcom::WarningMessage::WarningMessage(int, int, int, int)':
d:\Games\OpenXCOM\OXCE+\src/Battlescape/WarningMessage.cpp:41: undefined reference to `OpenXcom::Text::setWordWrap(bool, bool)'
C:/Programs/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ../obj/linux/CannotReequipState.o: in function `OpenXcom::CannotReequipState::CannotReequipState(std::vector<OpenXcom::ReequipStat, std::allocator<OpenXcom::ReequipStat> >)':
d:\Games\OpenXCOM\OXCE+\src/Battlescape/CannotReequipState.cpp:73: undefined reference to `OpenXcom::Text::setWordWrap(bool, bool)'
C:/Programs/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ../obj/linux/InfoboxState.o: in function `OpenXcom::InfoboxState::InfoboxState(std::__cxx11::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > const&)':
d:\Games\OpenXCOM\OXCE+\src/Battlescape/InfoboxState.cpp:58: undefined reference to `OpenXcom::Text::setWordWrap(bool, bool)'
C:/Programs/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ../obj/linux/AliensCrashState.o: in function `OpenXcom::AliensCrashState::AliensCrashState()':
d:\Games\OpenXCOM\OXCE+\src/Battlescape/AliensCrashState.cpp:67: undefined reference to `OpenXcom::Text::setWordWrap(bool, bool)'
C:/Programs/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ../obj/linux/InfoboxOKState.o: in function `OpenXcom::InfoboxOKState::InfoboxOKState(std::__cxx11::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > const&)':
d:\Games\OpenXCOM\OXCE+\src/Battlescape/InfoboxOKState.cpp:70: undefined reference to `OpenXcom::Text::setWordWrap(bool, bool)'
C:/Programs/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ../obj/linux/BuildNewBaseState.o:d:\Games\OpenXCOM\OXCE+\src/Geoscape/BuildNewBaseState.cpp:136: more undefined references to `OpenXcom::Text::setWordWrap(bool, bool)' follow
collect2.exe: error: ld returned 1 exit status
make: *** [Makefile.gcc-pch:42: ../bin/openxcom] Error 1
It seems the function declaration of setWordWrap has changed to accept a third argument, which VC apparently accepts but g++ does not.

Edit: I tried adding in the old definition of that function from vanilla OXC, and that remedies the issue. I have successfully built OXCE+ this way as well.
« Last Edit: August 19, 2018, 06:52:44 pm by BTAxis »

Offline Yankes

  • Global Moderator
  • Commander
  • *****
  • Posts: 3350
    • View Profile
Re: Build on Windows without VS
« Reply #11 on: August 19, 2018, 05:31:09 pm »
To stay on topic, I have in fact succeeded in building on Windows without VS. For this I used msys2/MinGW-w64.

I did have to edit some files to get it to work:

- src/Makefile.gcc-pch
On line 25, change
Code: [Select]
CXXFLAGS ?= -Wall -Wextra -Wno-unused-function -O2 -rdynamic -g -D_DEBUGto
Code: [Select]
CXXFLAGS ?= -Wall -Wextra -Wno-unused-function -O2 -g -D_DEBUGThe -rdynamic flag apparently doesn't exist in MinGW.

On line 30, change
Code: [Select]
LIBS = $(shell $(PKG-CONFIG) --libs sdl yaml-cpp) -lSDL_gfx -lSDL_mixer -lSDL_image -lGLto
Code: [Select]
LIBS = $(shell $(PKG-CONFIG) --libs sdl yaml-cpp) -lSDL_gfx -lSDL_mixer -lSDL_image -lopengl32 -lshlwapi
- src/Engine/Zoom.cpp
Find the following lines
Code: [Select]
#ifdef __GNUC__
#if (__i386__ || __x86_64__)
#include <cpuid.h>
#endif
#endif
and delete them. I built using the x86_64 toolchain, which causes a problem with this. Chalk it up to A Windows Thing.

To build, go into src/ and invoke
Code: [Select]
make -f Makefile.gcc-pch

Unfortunately, this process does not at this time seem to work for OpenXComExtended+. When linking it errors out with
Spoiler:
C:/Programs/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ../obj/linux/WarningMessage.o: in function `OpenXcom::WarningMessage::WarningMessage(int, int, int, int)':
d:\Games\OpenXCOM\OXCE+\src/Battlescape/WarningMessage.cpp:41: undefined reference to `OpenXcom::Text::setWordWrap(bool, bool)'
C:/Programs/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ../obj/linux/CannotReequipState.o: in function `OpenXcom::CannotReequipState::CannotReequipState(std::vector<OpenXcom::ReequipStat, std::allocator<OpenXcom::ReequipStat> >)':
d:\Games\OpenXCOM\OXCE+\src/Battlescape/CannotReequipState.cpp:73: undefined reference to `OpenXcom::Text::setWordWrap(bool, bool)'
C:/Programs/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ../obj/linux/InfoboxState.o: in function `OpenXcom::InfoboxState::InfoboxState(std::__cxx11::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > const&)':
d:\Games\OpenXCOM\OXCE+\src/Battlescape/InfoboxState.cpp:58: undefined reference to `OpenXcom::Text::setWordWrap(bool, bool)'
C:/Programs/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ../obj/linux/AliensCrashState.o: in function `OpenXcom::AliensCrashState::AliensCrashState()':
d:\Games\OpenXCOM\OXCE+\src/Battlescape/AliensCrashState.cpp:67: undefined reference to `OpenXcom::Text::setWordWrap(bool, bool)'
C:/Programs/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ../obj/linux/InfoboxOKState.o: in function `OpenXcom::InfoboxOKState::InfoboxOKState(std::__cxx11::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > const&)':
d:\Games\OpenXCOM\OXCE+\src/Battlescape/InfoboxOKState.cpp:70: undefined reference to `OpenXcom::Text::setWordWrap(bool, bool)'
C:/Programs/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ../obj/linux/BuildNewBaseState.o:d:\Games\OpenXCOM\OXCE+\src/Geoscape/BuildNewBaseState.cpp:136: more undefined references to `OpenXcom::Text::setWordWrap(bool, bool)' follow
collect2.exe: error: ld returned 1 exit status
make: *** [Makefile.gcc-pch:42: ../bin/openxcom] Error 1
It seems the function declaration of setWordWrap has changed to accept a third argument, which VC apparently accepts but g++ does not.

Edit: I tried adding in the old definition of that function from vanilla OXC, and that remedies the issue. I have successfully built OXCE+ this way as well.
For OXCE and OXCE+ you probably should use `src/Makefile.mingw`or `Makefile.mingw-w64` and more importantly cleanup all build files before building different branch.

Offline BTAxis

  • Colonel
  • ****
  • Posts: 149
    • View Profile
Re: Build on Windows without VS
« Reply #12 on: August 19, 2018, 06:07:05 pm »
For OXCE and OXCE+ you probably should use `src/Makefile.mingw`or `Makefile.mingw-w64` and more importantly cleanup all build files before building different branch.

I've tried this, but unfortunately I end up with pages and pages of undefined reference errors that I don't know how to fix. It seems YAML related though.

Offline Yankes

  • Global Moderator
  • Commander
  • *****
  • Posts: 3350
    • View Profile
Re: Build on Windows without VS
« Reply #13 on: August 19, 2018, 06:20:19 pm »
I've tried this, but unfortunately I end up with pages and pages of undefined reference errors that I don't know how to fix. It seems YAML related though.
And did you do "and more importantly cleanup all build files before building different branch." before this?

Offline BTAxis

  • Colonel
  • ****
  • Posts: 149
    • View Profile
Re: Build on Windows without VS
« Reply #14 on: August 19, 2018, 06:34:58 pm »
Yes, of course. make -f Makefile.gcc-pch clean before switching to the other makefile.