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.
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
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. For Artistic Style Wx version 3.0 it must be compiled as C++11. 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.
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 https://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. 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.
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 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"
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 main "wx" programs will link to the wxWidgets shared object libraries. All output will be in the "bin" directory.
The following workspace files are available.
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 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.
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.
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.
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.
The following additional compile options are available for GCC, Clang, Intel, and MacOS.
wx=3.0
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.0" will compile with wxWidgets release 3.0. This option may be used with compile and install commands.
To add additional compiler options use CFLAGS. The options should be enclosed in quotes if spaces are included.
To add additional linker options use LDFLAGS. The options should be enclosed in quotes if spaces are included.
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".
The following additional makefile targets are available.
Removes the object and executable files for all configurations.
To remove the files for all configurations:
make clean
Removes the object files for all configurations. The executables will not be removed.
To remove only the object files for all configurations:
make cleanobj
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
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.
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:
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.
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
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.
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.
There are build folders for the following compilers. All compiler folders are in the "build" directory.
There are workspace and project files for each folder. All projects have at least Debug and Release configurations. All output will be in the "bin" directory.
The following workspace files are available.
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 files 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 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.
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.
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.