Artistic Style Wx Install Information

 

Contents

wxWidgets Compiles

Linux

MacOS

Visual Studio

Other Windows Compilers

Linux Compiles

Linux Library Runtime Error

CodeBlocks Linux

CMake Linux

GCC Makefile

Clang Makefile

Intel Makefile

Makefile Shared Libraries

Other Makefile Options

Other Makefile Targets

MacOS Compiles

Xcode

CodeBlocks MacOS

CMake MacOS

MacOS Makefile

Windows Compiles

Precompiled Executable

Visual Studio

CodeBlocks Windows

CMake Windows

Other Compilers

Compiler Options

wxWidgets Compiles

For all platforms use wxWidgets 3.0 and higher. AStyleWx will NOT compile with wxWidgets 2.8.

AStyleWx expects a Unicode, non-Monolithic build. This is the default for WxWidgets 3.0 and higher and is usually the default for the Linux wxWidgets installation packages.

Linux

On Linux, wxWidgets is available as installation packages. AStyleWx will work with the available packages if wxWidgets 3.0 or higher is used. You can install both versions 2.8 and 3.0 on the same system. Both the development packages and the run-time packages should be installed.

The Linux compiles use the wx-config script for information about wxWidgets. The default release is used unless another is requested. Install locations, as well as compiler and linker options, are also obtained from the script.

To display the default release:

wx-config --release

To display a list of all installed releases:

wx-config --list

To display the compiler options:

wx-config --cflags

To display the linker options:

wx-config --libs

To get a list of other options:

wx-config --help
UPDATE ALTERNATIVES

If more than one wxWidgets distribution is installed, the default distribution to use for compiles can be selected with the Linux update-alternatives utility. Changing the default requires administrative privileges. Use the command "update-alternatives" with the appropriate options.

NOTE: Some Linux distributions do not support update-alternatives. There are AStyleWx project options available that will allow changing from the default distribution. These are described in the following Linux Compiles sections.

To change the wxWidgets distribution with update-alternatives (using administrative privileges):

update-alternatives  --config  wx-config

A menu will be displayed showing the installations for selection. Select the number of the desired installation.

Compile options are also available for changing the wxWidgets installation used as described in the CodeBlocks Linux, CMake Linux, and Other Makefile Options sections.

MacOS

Use wxWidgets 3.1 or higher. Previous versions did not work with C++11. For MacOS it must be compiled and installed from the source code. Download the source for Linux and MacOS. Do NOT use a Windows download. It will have the wrong line endings which will cause problems.

Build the library for cocoa. Install instructions are in wxWidgets docs/osx. Either Xcode or the command line tools may be used. The Xcode install did NOT do a complete install with the tested release. The command line tools were the better choice. The AStyleWx compiles are built with wxWidgets STATIC libraries from the default install folders.

For AStyleWx, wxWidgets must be compiled as C++11. Building with C++11 requires additional options. The following instructions worked on a macOS 10.12 Sierra with wxWidgets 3.1.0. Other possible configure flags are at http://wiki.wxwidgets.org/Possible_Configure_Flags_under_OS_X

NOTE: The following configure statement is three lines long for readability. It should be entered as one line. The files are built as static libraries (disable-shared). The option gnu++11 MUST be used instead of c++11 or linker errors will occur. The minimum deployment is macOS 10.9 Mavericks. In the following example, the Clang compiler is used instead of the default GCC.

To build and install static libraries using the command line:

cd wxWxdgets-3.1.0
mkdir build-release
cd build-release
../configure  --disable-shared  -with-macosx-version-min=10.9  CC=clang  CXX=clang++ \
CXXFLAGS="-std=gnu++11 -stdlib=libc++"  OBJCXXFLAGS="-std=gnu++11 -stdlib=libc++" \
LDFLAGS="-stdlib=libc++"
make
sudo make install

