News:

Do you need help?
Simutrans Wiki Manual can help you to play and extend Simutrans. In 9 languages.

Windows 10 and Visual Studio 2015

Started by jamespetts, July 28, 2015, 10:05:55 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Ters

In MSVC2015 at least, you can exclude a file from the build for particular configurations and platforms. Does anybody know if this is the right way of doing it? It's sort of similar to how CodeBlocks does it, except that it has the inverse property (and also doesn't hold platform distinct from configuration).

jamespetts

Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

DrSuperGood

QuoteAre you aware of any way (apart from #ifdef directives in the files themselves) to tell MSVS which files to try to build separately for each build configuration?
You can exclude specific files from particular builds by right clicking them and modifying their properties.

I am not sure if this is the "right" way to do it. Looking at how zlib did it, you could make separate projects (whatever they are called) which specify the build configuration and then in those separate projects you have standard configurations like "debug", "Release", "Release (64)" etc.

Currently I have the messy approach of various builds like SDL2, SDL2 Debug, POSIX etc in one project. From a configuration point of view having separate projects (maybe they are sub-projects?) for things like GDI, POSIX, SDL, SDL2 etc each linking to different libraries and C++ files and then each of those has separate standard configurations (debug and release for 32 and 64).

The configurations with different C++ source files is supported in community 2013 and 2015. I am unsure of 2012. I would recommend upgrading to Community 2015 since it is completely free and suitable for even small scale commercial operations. However depending on what else you use it for (eg work) that might not be applicable.

jamespetts

Thank you: that is very helpful. It does work in 2012. Would one then disable simsys_w for the command line server build?

Do you know whether your updated posix file is compatible with Experimental running on Linux? I know so little of the workings of the low level stuff that it will be very difficult for me to work out what the problem is if it is not (and a release is so far away that I may have forgotten this change by the time that I come to compile for Linux, making any problems very hard to track down).

Upgrading to the 2015 version may well be worthwhile if there are reasonable straightforward ways of fixing the issues, as you have outlined. I do not use MSVS for anything other than Simutrans: my work is entirely unconnected with programming (and I am entirely self taught, which is why I am hazy on the low level details in many cases).
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

DrSuperGood

QuoteThank you: that is very helpful. It does work in 2012. Would one then disable simsys_w for the command line server build?
You disable simsys_w and enable the posix one. I also think you need to change the graphic back end, I forget if that was for SDL2 or not.

QuoteDo you know whether your updated posix file is compatible with Experimental running on Linux?
Unless someone altered that file for experimental, or not all patches to it have been applied to experimental I see no reason for it to not work. The patches I made only alter the file behaviour when building targeting Windows, the file was not changed for Linux in any way.

QuoteUpgrading to the 2015 version may well be worthwhile if there are reasonable straightforward ways of fixing the issues, as you have outlined. I do not use MSVS for anything other than Simutrans: my work is entirely unconnected with programming (and I am entirely self taught, which is why I am hazy on the low level details in many cases).
I am slowly looking into constructing some form updated MSVC project file for standard. The problem is how to structure it in a nice, user friendly and maintainable way. Hopefully the same principles could be applied to experimental.

Ters

Quote from: DrSuperGood on August 23, 2015, 11:04:54 PM
You disable simsys_w and enable the posix one. I also think you need to change the graphic back end, I forget if that was for SDL2 or not.

simsys_* is the graphics back end. simgraph, which is the middle layer, shouldn't care for SDL2 or otherwise.

jamespetts

I should note that I am just in the process of upgrading to Visual Studio 2015 now so that I can undertake some profiling, and I note that Visual Studio 2015 compatible library files can be obtained from the Open TTD website here.

Edit: However, I cannot find compatible versions of bzip anywhere - can anyone assist with that? I currently get linker errors (unresolved external symbol __iob_func referenced in function _bzopen_or_bzdopen)
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

DrSuperGood

Quote
and I note that Visual Studio 2015 compatible library files can be obtained from the Open TTD website here.
Or you could just build them yourself, which is what I did. All the dependent libraries for standard come with MSVC projects which just need some minor modifications for compatibility/optimization.

Quote
However, I cannot find compatible versions of bzip anywhere - can anyone assist with that?
I have self-built versions which I use to statically link with standard.

jamespetts

#78
Were you able to build them from the source tarball on the official bzip website? I had trouble opening that.
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

DrSuperGood

QuoteWere you able to build them from the source tarball on the official bzip website? I had trouble opening that.
Yes I was. Start by extracting bzip2-1.0.6 folder using 7-zip. Since it is a tar.gz (nested compression) this means using 7-zip's file explorer to first open the gz file and then the tar file to reveal the required folder. Inside that folder open libbz2.dsp with MSVC2015 and one-way upgrade it to MSVC2015.

Since the project is very old one has to hack around at the build properties. For example change Configuration Type from .dll to .lib so that it can be statically linked (less messy, 1 fewer dll to distribute). Whole program optimization should be turned on to fast link time code generation (very important for optimization), multi-processor compilation and runtime library must be the same as Simutrans. After that build and it should be usable when placed on the library path. If you still get errors when trying to link it with Simutrans then maybe some of the settings are conflicting between the projects such as exception and calling conventions.

Ves

I think i remember using the version 3.1 of the openTTD files.
I use windows 10 and msvs2015

jamespetts

Excellent, that worked for me, thank you!
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

Rollmaterial

#82
I get this error when trying to compile bzlib:

Error D8016 '/ZI' and '/GL' command-line options are incompatible


Edit: I seem to have fixed that by compiling in release configuration. Now I'm having trouble with zlibstat from OpenTTD-useful-6.0.

Ves

After james updated the experimental enviroment to mvsv2015 I get this error when trying to compile simutrans experimental:

Severity Code Description Project File Line Suppression State
Error C2011 'timespec': 'struct' type redefinition Simutrans-Experimental C:\Users\Victor\Documents\GitHub\OpenTTD\shared\include\pthread.h 320


His reply was that I should recompile the bzlib.
I have no problem compiling the bzlib uing the instructions in this thread, resulting in the file libbz2.lib, and I am replacing the existing one in the open TTD-files. I also modified the preferences to match the ones in experimtal and all the values DrSupergood suggested are matching.
However, experimental will still not compile, just throwing the same error again. Do any of you know what I might have been doing wrong?
Needless to say maybe, but I am running windows 10 msvs 2015


QuoteNow I'm having trouble with zlibstat from OpenTTD-useful-6.0.
I dont know if all this has changed now, but try the 3.1 one. It was the latest one I could get to work before.

Rollmaterial

Turns out I just forgot to add some directories. Now I'm getting something else:
Severity Code Description Project File Line Suppression State
Error C1047 The object or library file '.\intermediates\release\simdepot.obj' was created with an older compiler than other objects; rebuild old objects and libraries

DrSuperGood

#85
Quote

Edit: I seem to have fixed that by compiling in release configuration. Now I'm having trouble with zlibstat from OpenTTD-useful-6.0.
Custom build all dependencies and make sure they are built with compatible settings. That error is the result of an incompatible library.

Quote
After james updated the experimental enviroment to mvsv2015 I get this error when trying to compile simutrans experimental:
The current MSVC version of pthread is incompatible with modern MSVC2015 due to it declaring its own timespec structure which already exists in MSVC2015 as it is part of standard C++. It was solved in Simutrans standard long ago but the patch must not have made its way to experimental.



#if defined _MSC_VER && _MSC_VER >= 1900
// MSVC 2015 with Windows 10 SDK has struct timespec
#define _TIMESPEC_DEFINED
#endif


Quote
Turns out I just forgot to add some directories. Now I'm getting something else:
You will manually need to build the dependencies as they were built with an incompatible or old version of MSVC.

jamespetts

Quote from: Rollmaterial on September 28, 2016, 05:16:20 PM
Turns out I just forgot to add some directories. Now I'm getting something else:
Severity Code Description Project File Line Suppression State
Error C1047 The object or library file '.\intermediates\release\simdepot.obj' was created with an older compiler than other objects; rebuild old objects and libraries


This looks as though you just need to clean the build before rebuilding, as the .obj files are temporary files created by the compiler whilst it is running.
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

DrSuperGood

Quote
This looks as though you just need to clean the build before rebuilding, as the .obj files are temporary files created by the compiler whilst it is running.
Yeh you are probably write. I just read the error and did not look at the path (ops). The same error is given if a library is used that was built with an old version of MSVC and was set for link time optimization.

Ves

Quote from: DrSuperGood on September 28, 2016, 06:30:56 PM
The current MSVC version of pthread is incompatible with modern MSVC2015 due to it declaring its own timespec structure which already exists in MSVC2015 as it is part of standard C++. It was solved in Simutrans standard long ago but the patch must not have made its way to experimental.

It appears as the experimental version was up to date, just with another set of comments, rearranging the lines. But that still unfortunately does not resolve the error.

DrSuperGood

Quote
It appears as the experimental version was up to date, just with another set of comments, rearranging the lines. But that still unfortunately does not resolve the error.
I cannot even find simthread.h in the experimental GitHub. Please link?

prissi

I am not sure but at a certain point this discussion went far away from MS 2015 issues. Maybe open a specific experimental thread that might help to find the pthread discussion again if needed?

jamespetts

To answer Dr. Supergood's question, pthread.h is not on the Github repository as it is found in ~\Simutrans\OpenTTD\shared\include (i.e., it is an included file rather than one that is treated as part of the core code).

Is this distinct from Standard? Ves - is this the same arrangement as you have?
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

Ters

Quote from: jamespetts on October 02, 2016, 11:49:05 AM
To answer Dr. Supergood's question, pthread.h is not on the Github repository as it is found in ~\Simutrans\OpenTTD\shared\include (i.e., it is an included file rather than one that is treated as part of the core code).

DrSuperGood didn't ask for pthread.h, which as far as I know is part of a (system) library. simthread.h on the other hand, is part of Simutrans and Simutrans specific.

DrSuperGood

The fix for standard was to simthread.h (not pthread.h). All Simutrans thread functionality comes from that header, as opposed to directly importing pthread.h. Experimental does not appear to have a simthread.h file, which would be why there is no fix. Until the developers of pthread.h update their header file to be compatible with never versions of MSVC the only solution is to explicitly state, via definition, that the timespec struct already exists and the header is to not create it before one can import the header file. As simthread.h does this for standard that is where the fix was applied but apparently experimental does not have a simthread.h.

Ves

Quote from: DrSuperGood on October 02, 2016, 01:23:32 AM
I cannot even find simthread.h in the experimental GitHub. Please link?
Simthread.h is located here: https://github.com/jamespetts/simutrans-experimental/blob/devel-new-2/utils/simthread.h

QuoteI am not sure but at a certain point this discussion went far away from MS 2015 issues. Maybe open a specific experimental thread that might help to find the pthread discussion again if needed?
I am sorry if this is considered the wrong thread, I thought it is a windows 10/msvs2015 issue?

QuoteTo answer Dr. Supergood's question, pthread.h is not on the Github repository as it is found in ~\Simutrans\OpenTTD\shared\include (i.e., it is an included file rather than one that is treated as part of the core code).

Is this distinct from Standard? Ves - is this the same arrangement as you have?
Yes I have that file there.

Ters

Quote from: Ves on October 02, 2016, 08:06:01 PM
I am sorry if this is considered the wrong thread, I thought it is a windows 10/msvs2015 issue?

I think the problem is that this thread was partially about experiences with Windows 10 mixed together with a MSVS2015 question. Now its just about MSVS2015, despite this being on a non-developer board. Anyone that might have come with Windows 10 feedback will likely be frightened by all the technical talk here. I suggest moving this discussion to one of the development boards. Then it can be a MSVS2015 discussion. What has been discussed lately has nothing to do with Windows 10.

Ves

QuoteI think the problem is that this thread was partially about experiences with Windows 10 mixed together with a MSVS2015 question. Now its just about MSVS2015, despite this being on a non-developer board. Anyone that might have come with Windows 10 feedback will likely be frightened by all the technical talk here. I suggest moving this discussion to one of the development boards. Then it can be a MSVS2015 discussion. What has been discussed lately has nothing to do with Windows 10.

Ok, made a new thread here: http://forum.simutrans.com/index.php?topic=15783.0

jamespetts

Apologies: I misread the original post. simthread.h should be there in the ~/utils directory, which I believe is the default location: I certainly have not moved it.
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.