aliens

Author Topic: Building openXCom in 64-bits with MinGW on Windows  (Read 27640 times)

Offline JDarthenay

  • Captain
  • ***
  • Posts: 55
    • View Profile
Re: Building openXCom in 64-bits with MinGW on Windows
« Reply #30 on: March 31, 2016, 11:13:48 am »
Please, people : DLLs work. Users don't care that there are 16 inter-dependant DLLs along with your executable, and any future maintainer will kiss you (posthumously if necessary) as you're saving them the trouble of tracking down and compiling 16 specific versions of those libraries.

Ok, no problem, I linked with SDL.dll, no worries!
By the way I am happy I did not uninstall my previous MinGW-64 executables because using GNU Make 3.82.90 instead of GNU Make 4.0 solved my problems.

Offline Yankes

  • Global Moderator
  • Commander
  • *****
  • Posts: 3350
    • View Profile
Re: Building openXCom in 64-bits with MinGW on Windows
« Reply #31 on: March 31, 2016, 07:44:22 pm »
Available sources doesn't mean there is someone doing builds or upgrades to newer libraries.
I have had to upgrade sources and/or rebuild toolchains many times, and please believe me, it's very hard work. There can easily be an incertainty of 4 years over which version of GCC you need to use (that's 28 stable versions), Internet links go stale, nothing is forward compatible when you need it, and libraries have depencies, which have dependencies, which have depencies, which...
Please, people : DLLs work. Users don't care that there are 16 inter-dependant DLLs along with your executable, and any future maintainer will kiss you (posthumously if necessary) as you're saving them the trouble of tracking down and compiling 16 specific versions of those libraries.
What is real difference between recompiling dll and exe? Every problem that can affect exe can affect dll too. New dll can be incompatible with old dll etc.
Sometimes recompiling one dll could be harder that recompiling whole exe because it have most dependencies.
If everything is compiled from sources then all libraries will need exactly the same toolchain and have uniform dependencies (if two have lib that have common dep then it will be in same version other wise it will fail to compile).

Right now my experience with compiling OXC as stand alone exe is that my only problem is that I need linux (to run mxe), rest of dependencies are fix by 2 commands. It work for me, nightles and for Meridian.

Offline yrizoud

  • Commander
  • *****
  • Posts: 1014
    • View Profile
Re: Building openXCom in 64-bits with MinGW on Windows
« Reply #32 on: March 31, 2016, 10:12:46 pm »
DLL and exe are similar issue, but at least, once the DLL and library are available, they have a chance to be forward compatible for many years.
For example SDL_image (of SDL1) is a pain to compile, with dependencies :
 - libpng
      - which requires zlib
 - libjpeg
 - tiff
 - (more?)
Once you manage to determine correct versions which are all compatible with each other, the resulting library and DLL are precious : They are compatible with any program which use SDL_image, no matter if it was written (or compiled) in 2006 or 2016, because the API hasn't changed ever. This is one less problem to worry about.

Offline JDarthenay

  • Captain
  • ***
  • Posts: 55
    • View Profile
Re: Building openXCom in 64-bits with MinGW on Windows
« Reply #33 on: April 03, 2016, 08:00:55 am »
DLL and exe are similar issue, but at least, once the DLL and library are available, they have a chance to be forward compatible for many years.
For example SDL_image (of SDL1) is a pain to compile, with dependencies :
 - libpng
      - which requires zlib
 - libjpeg
 - tiff
 - (more?)

This is a good thing I did not have to compile 64-bit SDL_image unlike SDL...

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9101
    • View Profile
Re: Building openXCom in 64-bits with MinGW on Windows
« Reply #34 on: April 03, 2016, 10:59:51 am »
Please, people : DLLs work.

In theory, and for people who can compile them, yes.

In practice, I had to switch to single exe, because people just couldn't run the game. Since then, no issues.

Offline JDarthenay

  • Captain
  • ***
  • Posts: 55
    • View Profile
Re: Building openXCom in 64-bits with MinGW on Windows
« Reply #35 on: April 03, 2016, 08:46:17 pm »
@Yankes

Where did you find about the "-static-libstdc++" linker option?
I tried "gcc --help" and "ld --help" but I find nothing about this option...

Offline Yankes

  • Global Moderator
  • Commander
  • *****
  • Posts: 3350
    • View Profile
