User:Stevethefiddle/Wx3.1
| This page documents steps to build Audacity 2.3.0 with WxWidgets 3.1.1 on Xubuntu 16.04.
|
Building WxWidgets 3.1.1
Further information about building WxWidgets on Linux can be found in wxWidgets-3.1.1/docs/gtk/.
- Download WxWidgets 3.1.1 from: https://github.com/wxWidgets/wxWidgets/releases/download/v3.1.1/wxWidgets-3.1.1.tar.bz2
- Extract the downloaded file to a convenient location. I used:
/home/user-name/Sourcecode/wxWidgets-3.1.1/
- Open a terminal in the extracted folder location
- Release build (for fastest builds, the -j switch is set to the number of processor cores)
mkdir buildgtk cd buildgtk ../configure --with-gtk make -j8 cd ..
- Debug build:
mkdir buildgtkd cd buildgtkd ../configure --with-gtk --enable-debug make -j8
Preparing Audacity
Audacity's configure files contain several references to WxWidgets 3.0. These need to be updated for 3.1.x. I simply replaced each reference to 3.0 with 3.1 (note that this will prevent Audacity building with 3.0 x).
The relevant files are (relative to the root of the Audacity source code):
- ./configure.ac
- ./lib-src/wx-wdigets-extra/configure.ac
- ./lib-src/FileDialog/configure.ac
Redefinition conflict
In MemoryX.h, the following code clashes with WxWidgets 3.1:
// For using std::unordered_map on wxString
namespace std
{
#ifdef __AUDACITY_OLD_STD__
namespace tr1
{
#endif
template<typename T> struct hash;
template<> struct hash< wxString > {
size_t operator () (const wxString &str) const // noexcept
{
auto stdstr = str.ToStdWstring(); // no allocations, a cheap fetch
using Hasher = hash< decltype(stdstr) >;
return Hasher{}( stdstr );
}
};
#ifdef __AUDACITY_OLD_STD__
}
#endif
}
For my initial test build, I simply commented it out, but see note from James (directly below):
James suggested a better alternative, to make the template conditional as below:
// For using std::unordered_map on wxString
namespace std
{
#ifdef __AUDACITY_OLD_STD__
namespace tr1
{
#endif
#if !wxCHECK_VERSION(3, 1, 0)
template<typename T> struct hash;
template<> struct hash< wxString > {
size_t operator () (const wxString &str) const // noexcept
{
auto stdstr = str.ToStdWstring(); // no allocations, a cheap fetch
using Hasher = hash< decltype(stdstr) >;
return Hasher{}( stdstr );
}
};
#endif
#ifdef __AUDACITY_OLD_STD__
}
#endif
}
Regenerate automake files
I used:
autoreconf -ivf
Though James wrote that it was sufficient to just:
autoreconf -i
Build debug version of Audacity
The following commands are relative to the root of the Audacity source:
mkdir build cd build mkdir "Portable Settings" ../configure WX_CONFIG=/home/steve/Sourcecode/wxWidgets-3.1.1/buildgtkd/wx-config CXXFLAGS="-std=gnu++11" --with-lib-preference="local system" --with-ffmpeg="system" --disable-dynamic-loading --enable-debug make -j8
All of the configure options above may not be necessary, though if (as in the steps above) WxWidgets 3.1.1 is NOT intalled, the option WX_CONFIG= MUST be included.
For fastest building, the -j option should be set to the number of CPU cores.
For fastest building, the -j option should be set to the number of CPU cores.