NOTE: An error may occur when compiling and installing QTKit. If it does, just re-execute the make using the additional option --ignore-errors e.g. "make --ignore-errors". The make will continue from that point. The project that does not compile is not needed.

The Artistic Style Wx compiles use the "wx-config" script for information about wxWidgets. The default release is used unless another is requested. Install locations, as well as compiler and linker options, are also obtained from the script. A brief description of the script is in the wxWidgets Linux description.

Visual Studio

There are Visual Studio solution files for wxWidgets releases in the wxWidgets build\msw folder. All of the configurations and platforms in the wxWidgets solution files are supported by AStyleWx. Just open the appropriate solution file for your Visual Studio version and compile the configurations and platforms you want. The outputs will be in the various wxWidgets "lib" folders.

The wxWidgets website has binary DLLs available for download. These were not used because the wxWidgets static libraries are not included. The binary DLLs can be used for the DLL files if you want, but the AStyleWx properties will need to be changed to the correct directories. The binaries are apparently compiled with the options OFFICIAL_BUILD, COMPILER_VERSION, and TARGET_CPU (and possibly others) while the solution file compiles are not. The properties that require changing are "C/C++ > General > Additional Include Directories" and "Linker > General > Additional Library Directories". This may change, of course, with later versions.

Compiling wxWidgets 3.0.2 with Visual Studio 2015 requires making changes to the wxWidgets source files. A description of the solution is at https://forums.wxwidgets.org/viewtopic.php?f=19&t=40491. Use the reply by doublemax tagged as [SOLVED]. These changes are NOT needed for wxWidgets 3.1.0 and higher.

AStyleWx has a "static" build which is not available with the wxWidgets solutions. The Visual Studio wxWidgets project files can be modified by using the procedure described in the AStyleWx documentation Visual Studio Static Compile.

Other Windows Compilers

Other Windows compilers will need to use the makefiles in the wxWidgets build\msw folder. With wxWidgets 3 you can use the default options with the following exceptions. To build the wxWidgets static libraries no additional options are needed. To build the wxWidgets DLLs the option SHARED=1 should be used.

Some compilers require compiling wxWidgets with C++11. If you need to compile with C++11, there is an important note in wxWidgets docs\msw\install.txt. Use ‑std=gnu++11 instead of ‑std=c++11 because the latter disables some extensions that wxWidgets relies on. If this is not done the linker will fail with undefined references. ‑Wno-deprecated-declarations may also be needed to eliminate unwanted warning messages.

To build wxWidgets DLLs with the TDM GCC compiler:

cd build\msw
mingw32-make -f makefile.gcc SHARED=1 CXXFLAGS="-std=gnu++11 -Wno-deprecated-declarations"

Linux Compiles

Linux Library Runtime Error

When using libraries like wxWidgets there is a possibility that the library has been compiled with a different version of a compiler than is used on your computer. You may get a runtime error of "Mismatch between the program and library build versions detected". The error message will also give the ABI for the library and the ABI for the program. The ABI indicates the exception handling version of the compiler.

Since AStyleWx does not use exceptions this error can be ignored. Add the preprocessor definition __GXX_ABI_VERSION=### to the compiler variables, replacing ### with the library ABI given in the error message. Rebuild the project. It should compile and run without error.

CodeBlocks Linux

There are build folders for the following compilers. All compiler folders are in the "build" directory.

There are workspace and project files in each folder. All projects have at least Debug and Release configurations. The compiles will link to the wxWidgets shared object libraries. All output will be in the "bin" directory.

The following workspace files are available.

If more than one wxWidgets distribution is installed the default distribution to used. To change the default distribution use update-alternatives as described in Linux wxWidgets Compiles. It can also be changed using the project file's "Custom Variables" option.

USING UPDATE-ALTERNATIVES
USING PROJECT FILES

