Skip to content

Latest commit

 

History

History
164 lines (162 loc) · 17.5 KB

File metadata and controls

164 lines (162 loc) · 17.5 KB

Compiling JmriQt

 This port of the Java JMRI project is referred to here as JmroQt.  Development  has been done starting with QT 4.8.3 Current efforts have been using Qt Version 5.11.3.  Qt is available for Linux, Windows, Mac and other systems. Qt can be downloaded from: http://qt-project.org/downloads|Qt downloads. You will also need to download the QtCreator IDE program. Recently, development has used Qt version 5.4 or higher. The recent addition of the Web Server requires the later versions of Qt because of support for WebSockets. 

The program requires the use of the | QtSerialPort package which is included in Qt 5.0+ but can be downloaded for use with QT 4.x versions. Even though the QtSerialPort module is included with Qt 5.0, it does not, when running on Linux, display manufacturer or descriptive info. In order to display this info, it is necessary to install the udevlib-dev packagage (|instructions) and to download the current QtSerialPort source (as of August, 2013). As of November, 2013, the QtSerialPort package included with Qt 5.0 provides the nececessary support.

The program consists of at least 13 sub-projects:

  1. appslib This module contains base libraries for the 3 apps that wil lbe built: DecoderPro3,
  2. AutoIncreaseBuildNr This is a little utility program that is used to automatically increment the build number in a c++ header file.
  3. DecoderPro3 This is one of the several executables produced. It is oriented to working with Rosters, and working with decoders.
  4. libPr3 This project creates a library that contains classes for accessing LocoNet messages and manages configuration data for LocoIO modules.
  5. ftdilib This project supports RFID readers that can be obtained from | Spark Fun Electronics
  6. JavaQt  This library contains  classes the map Qt  classes to JMRI classes and other basic  classes used thoughout.
  7. LayoutEditor This project creates a library of routines that are used to create and edit a GUI layout panel.
  8. libTables This project creates a library that provides a dialog to display and edit various system tables such as turnouts, sensors, blocks, etc.
  9. libPref This project creates a library with functions relating to setting and viewing preferences.
  10. LocoIO This project adds panels that I have developed to program LocoIO, LocoServo and LocoBuffer modules.
  11. InstallTest This project creates an excutable that JMRI developed to test an installation.
  12. PanelPro  This project creates an executable for making Control Panels.
  13. QtWebApp  Provides a web server. Local changes to the original package are now inclused in th source tree.

Other Package Requirements

