First determine your goals. To merely use the program, you need only download the installer and PDF manual, both available from the GitHub landing page.
However, if you wish to develop source code (fix bugs or add features), you will need the following. Note that the larger programs may take 10-20 minutes to install/compile.
C:\qwt-6.1.3\
. Then,
read the project documentation (online or in the local doc
folder)
regarding installing. You will have to compile a shared library with your favorite compiler
(eg. VisualStudio will give you a DLL file, MinGW will give you something).Now, open QtCreator. Select to open an existing project, and navigate to find
SorpSim/src/SorpSim.pro
, a Qt project file. You are then given options for
which compilers and platforms to use; just pick a favorite and click to Configure
(this create a new SorpSim.pro.user
file for your local machine).
The QtCreator then takes on the Editing mode appearance, and you can browse and
open source files. First, you need to edit SorpSim.pro and make sure that all
library paths are correct, specifically the Qwt library (include files, sources,
and .
(This initial setup could be done using CMake, but that requires some labor.)
Save changes, and then use menus to Build > qmake
, which generates a Makefile
for your compiler. Now you are ready to build the project and run it.
If you look at the GitHub page for SorpSim, you might see something like
2 authors
. Clicking through shows that there are a number of parallel
efforts. The developers may choose to synchronize changes into one main
branch, but it is good to research which branch is most up-to-date and
which developers are most active. Note: you can and likely should talk to them!
In the past I had difficulty compiling code (namely the CoolProp wrapper for Python) using my VS compiler from command line. This may have something to do with the Universal CRT as claimed by MS, or may just be a bug of VS. In fact you need to follow those directions in order to install a working version of VS. Furthermore, in Windows 10, I found that executing a couple lines was necessary to include the VS command line tools correctly. The script is here and requires you to set the arguments on the first Call statement based on your desired platform; see here. You could try that, or try launching QtCreator via the command line from within a "Native Tools Command Prompt" of your choosing. With the latter approach, you need to include manually into the Path: Qt bin and Jom. Ugh, this needs re-writing.
As the file qwt/INSTALL
indicates, you need to read
the documentation.
(Basic prequisites: open a command line, make sure that Qt
and your compiler tools are included in Path environment variable, etc.)
To help compile faster, try multithreaded compile. Per the Qwt documentation,
for MinGW, make takes argument -j
, as in -j4
for 4 cores. For VS, the
make tool is Nmake, which has no such option; see Nmake options.
On the other hand, the compiler does understand multithreading:
see here
and here.
The conclusion is that you need a replacement for nmake called JOM,
which is conveniently provided by the Qt folks, and automatically used by QtCreator
for VS projects. How about that?
Note that the Qwt project contains two targets to build: the library, and
also a plugin for QtCreator, in the qwt/src/designer
directory.
Project settings are in the file qwtconfig.pri
including a switch
to control whether and how the plugin is compiled.
I built Qwt by opening the project file in QtCreator. By default, QtCreator makes a separate build directory to avoid polluting your source folder; then you will have to locate the include files and libraries for use by SorpSim. Also note that in the IDE, you can pass arguments to your Make program by entering the Projects mode (Ctrl-5) and expanding Build Steps > Make
.
Anyway, compiling took a long time.
Compiler | Flags | Elapsed time |
---|---|---|
MinGW 32-bit | None | 29:31 |
MSVC 2017 64-bit | jom -j4 | 03:15 |
Please note above hints for multithreaded compile. Once again, I opened the project file in QtCreator and compiled that way. Oh, and it looks like jom is now using all my cores without my asking.
Here are the typical results.
Compiler | Lib versions | Computer | Extra flags | Compile time |
---|---|---|---|---|
MinGW 32-bit | Qt 5.9.3, Qwt 6.1.3, SorpSim 4751bf9 | 8x 3.6 GHz, 8 GB | None | Pending... |
MSVC 2017 64-bit | Qt 5.9.3, Qwt 6.1.3, SorpSim 4751bf9 | 8x 3.6 GHz, 8 GB | None | 00:58 |
So, wow, that's even faster than compiling qwt.
As often happens in life, the code fresh from the published repository will not compile. Here are a list of changes required from the commit 4751bf9.
Linker was complaining about finding the qwt library, so I let QtCreator automatically generate the specification for the external library into my SorpSim.pro
file (and I deleted the manually included lines). The difference is at the end of the line an extra argument with lower case l for link, as in LIBS += -L<qwt path>/lib/ -lqwt
.
C-tyle array declarations converted to C++ vectors. I was getting errors about initializing arrays with non-constant expression. There were many declarations of C++ style arrays (with brackets[]), some containing Qt objects and many containing double, using variables as the size specifier. C++ wants an actual constant at compile-time, not a const
variable. So I converted these to declarations of std::vector<T>
. I wonder if extern "C"
could get around that, but it is easy enough to stick with C++.
Clean environment PATH variable. I had a DLL in my path that may overlap with system files, from MiKTeX. I removed MiKTeX from the PATH and continued (no change to code).
Adjust linker argument order. I received a new error message that some symbol was unresolved (in my case, theTabledialog
from tabledialog.cpp
). It was defined properly in code. So continuing to search, I read that this error message may be related to the order in which linked libraries are specified. The project file SorpSim.pro
lists the files to include in the project. Presumably these are passed as-is to the linker. So I moved tabledialog.cpp
to just after the two files that use it. Edit: nevermind, this was not the problem.
Change type of extern variables at global scope to match declaration with definition. A global variable theTabledialog
was defined as QTableDialog*
in tabledialog.cpp
but included as tabledialog*
in a couple other files.
Include missing files (or drop unused files). The compiler could not find the header file ui_breaklinkdialog.h
. This type of file gets generated by moc
in the Qt build process, and its specification is a file breaklinkdialog.ui
. That file exists; however, the file SorpSim.pro
lists individual files to include in the Makefile, rather than directories, and this one wasn't listed, althought it was included by breaklinkdialog.cpp
. However, that code is never used by the project, so we might as well drop it from the list!
Note: compiling with MSVC, I get a false warning: ..\src\tabledialog.cpp(1841): warning C4189: 'fDialog': local variable is initialized but not referenced
. However, the local variable is indeed referenced two lines later! So ignore that one.
At last, the code compiles and runs. I was even able to open one of the template files (by browsing). However, it crashed on my first attempt to calculate. So there may still be some debugging required! One more note, I can see from the provided systemSetting.xml
that the last developer was trying to compile with MinGW 32bit and Qt 5.0.2. So I should probably try compiling with that as well.