In the CodeBlocks menu select Project > Build Options, Custom Variables, and select the project name at the top. The variables apply to all targets. The variable values must correspond to an installed wxWidgets distribution available in wx-config. WX indicates the wxWidgets version to use. Use the major and minor version number separated by a dot (e.g. 3.1). If it is not specified the version of the default distribution is used. TK indicates the graphical toolkit to use. The valid entries are gtk2 or gtk3. If it is not specified the toolkit of the default distribution is used. Invalid WX or TK values will get compile errors for "No such file or directory".

CMake Linux

A CMake "out of source" build should be used for the different compile configurations. The default build is a release version. A debug version must be specifically requested.

Artistic Style Wx has CMake support for the GCC, Clang, and Intel compilers. Other compilers will probably work if the necessary options are set. To use a compiler other than GCC the CXX environment variable must be set to the name of the compiler. This is done before calling cmake.

If more than one wxWidgets distribution is installed the default distribution to used. The best way to change the default distribution is to use update-alternatives as described in Linux wxWidgets Compiles. It can also be changed using variable definitions when cmake is executed. The variable values must correspond to an installed wxWidgets distribution available in wx-config. The following variable definitions are available.

The standard cmake options can be used in the cmake or make commands. For example, for verbose compiler output use ‑DCMAKE_VERBOSE_MAKEFILE=ON with cmake or VERBOSE=1 with make.

EXAMPLES

The following examples are assumed to be run from the astyle directory that contains CMakeLists.txt. They show out of source builds that generate makefiles.

To build the GCC release version:

mkdir  aswx-gcc
cd  aswx-gcc
cmake  ../
make

To build the debug version using the Clang compiler:

mkdir  aswx-clang
cd  aswx-clang
CXX=clang++  cmake  -DCMAKE_BUILD_TYPE=Debug  ../
make

To change the wxWidgets distribution and GTK toolkit using the Intel compiler:

mkdir  aswx-intel
cd  aswx-intel
CXX=icpc  cmake  -DWX=3.1  -DTK=gtk3  ../
make
INSTALL

There is no install or uninstall. This should be done manually.

GCC Makefile

The build has no autoconf dependency. To build the AStyleWx configurations use the makefile located in the astylewx/build/gcc directory. The executables will be in the astylewx/build/gcc/bin directory. The Artistic Style source is included in the AStyleWx compile but not in the AStyleWxSo compile.

To build Artistic Style Wx change to the astylewx build/gcc directory. Before the first compile the deps.mak file should be regenerated to assure the correct version of wxWidgets headers is being used. It is regenerated using the "deps" target in the makefile. Wait for it to finish before doing the make.

cd astylewx/build/gcc
make deps
make

To build the other astylewx configurations you can enter the file name or a symbolic name. Entering "make astylewx" or "make release" will build the command line configuration. Following are the symbolic names and file names (in parens) of the various configurations:

More than one configuration can be built at the same time. For example, to build all the release and shared configurations enter:

cd astyle/build/gcc
make release shared

The Makefile Shared Libraries section contains additional information on compiling to use an astyle shared library. The Other Makefile Options and Other Makefile Targets sections contain additional compile and target options.

Clang Makefile

The build has no autoconf dependency. To build AStyleWx use the makefile located in the astyle/build/clang directory. The executables will be in the astyle/build/clang/bin directory. The Artistic Style source is included in the AStyleWx compile.

To build Artistic Style Wx change to the astylewx/build/clang directory. Before the first compile the deps.mak file should be regenerated to assure the correct version of wxWidgets headers is being used. It is regenerated using the "deps" target in the makefile. Wait for it to finish before doing the make.

cd astylewx/build/clang
make deps
make

The Makefile Shared Libraries section contains additional information on compiling to use an astyle shared library. The Other Makefile Options and Other Makefile Targets sections contain additional compile and target options.

Intel Makefile

These procedures and the makefile are for recent versions of the compiler. They may not work for earlier versions. Instructions for your compiler are in the compiler documentation file "get_started_lc.htm".

