Open HBS
Development environment
orwell dev-c++ version 5.10 with gc 4.8.1
wxWidgets 2.8.12/3.0.2 (yeah, it works now with 3.0.2 as well!)
compilation wxWidgets:
before compilation (probably!) makefile.gcc must be adapted as follow:
set shell variable (if cygwin or similar used)
makefile.gcc
#!makefile
#SHELL := $(COMSPEC)
SHELL := cmd
add RCFLAGS to the resource compiler:
#!bash
sed -i 's/--define/$(RCFLAGS) --define/g' makefile.gcc
then compiler could be started..
#!bash
mingw32-make.exe -j4 -f makefile.gcc UNICODE=0 SHARED=1 BUILD=debug CXXFLAGS+="-D__MINGW64__ -fpermissive -fno-keep-inline-dllexport -Wno-unused-local-typedefs" CPPFLAGS=-m32 LDFLAGS=-m32 RCFLAGS=-Fpe-i386
probably this command has to be started twice - first runs generates strange error, the second run works fine.
build release without asserts:
mingw32-make.exe -j4 -f makefile.gcc UNICODE=0 SHARED=1 BUILD=release CXXFLAGS+="-DNDEBUG=1 -D__MINGW64__ -fpermissive -fno-keep-inline-dllexport -Wno-unused-local-typedefs" CPPFLAGS=-m32 LDFLAGS=-m32 RCFLAGS=-Fpe-i386
zlib
openssl (v.0.98/0.98a, but not 1.x, because x509v3.h probably conflicts with wincrypt.h)
(it works even with 1.x, but some lines in the x509v_3.h must be out commented)
after installing zlib package zlib directory missing.
it must be created manually in "...\Dev-Cpp\include" and both zconf.h and zlib.h files have to be moved into.
running from the pgsql command promt:
(connect to the default database first)
#!SQL
start psql:
psql.exe -U postgres
create user "lbs-admin" password 'lbsadm';
create database "HBS" owner = "lbs-admin" lc_ctype='C' lc_collate='C' encoding 'LATIN1' template template0;
...reconnect to the database HBS
#!SQL
pgsql -d HBS -U "lbs-admin"
create schema "LBS" AUTHORIZATION "lbs-admin";
\i create_khs_weissensee.sql;
easylogging (v.8.91) will be used for logging (https://github.com/easylogging/easyloggingpp). in the .h file one change is mandatory:
in the line 74: _ELPP_GCC_VERSION >= 40801
the number 40801 must be replaced with (any) bigger number, otherwise compiler forced to use c++11.
6a. lines starting with 152 : #include <winsock2.h> is needed
// Windows
#if defined(_WIN32) || defined(_WIN64)
# define _ELPP_OS_WINDOWS 1
#include <winsock2.h>
#else
# define _ELPP_OS_WINDOWS 0
#endif // defined(_WIN32) || defined(_WIN64)</winsock2.h></winsock2.h>
Ini file reader/parser inih (https://github.com/benhoyt/inih)
download postgres redistributable and create .a files from libpq.dll
generate .def file from dll: http://purefractalsolutions.com/show.php?a=utils/expdef
generate .a file from .def file:http://www.mingw.org/wiki/createimportlibraries (must not be downloaded extra, is a part of MinGW)
setup include/lib paths in the Code:Block
** note **
* directory structure:
<drive>
*\hksb
\3rdParty
\
Note: WXwxWidgets' official recommendation is using MinGW TDM-GCC. You can most likely go through this section using this compiler - we did not test this combination yet tho. It may also work with GCC, which we do not recommend as we had mixed results.
Note: In the following sections, you will find some paths which you have, for example, to add to environment variables. If you decide to install/copy/unzip some of the files or tools to other directories, you will have to adjust the paths.
Get the compiler of your choice:
a) TDM2 4.8.1: http://sourceforge.net/projects/tdm-gcc/files/TDM-GCC%20Installer/Previous/1.1309.0/ or
b) MinGW TDM-GCC 4.8.1: http://sourceforge.net/projects/tdm-gcc/files/TDM-GCC%20Old%20Releases/TDM-GCC%204.8%20series/
Note: Do not forget to set the path to the compiler in the environment Path variable.
Get the Eclipse IDE:
a) You can either download the Eclipse IDE for C/C++ Developers directly here: http://www.eclipse.org/downloads/packages/eclipse-ide-cc-developers/keplersr2 or
b) Download the CDT extention here: https://eclipse.org/cdt/downloads.php
Note: If you want to make sure the project will be built, use Eclipse Mars.1 as this is the release we tested.
Set up the directory structure and get the source code
In any drive (or directory you linked to be a drive), you have to create the directory HKSB in which you have to create another directory called 3rdparty. As the name suggests, the 3rdparty directory will contain (at least most of) the 3rd-party software we have to use and which you will find in the upcoming sections.
You now can create another directory for the project, let's call it HBS. Into this directory you have to clone the project, resulting in you having the following directories:
<drive>\HKSB\3rdparty
<drive>\HKSB\HBS\
with the directories LBS-Client
, LBS-Server
, HBS-Interface
Database
and SOAP
in it.
If you decide to replace some of the files in the SOAP directory (which you can, for example if you want to use another version of gSoap), you have to add the following lines into the file soapLBS_SoapProxy.h right below the call soap = soap_new();
in the constructor:
if (soap_ssl_client_context(soap,SOAP_SSL_NO_AUTHENTICATION,NULL,NULL,NULL,NULL,NULL))
{
soap_print_fault(soap,stderr);
}
endpoint = Prog->URL_SOAP.c_str();
If you are unsure about where to place those lines, take a look into the existing file before replacing it.
Note: If you change the directory structure, you may have to adjust the makefile and the environment variables in Eclipse and in your Windows Path variable.
Build wxWidgets
wxMSW-2.8.12\build\msw\makefile.gcc
and make the following changes:SHELL := $(COMSPEC)
with SHELL := cmd
windres --use-temp-file -i$< -o$@ --define __WXMSW__
with windres --use-temp-file -i$< -o$@ $(RCFLAGS) --define __WXMSW__
You can now build wxWidgets using the following command: mingw32-make.exe -j4 -f makefile.gcc UNICODE=0 SHARED=1 BUILD=debug CXXFLAGS+="-D__MINGW64__ -fpermissive -fno-keep-inline-dllexport -Wno-unused-local-typedefs" CPPFLAGS=-m32 LDFLAGS=-m32 RCFLAGS=-Fpe-i386
Important: You may have to start this command a couple of times - just repeat it. The first few times you may get error messages, but it will start to compile after a few times.
When the build finishes, move the file Setup.h from include\wx\univ
to include\wx
(one directory up).
Note: Whichever compiler you chose to use - make sure you compile wxWidgets with the same one as you will compile the project. If you happen to change your mind after compiling wxWidgets, make sure to recompile it with the compiler.
Get the other third-party software
Download and unzip the following tools into the 3rdparty-directory:
gSoap 2.8.16: http://sourceforge.net/projects/gsoap2/files/gSOAP/gsoap_2.8.16.zip/download
After unzipping, copy the file gsoap-2.8\gsoap\stdsoap2.h
into the <drive>\HKSB\HBS\SOAP
-directory.
Now run the following command from a shell in the <drive>\HBSK\HBS\SOAP
directory:
<drive>\HKSB\3rdparty\gsoap-2.8.16\gsoap\bin\win32\soapcpp2.exe -z2 -I<drive>\HKSB\3rdparty\gsoap-2.8.16\gsoap\import -x LBS_Soap.h</drive></drive>
This should create new versions of most of the files already contained in the SOAP
directory.
OpenSSL 1.0.2d: https://www.openssl.org/source/
After unzipping, you have to open HKSB\3rdparty\OpenSSL-Win32\include\openssl\x509v3.h
and comment out lines 238 to 248 (they all start with #define CRL_
...). They do conflict with wincrypt.h, that's why we have to get rid of them.
Easylogging 8.9.1: https://github.com/easylogging/easyloggingpp
In the unzipped directory you can will find a .h-file. In line 74 _ELPP_GCC_VERSION >= 40801
, you have to replace the number 40801 with any bigger number (like 40802). Otherwise, when building the Client, the compiler would be forced to use C++11.
zlib 1.2.8: http://sourceforge.net/projects/libpng/files/zlib/1.2.8/zlib-1.2.8.tar.gz/download?use_mirror=freefr&download=. After unzipping, remove the version from the directory name (so you get just zlib), otherwise you will have to change the path in the makefile.
Set up the Eclipse Project
<drive>\HKSB\HBS\LBS-Client
. <drive>\hksb\3rdparty\gsoap-2.8.16\gsoap
<drive>\CodeBlocks\MinGW
(or whereever you decided to install the compiler - this is completly up to you as the makefile does not depend on it)<drive>\HKSB\3rdparty\wxMSW-2.8.12
Build
When using the TDM2 compiler (and maybe TDM-GCC), there is a discrepancy between the name of the make software provided and the one Eclipse expects. Therefore, you either have to change the expected name in Eclipse from make to mingw32-make, or create a copy of the file inside the the directory you installed the compiler into and rename it from mingw32-make to make.
You can now build the project without any more actions.
Run
To run the resulting .exe, you have to:
a) add the following directories to the Windows environment Path variable:
<drive>\HKSB\3rdparty\wxMSW-2.8.12\lib\gcc_dll
<drive>\HKSB\3rdparty\wxMSW-2.8.12
<drive>\HKSB\3rdparty\OpenSSL-Win32\bin
Also make sure that the path to the compiler you used to compile wxWidgets is still in the Windows environment Path.
b) copy the files client.ini and LBS-Client.log.cfg from the Client source code directory (LBS-Client) into the containing exe directory (which is created when building the Client).
You now can run the program. Please note that it may some time to launch from outside the IDE.
Common errors
a) Make sure to compile wxWidgets with the same compiler you are going to build the project.
b) If, during the build, you get the error that some header-files can't be found, make sure that you:
c) If the .exe won't start, make sure that you added all neccessary paths to the Windows environment Path. There should be two for wxWidgets (see section 8), one for OpenSSL (see section 8) and one for your compiler (see section 1).
d) Make sure you didn't forget to select the right toolchain when creating the Eclipse project.
Important: In this section we assume that you built the Client already, as explained in the previous section Build Client on Windows with Eclipse and TDM2 4.8.1. All notes, e.g. about the compiler and the paths used, are also relevant in this section. If you, for some reason, only want to build the Server, you still have to set up everything explained in the sections 1-3, 5, 7 and 8 of the Client section.
Get and setup additional third-party software
Download and unzip the following tools into the 3rdparty-directory:
inih: https://github.com/benhoyt/inih
Please remove the -master ending of the unzipped directory.
Tinyxml2: https://github.com/leethomason/tinyxml2
Please remove the -master ending of the unzipped directory.
PostgreSQL 9.2.14:
<drive>\HKSB\3rdparty\pgsql
(please remember the password you've set here. Other settings can be left at default values).<drive>\HKSB\3rdparty\pgsql\bin
.Open a shell.
psql.exe -U postgres
to connect to the default database as the default superuser.create user 'lbs-admin' password 'lbsadm;'
(or choose your own credentials, but then remember to replace them whenever they occur in the course of this section). You should see the message CREATE ROLE
.create database "HBS" owner = "lbs-admin" lc_ctype='C' lc_collate='C' encoding 'LATIN1' template template0;
to create a new database. You should see the message CREATE DATABASE
. \quit
to disconnect from the default database.SET PGCLIENTENCODING=utf-8
to set the encoding used in PostgreSQL.chcp 65001
to change the code page.(as usual, replace
<drive>` with the drive you use).</drive>Enter the password you set in step 3. You should see a list of CREATE VIEW
and ALTER TABLE
messages.
%TODO%: Fix the create_db.cmd (or the conditions to make it work) to automatize these steps
We now will have create an .a file out of the libpq.dll.
<drive>\HKSB\3rdparty\pgsql\bin
)."expdef.exe -p -o libpq.dll > libpq.def
.dlltool -d libpq.def -l libpq.a
(dlltool is a MinGW tool which you should already have after building the Client).Set up the Eclipse project
<drive>\HKSB\HBS\LBS-Server
. <drive>\hksb\3rdparty\gsoap-2.8.16\gsoap
<drive>\CodeBlocks\MinGW
(or whereever you decided to install the compiler - this is completly up to you as the makefile does not depend on it)<drive>\HKSB\3rdparty\logging\easylogging
<drive>\HKSB\3rdparty\OpenSSL-Win32
<drive>\HKSB\3rdparty\pgsql
U_ZLIB: <drive>\HKSB\3rdparty\zlib
%TODO%: Adapt the makefile to the one of the Client for the sake of consistency
Build
You can now build the project without any more actions.
Run
You now can run the program. Please note that it has no GUI. If you want to make sure it runs, check the log which is created in the same directory.
Common errors
Important: In this section we assume that you built the Client already, as explained in the previous section Build Client on Windows with Eclipse and TDM2 4.8.1. All notes, e.g. about the compiler and the paths used, are also relevant in this section. If you, for some reason, only want to build the Server, you still have to set up everything explained in the sections 1-3, 5, 7 and 8 of the Client section.
Set up the Eclipse project
<drive>\HKSB\HBS\HBS-Interface
. <drive>\hksb\3rdparty\gsoap-2.8.16\gsoap
<drive>\CodeBlocks\MinGW
(or whereever you decided to install the compiler - this is completly up to you as the makefile does not depend on it)<drive>\HKSB\3rdparty\wxMSW-2.8.12
<drive>\HKSB\3rdparty\OpenSSL-Win32
U_ZLIB: <drive>\HKSB\3rdparty\zlib
%TODO%: Adapt the makefile to the one of the Client for the sake of consistency
Build
You can now build the project without any more actions.
Run
%TODO%: No .ini file available at the moment.
Writing tests