Re: Building openXCom in 64-bits with MinGW on Windows
« Reply #36 on: April 04, 2016, 02:05:46 am »
@Yankes

Where did you find about the "-static-libstdc++" linker option?
I tried "gcc --help" and "ld --help" but I find nothing about this option...
https://gcc.gnu.org/onlinedocs/gcc/Link-Options.html

Offline JDarthenay

  • Captain
  • ***
  • Posts: 55
    • View Profile
Re: Building openXCom in 64-bits with MinGW on Windows
« Reply #37 on: April 04, 2016, 08:49:45 am »
https://gcc.gnu.org/onlinedocs/gcc/Link-Options.html

I wonder why I can't see that with 'ld --help'...

They say it has no effect if '-shared' is used and you use them both... So no reason to keep it, right? Except maybe if you sometimes build without '-static' but want to keep '-static-libstdc++'.

Offline Yankes

  • Global Moderator
  • Commander
  • *****
  • Posts: 3350
    • View Profile
Re: Building openXCom in 64-bits with MinGW on Windows
« Reply #38 on: April 04, 2016, 07:58:21 pm »
I wonder why I can't see that with 'ld --help'...

They say it has no effect if '-shared' is used and you use them both... So no reason to keep it, right? Except maybe if you sometimes build without '-static' but want to keep '-static-libstdc++'.
probably yes

Offline JDarthenay

  • Captain
  • ***
  • Posts: 55
    • View Profile
Re: Building openXCom in 64-bits with MinGW on Windows
« Reply #39 on: April 28, 2016, 11:26:32 pm »
@Yankes I just discovered the "vpath" directive in makefiles. Why don't you use it to have only one pattern rule?

Offline Yankes

  • Global Moderator
  • Commander
  • *****
  • Posts: 3350
    • View Profile
Re: Building openXCom in 64-bits with MinGW on Windows
« Reply #40 on: April 28, 2016, 11:59:23 pm »
@Yankes I just discovered the "vpath" directive in makefiles. Why don't you use it to have only one pattern rule?
My knowledge of make is basic, I did not even write it, I only modify to work for me. Because building system is not my focus, if it work I can leave it as is even if it not perfect. Bigger problem for me is cmake and VS project because each time I add some file I need update them manually. I don't have this problems with makefiles.

Offline JDarthenay

  • Captain
  • ***
  • Posts: 55
    • View Profile
Re: Building openXCom in 64-bits with MinGW on Windows
« Reply #41 on: April 29, 2016, 02:22:00 am »
Indeed, you need to update your makefile only if someone add a directory in sources. But using vpath it seems it won't even be necessary, only need to update it if someone increases the max depth in src directory.

Offline JDarthenay

  • Captain
  • ***
  • Posts: 55
    • View Profile
Re: Building openXCom in 64-bits with MinGW on Windows
« Reply #42 on: April 29, 2016, 07:11:40 pm »
If you want to use it you need to add this line after your $(SRC) definition:

Code: [Select]
vpath %.cpp $(sort $(dir $(SRCS)))
You can then remove all your compiling commands but the first one:
Code: [Select]
$(OBJDIR)%.o:: %.cpp
$(CXX) $(CXXFLAGS) -c -o $@ $<
You will end with two rules instead of 13 for openXCom core.

And to avoid polluting yaml-cpp building rules you add after openXCom rule:
Code: [Select]
vpath %.cpp

Offline JDarthenay

  • Captain
  • ***
  • Posts: 55
    • View Profile
Re: Building openXCom in 64-bits with MinGW on Windows
« Reply #43 on: May 01, 2016, 08:06:59 pm »
My knowledge of make is basic, I did not even write it, I only modify to work for me. Because building system is not my focus, if it work I can leave it as is even if it not perfect. Bigger problem for me is cmake and VS project because each time I add some file I need update them manually. I don't have this problems with makefiles.

Ahhh! I feel stupid, I completely forgot you told me that! My Push Request failed automatic build check because I added a file and linking failed! What do I have to do to fix it?

Offline Yankes

  • Global Moderator
  • Commander
  • *****
  • Posts: 3350
    • View Profile
Re: Building openXCom in 64-bits with MinGW on Windows
« Reply #44 on: May 01, 2016, 09:02:46 pm »
Looking on https://travis-ci.org/SupSuper/OpenXcom/jobs/127037699 I see that build is probably generated from CMakeLists.txt
To fix it you need add your file there too.