To compile the source there are environment variables that must be set by running the compiler environment script compilervars.sh (or compilervars.csh) with an argument that specifies the target architecture. If this has not been done already enter: "source  <install-dir>/bin/compilervars.sh <arg>", where <install-dir> is the directory where the compiler is installed and <arg> is ia32 or intel64. If this is not done "make" will display an error message. On an Intel x64 platform installed in the default directory the instruction would be

source /opt/intel/bin/compilervars.sh intel64

The build has no autoconf dependency. To build AStyleWx use the makefile located in the astyle/build/intel directory. The executables will be in the astyle/build/intel/bin directory. The Artistic Style source is included in the AStyleWx compile.

To build Artistic Style Wx change to the astylewx/build/intel directory. Before the first compile the deps.mak file should be regenerated to assure the correct version of wxWidgets headers is being used. It is regenerated using the "deps" target in the makefile. Wait for it to finish before doing the make.

cd astylewx/build/intel
make deps
make

The Makefile Shared Libraries section contains additional information on compiling to use an astyle shared library. The Other Makefile Options and Other Makefile Targets sections contain additional compile and target options.

Makefile Shared Libraries

To build the AStyleWxSo program an AStyle shared library must be compiled using the AStyle makefile. AStyleWxSo, the compile using the AStyle dynamic library, uses the compiler directive ASTYLE_DYLIB. This does a dynamic load of the AStyle library at runtime, it is NOT linked during the compile. This will allow it to ignore the library soname version while loading. The shared library can either be left in the AStyle folder or copied to the binary folder containing the AStyleWxSo executable. (It may be in any of the folders indicated by the rpaths options in the AStyleWx makefile). If no library is found a message will be displayed a runtime, not compile time.

The shared library compile expects to use the current AStyle library as a local library. If you have system libraries installed and want to use them, the makefile needs to be changed. Find the Makefile macro "$(rpaths)" in the linker command and change it to "‑lastyle". The instruction for the default build should be changed in a similar manner. When this is done the compile will link to the most current system library.

Other Makefile Options

The following additional compile options are available for GCC, Clang, Intel, and MacOS.

WX=
WX=3.1

To compile with a wxWidgets release other than the default use the WX option. For example, if both releases 3.0 and 3.1 are installed, using WX=3.1 will compile with wxWidgets release 3.1. The variable values must correspond to an installed wxWidgets distribution available in wx-config. This option may be used with makefile compile and install commands.

TK=
TK=gtk3

To compile with a GTK toolkit other than the default use the TK option. For example, if a wxWidgets release has both gtk2 and gtk3 installed, using TK=gtk3 will compile with the gtk3 toolkit. The variable values must correspond to an installed wxWidgets distribution available in x-config. This option may be used with makefile compile and install commands.

CFLAGS

To add additional compiler options use CFLAGS. The options should be enclosed in quotes if spaces are included.

LDFLAGS

To add additional linker options use LDFLAGS. The options should be enclosed in quotes if spaces are included.

TESTMODE1

This is used in CFLAGS to bypass AStyleWx warning messages when changed files have not been saved. Its purpose is to make testing more convenient. It is not intended to be used in a release configuration. To use the option enter CFLAGS="‑DTESTMODE1".

Other Makefile Targets

The following additional makefile targets are available.

clean

Removes the object and executable files for all configurations.

To remove the files for all configurations:

make clean
cleanobj

Removes the object files for all configurations. The executables will not be removed.

To remove only the object files for all configurations:

make cleanobj
install

Installs the AStyleWx executable and documentation files. The default is /usr/bin for the executable and /usr/share/doc/astylewx for the documentation. You must have the appropriate permissions to use install.

To install AStyleWx to the default directories:

sudo make install

To install AStyleWx to a different directory, set a value for the macro $(prefix). For example, to install the executable to a user's home directory (/home/user/bin):

sudo make prefix=$HOME install
uninstall