Several other software software packages must be present in order to compile. These are:

  1. QuaZip This package provides support for creating and reading zip files. For example, the files creating a roster can be saved as Zip files. The package (version 0.7.3) can be downloaded from https://sourceforge.net/projects/quazip/files/latest/download
  2. PythonQt This package is used to support creation and execution of Python scripts. I am using branch "opencor_r502" which has wrappers for Qt version 5.11. https://sourceforge.net/projects/pythonqt/files/  See: (| Scripting) Because of some problems with the version of PythonQt on SourceForge, I have made some minor changes: ```Index: generator/main.h
    ===================================================================
    --- generator/main.h    (revision 502)
    +++ generator/main.h    (working copy)
    @@ -105,6 +105,12 @@
                 std::cout << "-------------------------------------------------------------" << std::endl;
                 std::cout << "Using QT at: " << qtdir.toLocal8Bit().constData() << std::endl;
                 std::cout << "-------------------------------------------------------------" << std::endl;
    +            QDir dir(qtdir);
    +            if(!dir.exists())
    +            {
    +             qWarning("QTDIR environment variable does not exist. This may cause problems with finding the necessary include files.");
    +             std::cout <<  "WARNING! QTDIR environment variable does not exist. This may cause problems with finding the necessary include files.";
    +            }
                 qtdir += "/include";
                 includes << (qtdir + "/QtXml");
                 includes << (qtdir + "/QtNetwork");
    @@ -111,6 +117,7 @@
                 includes << (qtdir + "/QtCore");
                 includes << (qtdir + "/QtGui");
                 includes << (qtdir + "/QtOpenGL");
    +            includes << (qtdir + "/QtWidgets");
                 includes << qtdir;
             }
             foreach (QString include, includes) {
    Index: generator/shellheadergenerator.cpp
    ===================================================================
    --- generator/shellheadergenerator.cpp    (revision 502)
    +++ generator/shellheadergenerator.cpp    (working copy)
    @@ -152,7 +152,8 @@
           }
           s << "),_wrapper(NULL) {";
           writeInjectedCode(s, meta_class, TypeSystem::PyInheritShellConstructorCode, true);
    -      s << "};" << endl;
    +      //s << "};" << endl;
    +      s << "}" << endl;  // ACK
         }
         s << endl;
         s << "   ~" << shellClassName(meta_class) << "();" << endl;
    ```
  3. Python  The version of Python supported is version 2.7 or later. Python may be included with your OS. There are several Python versions available. For example to install Python 3.4
    1. Add the deadsnakes PPA (read more about it at https://launchpad.net/~deadsnakes/+archive/ubuntu/ppa):

      <code><span class="pln">sudo add</span><span class="pun">-</span><span class="pln">apt</span><span class="pun">-</span><span class="pln">repository ppa</span><span class="pun">:</span><span class="pln">deadsnakes</span><span class="pun">/</span><span class="pln">ppa</span></code>
    2. Install python3.4:

      <code><span class="pln">sudo apt</span><span class="pun">-</span><span class="pln">get update<br>sudo apt</span><span class="pun">-</span><span class="pln">get install python3</span><span class="pun">.</span><span class="lit">4</span></code>
  4. QtWebApp This package provides the basic web server functionality. The original QtWebApp developed by Stefan Frings doesn't suppport WebSockets but there is a fork available that does: httpss://github.com/samiavasil/QtWebApp  However there are a few minor changes that need to be made. See QtWebApp.html
  5. JMRI While this project does not use any of the original JMRI code, it does require many of the support files included with JMRI like icons, html files, decoder files, etc. For this reason, you must have a copy of JMRI on your PC to be able to use these files. JMRI source can be downloaded from: http://jmri.sourceforge.net/download/index.shtml
  6. QtZeroConf This package is required to be able to advertise the Web server and the LnOverTcp server. It can be downloaded from https://github.com/jbagg/QtZeroConf It requires that the libavhi-client-dev package be installed.
  7. libftd2xx This library is needed to compile the ftdilib sub-project. You can download the library from  FTDI Drivers. Note, I was unable to use the version for Linux x64 (64-bit), version 1.4.8  but further on down the page,  the older  version 1.3.6  works fine.  Copy the file libftd2xx.a to /usr/local/lib.


Downloading the source

The source repository uses Fossil. Fossil can be downloaded for various platforms at | http://www.fossil-scm.org/download.html. Download the program and make it available in your path as is appropriate for your operating system. To prepare for downloading the source, perform these steps:
  1. Select a root directory where the source will reside. In my case, I have a directory called 'Projects' although it can be any name you choose.
  2. In the 'Projects' directory, create a directory named 'DecoderPro'. Again, the name you choose for this directory is not important.
  3. Change to the 'DecoderPro' directory.
  4. Clone the source repository with the command: 'fossil clone http://acksoft.dyndns.biz:1080/cgi-bin/fossil/DecoderPro decoderpro.fossil'. This will create a file named 'decoderpro.fossil' which is your local repository copy.
  5. Next, issue the command 'fossil open decoderpro.fossil'. This will download the source and other files in the project. It will create a directory 'DecoderPro_app in the '../DecoderPro/' directory containing directories: 'AutoIncreaseBuildNr', 'ftdilib', 'libPr3', 'LocoNetMonitor', 'LayoutEditor', 'Tables' and 'wiki'.
  6. In QtCreator, open the 'AutoIncreaseBuildNr.pro', 'libPr3.pro' and 'LocoNetMonitor.pro' project files in their respective directories.
  7. Project AutoIncreaseBuildNr should be built first as it is required by the other projects. If you want the optional RFID support, ftdilib must be |compiled and built. Then likewise, the library, libPr3 must be compiled before LocoNetMonitor.
  8. The source can be updated at any time with any changes since you created the project or last ran 'fossil update' at any time by running 'fossil update
  9. QtWebApp is stored in a separate Fossil repository: http://acksoft.dyndns.biz:1080/cgi-bin/fossil/QtWebApp

Windows

On Windows, a USB driver is required. There are instructions in the http://users.telenet.be/deloof/Locobuffer/LocoBuffer%20EN.pdf|LocoBuffer Manual on how to do this.

Compiling Tips

Because many classes refer to classes in other libraries, it will become necessary to take some precautions in order to sucessfully compile the various libraries. At the present time, the only library that does not reference classes in any other library is JavaQT. Therefore, it is recommended that it be compiled first.  When compiling the other libraries, the link will fail when another library is referenced which is not yet built. To circumvent this, one should temporarily comment out the references to the libraries that have not yet been built. This will of course produce a host of unresolved link errors. But it will create the necessary .so file or .dll file that other libraries and execuables need. Once a library is built and a .so or .dll file exists, the commented out references in the various .pro files for each sub-project can be un-commented.

The Project has been created as several separate project directories as part of an overall Projects directory. In order to avoid extensive changes to the various projects' .pro files, it is recommended that you maintain this structure. When it is necessary for a project to referance another, the ,pro files all can use an environment variable, "PROJ_DIR" to specify the location of the projects directory. This environment variable can be set in Windows environment variables or in Linux as an entry in .bash.rc, e.g. "export PROJ_DIR="/home/allen/Projects".

Suggested steps to compile the first time

  1. Create an Environment variable "PROJ_DIR" that specifies the location of your projects directory where the various packages are kept. The Projects folder well then contain one or more flders/directoried with different projects.
  2. Make sure you have either an installed copy of the Java JMRI app or have downloaded the source from JMRI. It is needed to provide resources like icons and other resources. It is best to insure that you have an environment variable "JMRI_PROG" set to the location of the JMRI code.  (Jmri Code: Getting the Code)
  3. Make sure that you have a copy of QtZeroConf  installed and compiled. (It can be downloaded from https://github.com/jbagg/QtZeroConf It requires that the libavhi-client-dev package be installed.)
  4. In QtCreator open project "jmri.pro". Make sure that  thw shadow build box is not checked!
  5. Build the JavaQt sub-project.
  6. Build the QtWebApp sub-project.
  7. Insure that QuaZip has been installed on your system. (The package (version 0.7.3) can be downloaded from https://sourceforge.net/projects/quazip/files/latest/download)
  8. Modify the appslib.pro  file to comment out each of the parts referencing other libraries: (libPr3, libPref, Tables, LayoutEditor, LocoIO but not JavaQt. DO NOT comment the "INCLUDPATH" or "DEPENDPATH" statements for these libraries! This will allow the initial libappslib.so file to be created although there will be a large number of undefined references to other libraries not built. When the other libraries have been built, the lines commented out here can be restored.  Now build sub-project appslib. Verify that the lib file. appslib.so has been created.
  9. Now do the same for sub-project LayoutEditor.pro; comment out references to other libraries (except JavaQt and appslib which are already built).
  10. Now, build sub-project libPr3. Comment out references to libraries not yet built, e.g. libPref, LocoIO, Tables.
  11. Once libPr3 is complete and libPr3.so has been created, proceed to build sub-project libPref, commening out the reference to lib locoio.
  12. And once libPref is complete, we can build sub-project LocoIO. It won't be necessary to comment any references to any other libs since they should have been built.
  13. Now build sub-project Tables. No library references to other sub-projects need to be commented out as they should have been built.
  14. When Tables has been successfully built, go back and un-comment the lib references in appslib, libPr3, LayoutEditor, lipPref .pro files
  15. After un-commenting the lines in the .pro files that was done earlier, build the sub-projects again to pick up the references to functions and classes in the other lobraries.
  16. Now, we can build the app PanelPro. Build the sub-project PanelPro.
  17. After PanelPro has compiled successfully, you can go click on the Qt Creator "Projects" icon in the left side panel and then select PanelPro executable which can then be run using the run button or the debug button.