Announcement

Collapse
No announcement yet.

Compiling TSRE

Collapse
X
Collapse
First Prev Next Last
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Compiling TSRE

    To help those who may need to update TSRE for future enhancements or support, these are the steps to install NetBeans, QT, and other components needed to be able to edit and compile TSRE.

    These steps are only needed by programmer making coding changes, and not intended for those who plan to run TSRE as a route, consist or activity editor.
    Last edited by eric; 01-17-2024, 08:18 PM.
    If you like what you see here at Trainsim.com, be it the discussions and knowledge in the forums, items saved in our library or the ongoing development of our TSRE Fork, I hope you'll consider a paid membership to help support keeping the site operating.... Thanks!

    #2

    There are some "instructions" buried within the forums here and on ET for how to make a new build, but while several have tried, nobody's been able to get it to compile or run in debug.


    Hi Goku, I'm trying to generate a build for TSRE5. I tried to follow what you explained here http://www.elvastowe...post__p__207252 (I'm abso...


    The code in GitHub does look correct as far as the logic.
    Last edited by eric; 01-17-2024, 08:19 PM.
    If you like what you see here at Trainsim.com, be it the discussions and knowledge in the forums, items saved in our library or the ongoing development of our TSRE Fork, I hope you'll consider a paid membership to help support keeping the site operating.... Thanks!

    Comment


      #3
      I have the TSRE5 codebase from github compiling and running locally on my windows machine.

      It's relatively easy to get it working.

      I can do a quick writeup on how to do it if you want?

      Comment


        #4
        Originally posted by pgroenbaek View Post
        I have the TSRE5 codebase from github compiling and running locally on my windows machine.

        It's relatively easy to get it working.

        I can do a quick writeup on how to do it if you want?
        That would be FANTASTIC! Thank you!

        Comment


          #5
          Originally posted by pgroenbaek View Post
          It's relatively easy to get it working.
          That would be very helpful... If I can be demanding, screenshots are critical.

          What compiler/studio is it running in? ORTS leans towards Visual Studio, but I know there are others that may play better with QT for multi-platform use.

          (Very glad to see the Danish contingent showing up lately... Mine bedsteforældre var fra ved Nykøbing i nord)
          If you like what you see here at Trainsim.com, be it the discussions and knowledge in the forums, items saved in our library or the ongoing development of our TSRE Fork, I hope you'll consider a paid membership to help support keeping the site operating.... Thanks!

          Comment


            #6
            Originally posted by eric View Post

            That would be very helpful... If I can be demanding, screenshots are critical.

            What compiler/studio is it running in? ORTS leans towards Visual Studio, but I know there are others that may play better with QT for multi-platform use.

            (Very glad to see the Danish contingent showing up lately... Mine bedsteforældre var fra ved Nykøbing i nord)
            I have it running with the g++ compiler in mingw32 through the Apache Netbeans IDE.

            I suspect Goku was using the same setup based on the contents of the /nbproject folder.

            That folder was also how I figured out the dependencies needed, their versions, etc.

            I'll get around to it over the weekend. And will create it with screenshots where necessary (because it 100% is in some places).

            (Og fedt haha, havde ikke lige forventet at se dansk her )

            Comment


              #7
              I have it running with the g++ compiler in mingw32 through the Apache Netbeans IDE.

              I suspect Goku was using the same setup based on the contents of the /nbproject folder.
              I completely agree with this assessment, btw
              http://www.railsimstuff.com
              Just Blender now, 3DCrafter only when I have to.
              formerly The Keystone Works (All Permissions Granted)
              https://github.com/pwillard/MSTS-replacement
              sigpic

              Comment


                #8
                So, as promised, here's how to get the current TSRE5 codebase from GitHub compiling and running in Windows using the NetBeans IDE.

                I am not going to go into too much detail with things like installing NetBeans, Qt, etc. Because that is easy to do.

                But if you need more details in regards to something, just ask and I'll clarify.

                And you may have to adjust some of the directory paths I specify. That depends on where you choose to install and put things in your system during the first few steps.

                Let's get into it.


                Step 1 - Installing Apache NetBeans 20:

                First you need to install Apache NetBeans 20.

                You can download it from here: https://netbeans.apache.org/front/main/download/nb20/

                You'll specifically want the "Apache-NetBeans-20r1-bin-windows-x64.exe" from that page.

                This should be fairly straightforward to install.


                Step 2 - Installing OpenJDK 13.0.2:

                Next you need to install a JDK that MUST be no newer than version 13.0.2.

                There is a very good reason why you need a JDK that's not newer than that.

                You will most likely need a file in the next step that's not available in JDK's that are newer than 13.0.2.

                You can get it from this page: https://jdk.java.net/archive/

                Again, this should be fairly straightforward to install.


                Step 3 - Installing the C/C++ plugin within NetBeans:

                Next install the C/C++ within NetBeans.

                You can do this by going to Tools => Plugins in the top menu.

                In the window that opens select "Available Plugins"

                Then find the one called "C/C++". And click install.

                During installation NetBeans will most likely complain that it needs a "unpack200.exe". At least it did for me.

                If it does, point it to the file within the JDK13 you just installed in the previous step.

                The file is located at: C:\Program Files\Java\jdk-13.0.2\bin\unpack200.exe

                Other than that installing the plugin should be without much hassle.


                Step 4 - Installing Qt 5.7:

                Next up you need to install Qt.

                We will need version 5.7 as this is what Goku was using.

                You can download the installer from this page: https://download.qt.io/new_archive/qt/5.7/5.7.0/

                You'll want to specifically download the one for mingw named "qt-opensource-windows-x86-mingw530-5.7.0.exe".

                The installation of Qt should be easy as well.


                Step 5 - Install MinGW:

                Download the MinGW installer from here: https://sourceforge.net/projects/mingw/

                The installation of MinGW should be also be quite easy.


                Step 6 - Download and set up OpenAL Soft binaries:

                Now you need to download the OpenAL Soft binaries, this is where things start to get interesting.

                You'll specifically need version 1.18.2 from this page: https://www.openal-soft.org/openal-binaries/

                As of writing this I am unable to visit the url, and that was not the case two weeks ago when I first did this.

                You can try getting it from here instead if the other does not work for you: https://web.archive.org/web/20230805...1.18.2-bin.zip

                There is one problem with the binaries you just downloaded though. They don't work with MinGW and g++ out of the box.

                You will always get linking errors if you try to use the libraries directly from the zip file you downloaded.

                So what we need to do is to create the ".a" file that's needed by ourself, and fortunately that is a simple process.

                You will need something called "dlltool" do create it. This is included in the MinGW installation from the last step.

                You'll need to open up cmd.exe and type in the following commands:

                Code:
                cd C:\openal-soft-1.18.2-bin\libs\Win64
                C:\MinGW\bin\dlltool -d OpenAL32.def -D OpenAL32.dll -k -a -l libopenal32.a -v
                Like this:



                This will create a MinGW compatible library that links successfully when building TSRE5.

                Of course, the paths in the above commands might be different depending on where you have put things in the previous steps.

                Now you should have a file named "libopenal32.a", and we will need this in the next step.




                Step 7 - Configuring the NetBeans build:

                If you haven't done so already, it's time to clone the TSRE5 repository from GitHub.

                In the top menu bar go to Team => Remote => Clone..., that will bring up the following dialog:



                Specify the repository URL as "https://github.com/GokuMK/TSRE5", and then the local directory you want to clone the repo to.

                Next specify the remote branch. Check "master" if it isn't already.



                Click next.

                The final step should look like something this:



                Then click Finish. NetBeans will now clone the repo and open the project for you.

                When the project has loaded you'll want to right click it, and select Properties:



                First we will need to add some extra Qt linking settings.

                Select "Qt" under categories.

                Then scroll all the way down to the bottom and find "Custom Definitions".

                Next, click on the small button with "..."​



                That will bring up a another dialog where you need to add the following lines:

                Code:
                LIBS += -lopengl32
                LIBS += -lglu32
                LIBS += -lglut32
                LIBS += -L"C:\openal-soft-1.18.2-bin\libs\Win64"
                Again change the path if necessary, it should look like this when you're done:



                And click OK.

                Next we'll need to change the path for the OpenAL Soft binaries

                Now select "C++ Compiler" under Categories.

                Click the small button with "..." in the "Include Directories" line.

                Then edit the path to where you put the OpenAL Soft binaries, with the ".\include" subdirectory appended to it.

                In my case this is "C:\openal-soft-1.18.2-bin\include":



                Click OK.

                Then go to "Linker" under Categories and specify the path to the "libopenal32.a" file we created earlier.

                In my case this is "C:\openal-soft-1.18.2-bin\libs\Win64\libopenal32.a"

                You can edit the string directly or use the "Add Library File..." button.



                Click OK.

                The final thing we need to do before we can build TSRE5 is to tell NetBeans where Qt and the compiler tools are located.

                Go to "Build" under categories.

                Click the small "..." button in the "Tool collection" line.



                That will bring up the following dialog:



                ​All the fields here will be blank when you open it.

                Here you need fill out all the the fields like above.

                It does not matter whether you create a new Tool Collection or modify an existing one. And you can name it whatever you want.

                When you have filled out the fields click "OK".

                And make sure the Tool Collection that you filled out the fields for is selected like this:



                Now you can compile TSRE5. At least these were the steps I needed to take. Let me know if you are unable to.


                Step 8 - Compile the project:

                It's now time to build. You can do this by clicking the hammer in the toolbar or you can press F11.



                Note that sometimes the build fails with messages like this:

                Code:
                "mv: cannot move `qttmp-Release_x64.mk' to `nbproject/qt-Release_x64.mk': Permission denied"
                And that's just something you can disregard and try again until it works. I don't know why NetBeans does this occasionally.


                Step 9 - Making the compiled .exe able to start outside of NetBeans:

                When it's been built you can start it within NetBeans with the play button in the toolbar or by pressing F6.

                The built TSRE5.exe is put inside the "./dist" folder of the same directory that you cloned the repository to.

                In my case this is "C:\Users\Peter\Documents\NetBeansProjects\TSR E5\T SRE5\dist\Release_x64\MinGW_1-Windows".

                To run TSRE5.exe outside of NetBeans, there's one more thing we have to do.

                And that is to move a couple of dll's into the directory with the TSRE5.exe file.

                Copy the following dll's from "C:\Qt\Qt5.7.0\5.7\mingw53_32\bin":
                • libstdc++-6.dll
                • libgcc_s_dw2-1.dll
                • libwinpthread-1.dll
                • Qt5Core.dll
                • Qt5Gui.dll
                • Qt5Network.dll
                • Qt5WebSockets.dll
                • Qt5Widgets.dll
                So that the folder looks like this:



                The reason why these are not present with the TSRE5.exe built by Goku is that they are somehow included in the executable when he builds it.

                And that doesn't happen here for some reason.


                And that's it, you can now run the TSRE5.exe that you've compiled yourself.

                When it starts for the first time it downloads the appdata folders it needs from Goku's webserver and creates the settings.txt file.


                Let me know if you encounter any difficulties.

                Anyway, this is what I needed to do to compile and run TSRE5 on my machine.​

                Hope this guide is useful.
                Attached Files
                Last edited by eric; 01-18-2024, 04:33 PM.

                Comment


                  #9
                  Thanks for posting this --- I've started downloading the installers before taking on the installation.

                  For others who are thinking of doing this --- the QT download is 1Gb, so expect that will take a while. The others were quick, and yes, I had to get that one file from the Wayback Machine.

                  Assuming this works (and I have no reason to think it won't), I may host those here so that they're preserved for other developers on this effort until TSRE can be re-platformed or it gets replaced by an official ORTS team product.

                  If you like what you see here at Trainsim.com, be it the discussions and knowledge in the forums, items saved in our library or the ongoing development of our TSRE Fork, I hope you'll consider a paid membership to help support keeping the site operating.... Thanks!

                  Comment


                    #10
                    Are Steps 1 and 2 reversed? -- you cannot install NetBeans without a JDK present

                    Step 7 -- I didn't have a Team->Remote but I did have Team->Git->Clone


                    Using the same steps, I get this when I try to open the project properties:

                    Attached Files
                    Last edited by eric; 01-19-2024, 01:38 AM.
                    If you like what you see here at Trainsim.com, be it the discussions and knowledge in the forums, items saved in our library or the ongoing development of our TSRE Fork, I hope you'll consider a paid membership to help support keeping the site operating.... Thanks!

                    Comment


                      #11

                      That does make sense Eric, since you can't *RUN* NETBEANS without JAVA... make sense too, since NETBEANS is primarily an IDE for JAVA users. (Though clearly its not limited to JAVA coding)

                      Also...

                      I'll can add this writeup as an appendix in the GITHUB TSRE PDF Manual, if you like.
                      http://www.railsimstuff.com
                      Just Blender now, 3DCrafter only when I have to.
                      formerly The Keystone Works (All Permissions Granted)
                      https://github.com/pwillard/MSTS-replacement
                      sigpic

                      Comment


                        #12
                        This reminded me of rooting my phone….

                        I tried to do this as a non-programmer person, so that it would be a “clean” install experience. The process was slightly different for me than what was described, and I eventually got stuck at the same place as Eric. I’m on Windows 11.

                        I already had Java 18+ installed, so I didn’t install Java 13+ and instead just unzipped it onto my desktop to get the needed file. When I installed NetBeans, I pointed it to the Java13+ folder when given the option to do so. It installed no problems.

                        When I opened NetBeans, C/C++ was already loaded as a plug-in, so I didn’t have to do that. I also received no errors about unpack200.exe. Not sure if both of these differences are related to the fact that I pointed NetBeans directly to Java13+ or what.

                        I had to request to create an account to install QT. This generated an email asking me to click on a link to verify an account. But apparently this is optional (albeit somewhat misleading/confusing). QT is over 3gb installed.

                        MinGW was the only step that was as described above. Super easy and straightforward to download and install.

                        I, too, had to use the Way Back Machine to get the Open AL Soft Binary. And then I got stuck. There is no DLLTool in MinGW, and I get the following result:
                        'C:\MinGW\bin\dlltool' is not recognized as an internal or external command, operable program or batch file.

                        The path is the same, but dlltool does not exist anywhere in the MinGW folder structure. Poking around in MinGW, I clicked on All Packages and installed the MinGW-Developer-Toolkit on a whim. This installed some sub packages by default, and I just let the defaults install. It took several minutes to install. That installed a lot of other things in the Bin folder, but not dlltool. I noticed G++ was mentioned in the post above, so then I installed the packages related to G++. That did the trick: dlltool was installed and running the command successfully created libopenal32.a in the correct openal subfolder.

                        For Step 7, I don’t have a Team->Remote->Clone. Instead, like Eric, I have a Team->Git->Clone. Other than that, the next few directions are straightforward and I followed them. NetBeans creates a progress bar once you ask it to Clone. Once that finishes, is where I got lost. NetBeans doesn’t immediately open the project. Instead it asks if you want to Create Project, with a subobtion to checkbox Open Sources in Favorites.


                        I checked Open Sources in Favorites and clicked ”Create Project.” That took me to a completely different menu than what is posted above, with completely different options. I didn’t know what to do, but we’re talking about C++, so I clicked that option.



                        That asked me for the path again. I clicked next. And then asked me for the Compile Commands.

                        I had no idea what to put in there, so I just clicked Finish. THAT finally brought me to the option to right-click on the project and select Properties.

                        But clicking on Properties brought me back to selecting Editor and Build. There's nothing in Build, but clicking on "…" next to Editor/Compile Commands makes me select a folder location. Which is where Eric got to. And, like him, I don’t know where to go from there.


                        Attached Files

                        Comment


                          #13
                          Also, mine looks a lot different "when the project has loaded" and I have a lot fewer options under Properties than what is displayed above. I also notice that your icon to the left of TSRE5 is different (looks like some sort of QT icon) than mine.


                          So I have a feeling that there are things that still need to be defined somewhere within NetBeans, to point to QT and/or something else. After some further internet searching, I tried adding the editor as the MNGW\bin\g++.exe and also qt\qt5.7.0\tools\mingw530_32\bin\g++.exe. But that still doesn't do anything to change the Build options

                          Attached Files

                          Comment


                            #14
                            Originally posted by pgroenbaek
                            ...
                            I gave this a try as well -
                            Similar problems as Yellow Dog.

                            Pgroenbaek - I wonder if you've got a different version of Netbeans?
                            When I pulled Goku's code, Netbeans does not see a project - (Though I do see a NBProject folder and some files)
                            One thought was that he was using an older version of netbeans, another was that he was using a different OS (ie not windows)
                            I wonder if there's a case sensitivity issue going on here.

                            Oh and one more thing - In my netbeans install, C/C++ was already installed, but I did have to Activate it.

                            Comment


                              #15
                              Originally posted by yellowdog
                              Also, mine looks a lot different
                              I think I may have figured this one out.

                              I was using the included C++ plugin.
                              but I think the one that works is the old one.

                              Go to the Tools menu-> Plugins ->Settings tab.
                              Check that Netbeans 8.2 plugin portal.

                              Then back on the Available plugins tab, sort by name and install the C/C++ one as shown below (note the source is NetBeans 8.2 Plugin Portal)




                              You don't want the red one - that's the one that comes with Netbeans 20, Pick the C/C++ one.
                              ​​
                              Attached Files

                              Comment

                              Working...
                              X