Uninstalls the executable and documentation. You must have the appropriate permissions to use uninstall.

To uninstall AStyleWx from the default directories:

sudo make uninstall

To uninstall the files from a different directory set a value for the macro $(prefix). For example, to uninstall the files from a user's home directory (/home/user):

sudo make prefix=$HOME uninstall

NOTE: The uninstall option will NOT remove the ".astylewx" configuration files from the user's home directory. The files must be removed individually for each user.

MacOS Compiles

Xcode

AStyleWx workspace and project files for the Xcode development environment are available in the "build/xcode" directory. AStyleWx links AStyle as a static library.

The project files have Debug and Release configurations. The following projects are available in the AStyleWx workspace.

The following projects are available in the AStyleWxDy workspace.

Xcode cannot use the wx-config file like the makefile compile. The information for wxWidgets headers and libraries must be entered into Xcode. There is information at on doing this at wxWidgets Creating Xcode 3 projects for wxWidgets applications. A description of the process follows.

Display the wx-config default release as described in Linux wxWidgets Compiles.

Check the following settings for the wxWidgets release you want to use:

  1. In the Xcode Build Settings, navigate to Search Paths and find Header Search Paths. Change the wxWidgets version numbers if they are not correct.
  2. In the Xcode Build Settings, navigate to Linking and find Other Linker Flags. Change the wxWidgets version numbers if they are not correct.

Build and run the program as usual from Xcode. The linker should be able to find the correct static libraries for the wxWidgets version. If there are linker errors check the wx-config settings above.

install

The following instructions are for the AStyleWx applications. The app will be installed in the Applications directory. You must have the appropriate permissions to use install.

To install AStyleWx app to the tmp/AStyleWx.dst/Applications directory:

cd astylewx/build/xcode
sudo xcodebuild install -project AStyleWx.xcodeproj -target AStyleWx

CodeBlocks MacOS

The AStyleWx folder build/cb-mac has workspace and project files for macOS. They are used the same as CodeBlocks Linux except the only supported compiler is Clang and they link to static instead of shared wxWidgets libraries. The wx-config file is used for the compiles. The WX option is available if more than one wxWidgets version is installed. The TK option is NOT used since only one graphical toolkit is available, osx_cocoa.

CMake MacOS

Artistic Style Wx has CMake support for MacOS. It is used the same as CMake Linux except the supported compilers are only GCC and Clang.

MacOS Makefile

The build has no autoconf dependency. To build the AStyleWx configurations use the makefile located in the astylewx/build/mac directory. The executables will be in the astylewx/build/mac/bin directory. The Artistic Style source is included in the AStyleWx compile.

To build Artistic Style Wx change to the astylewx build mac directory. Before the first compile the deps.mak file should be regenerated to assure the correct version of wxWidgets headers is being used. It is regenerated using the "deps" target in the makefile. Wait for it to finish before doing the make.

cd astylewx/build/mac
make deps
make

To build the other astylewx configurations you can enter the file name or a symbolic name. Entering "make astylewx" or "make release" will build the command line configuration. Following are the symbolic names and file names (in parens) of the various configurations:

More than one configuration can be built at the same time. For example, to build all the release configurations enter:

cd astyle/build/mac
make release debug

The Other Makefile Options and Other Makefile Targets sections contain additional compile and target options. They are the same as for Linux makefiles.

Windows Compiles

Precompiled Executable

In addition to the source files, the Windows distribution package contains an Artistic Style Win32 executable (AStyle.exe). If you prefer to compile the executable yourself use the following instructions.

Visual Studio

To compile AStyleWx the wxWidgetsMacros.props files must be changed. The files are located in the build\vs... folders. The easiest way to change them is to open the props file in a text editor. Then change the "WXWIN"" field to the location of the wxWidgets directory on your system. The "wxVersion" field will need to be changed if it does not contain the correct wxWidgets two digit version.

The "wxWidgetsMacros.props" files can also be changed from the "Properties Editor" in Visual Studio. An AStyleWx solution must be open. Open the "Property Manager" window from the View menu. Open a configuration in the Property Manager, right click on "wxWidgets Macros", and select "Properties". Under "Common Properties" select "User Macros". The "WXWIN" and "wxVersion" macros values will be displayed. They can be changed by double-clicking on the field name. Change the macro value to the correct value for your system and press OK. This will change the macros for all configurations. The properties file needs to be saved before closing the solution.

The following solution files are available.

All projects have the following configurations available for Win32 and x64 platforms.

To compile a configuration, the corresponding library files must be available in the wxWidgets directory. All library file compiles are available in the wxWidgets solution files except the Static compile. If the Static compile is not needed it can be removed from the configurations. If you want to try compiling it the procedure described in the AStyleWx documentation Visual Studio Static Compile.

CodeBlocks Windows

There are build folders for the following compilers. All compiler folders are in the "build" directory.

There are workspace and project files for each compiler. All projects have at least Debug and Release configurations. Output will be in the "bin" directory.

The following workspace files are available.

To compile AStyleWx the project file's "Custom Variables" options must be changed. In the menu select Project > Build Options, Custom Variables, and select the project name at the top. The variables apply to all targets. All of the variables must be changed to the correct values.

CMake Windows

Artistic Style Wx has CMake support for the MinGW compiler only.

Since the different builds use the same source files an "out of source" build should be used. The default build for MinGW is a release version. A debug version must be specifically requested.

The build can get compile information from the following optional variables passed to CMake.

EXAMPLES

The following examples are assumed to be run from the directory that contains CMakeLists.txt. They show out of source builds that generate makefiles.

A path to the compiler executable may need to be declared before compiling. To set the variables before compiling, replace the following path name with the path on your computer.

set PATH=C:\Program Files\CMake\bin;%PATH%

To build the MinGW release version using static libraries:

md  aswx-mingw
cd  aswx-mingw
cmake  -G "MinGW Makefiles"  -DWXWIN="C:/Programs/wxWidgets-3.0.2_mingw"  ../
mingw32-make

To build the MinGW debug version using shared libraries:

md  aswx-mingw
cd  aswx-mingw
cmake  -G "MinGW Makefiles"  -DCMAKE_BUILD_TYPE=Debug  -DWXSHARED=ON  ../
mingw32-make
INSTALL

There is no install or uninstall. This must be done manually.

Other Compilers

To use other compilers a project file must be built using an editor or development environment.

The AStyle source can also be compiled as a separate static library and linked to the AStyleWx compile.

Compiler Options

To compile AStyle as a static or shared (dynamic) library define the macro ASTYLE_LIB. To compile a Java shared (dynamic) library define the macro ASTYLE_JNI. The option ASTYLE_NO_EXPORTS is sometimes needed for static libraries to prevent compiler error and warning messages. Use the appropriate compiler and linker options to compile the static or shared library. Add debug options to compile the debug versions.

Artistic Style Wx has two compiler options. ASTYLE_DYLIB uses the wxWidgets wxDynamicLibrary Class to load an AStyle dll at runtime. The AStyle library is NOT linked with AStyleWx. It is loaded at runtime and must be available where expected. The TESTMODE1 option can be used with debug builds of AStyleWx. It removes confirmation messages for file saves and adds a "Test Options" dialog box to the Tools menu. It cannot be used with release builds.

Artistic Style is a small program and it is best to optimize for speed. The debug configurations are not usually optimized. To optimize for speed in the release configurations, use the macro NDEBUG to remove asserts. If necessary, use an option to activate the C++11 standards (--std=c++11 on GCC and MinGW). Use an option that allows inline function expansion. Runtime Type Information (RTTI) is NOT needed. Exceptions are not used. Use whole program optimization if your compiler supports it. There may be other options you can use depending on the compiler.