Error compiling Audacity 2.3.2: invalid use of incomplete type ‘class wxTreeCtrl’ [SOLVED]

Hello, I’m trying to build Audacity from source, and I’m getting an “invalid use of incomplete type” error during compilation. I would be grateful for any pointers. Please let me know if I need to provide more details.

OS: Pop!_OS 19.04 (a flavor of Ubuntu)
Compiler: g++ 8.3.0
wxWidgets: 3.1.2 (compiled with --with-gtk=3)

./configure CXXFLAGS="-std=gnu++11" --with-lame --with-ffmpeg
make

The make command stops with these messages:

prefs/PrefsDialog.cpp: In constructor ‘PrefsDialog::PrefsDialog(wxWindow*, const wxString&, PrefsDialog::Factories&)’:
prefs/PrefsDialog.cpp:556:36: error: invalid use of incomplete type ‘class wxTreeCtrl’
          mCategories->GetTreeCtrl()->SetName(_("Category"));
                                    ^~
In file included from /usr/local/include/wx-3.1/wx/treebook.h:20,
                 from prefs/PrefsDialog.cpp:35:
/usr/local/include/wx-3.1/wx/treebase.h:57:35: note: forward declaration of ‘class wxTreeCtrl’
 friend class WXDLLIMPEXP_FWD_CORE wxTreeCtrl;
                                   ^~~~~~~~~~
prefs/PrefsDialog.cpp:625:33: error: invalid use of incomplete type ‘class wxTreeCtrl’
       mCategories->GetTreeCtrl()->EnsureVisible(mCategories->GetTreeCtrl()->GetRootItem());
                                 ^~
In file included from /usr/local/include/wx-3.1/wx/treebook.h:20,
                 from prefs/PrefsDialog.cpp:35:
/usr/local/include/wx-3.1/wx/treebase.h:57:35: note: forward declaration of ‘class wxTreeCtrl’
 friend class WXDLLIMPEXP_FWD_CORE wxTreeCtrl;
                                   ^~~~~~~~~~
prefs/PrefsDialog.cpp:625:75: error: invalid use of incomplete type ‘class wxTreeCtrl’
       mCategories->GetTreeCtrl()->EnsureVisible(mCategories->GetTreeCtrl()->GetRootItem());
                                                                           ^~
In file included from /usr/local/include/wx-3.1/wx/treebook.h:20,
                 from prefs/PrefsDialog.cpp:35:
/usr/local/include/wx-3.1/wx/treebase.h:57:35: note: forward declaration of ‘class wxTreeCtrl’
 friend class WXDLLIMPEXP_FWD_CORE wxTreeCtrl;
                                   ^~~~~~~~~~
make[2]: *** [Makefile:6316: prefs/audacity-PrefsDialog.o] Error 1
make[2]: Leaving directory '/home/eduardo/src/audacity/src'
make[1]: *** [Makefile:1656: all] Error 2
make[1]: Leaving directory '/home/eduardo/src/audacity/src'
make: *** [Makefile:812: all-recursive] Error 1

Audacity requires gtk2.

Thank you. I will rebuild wxWidgets and try again.

I recompiled wxWidgets 3.1.2 using --with-gtk=2 (had to install libgtk2.0-dev package).

I then went to the audacity build folder, and did a make clean; then:

$ ./configure CXXFLAGS="-std=gnu++11" --with-lame --with-ffmpeg

After a while, configure failed with these errors:

=== configuring in lib-src/libsoxr (/home/ek/src/audacity/lib-src/libsoxr)
configure: running /bin/bash ./configure --disable-option-checking '--prefix=/usr/local/'  'WX_CONFIG=/home/ek/src/wxWidgets-3.1.2/buildgtk/wx-config' 'CXXFLAGS=-std=gnu++11' '--with-lame' '--with-ffmpeg' '--with-wx-config=/home/ek/src/wxWidgets-3.1.2/buildgtk/wx-config' '--enable-static=yes' '--enable-shared=no' '--disable-xmms-plugin' '--disable-doxygen-docs' '--disable-thorough-tests' '--disable-programs' '--disable-sqlite' '--disable-external-libs' '--disable-alsa' '--disable-programs' '--disable-programs' '--disable-oggtest' 'OGG_CFLAGS=-I/home/ek/src/audacity/lib-src/libogg/include -I/home/ek/src/audacity/./lib-src/libogg/include' 'OGG_LIBS=/home/ek/src/audacity/lib-src/libogg/src/libogg.la' '--with-ogg-includes=/home/ek/src/audacity/lib-src/libogg/include -I/home/ek/src/audacity/./lib-src/libogg/include' '--with-ogg-libraries=/home/ek/src/audacity/lib-src/libogg/src/.libs' 'PORTAUDIO_CFLAGS=-I/home/ek/src/audacity/./lib-src/portaudio-v19/include' 'PORTAUDIO_LIBS=/home/ek/src/audacity/./lib-src/portaudio-v19/lib/libportaudio.la' --cache-file=/dev/null --srcdir=.
-- Configuring done
CMake Error: Cannot determine link language for target "1a-lsr".
CMake Error: CMake can not determine linker language for target: 1a-lsr
CMake Error: Cannot determine link language for target "3-options-input-fn".
CMake Error: CMake can not determine linker language for target: 3-options-input-fn
-- Generating done
-- Build files have been written to: /home/ek/src/audacity/lib-src/libsoxr
configure: error: ./configure failed for lib-src/libsoxr

I don’t understand why changing to wxWidgets with GTK2 would make cmake no longer know how to link files in this folder. Any ideas of what could be wrong?

Do you know which version of Ubuntu it is based on?

I wrote step by step instructions for building on Ubuntu 18.04 here: https://forum.audacityteam.org/t/building-audacity-2-3-1-on-ubuntu-18-04/52255/1

Pop!_OS should just be Ubuntu with some extras, so the equivalent Ubuntu version should be 19.04.

It should not be all that different from Ubuntu 18.04. I will try to follow your instructions exactly and see what happens.

The only reason I am trying to build from source is that Audacity 2.2.2 is what I get from the repository, and it is extremely cumbersome to use for heavy editing, as every time you do anything such as applying an effect, etc., takes the focus away from the current track (even if there is only one), and clicking on the track to get the focus back makes you lose the place where you were editing. I was hoping that this would be a bug (the same or similar to https://forum.audacityteam.org/t/how-to-lock-track-focus/51575/1) that might have been resolved since 2.2.2.

First of all, thank you for your help.

Second, your instructions at https://forum.audacityteam.org/t/building-audacity-2-3-1-on-ubuntu-18-04/52255/1 work fine, both on a fresh install of Ubuntu 19.04, and Pop!_OS 19.04.

In case this helps anyone else, building wxWidgets from source is neither necessary nor advisable. I ran into all kinds of trouble because of this. Even when I eventually did a sudo make uninstall in the wxWidgets build folder to get rid of my wxWidgets, it did not completely remove itself, and it made the Audacity configure script think wxWidgets headers were installed in /usr/local. To avoid deleting anything that might have been installed by your instructions, I ended up trying to install Pop!_OS inside Virtualbox, failing miserably, and finally successfully installing Ubuntu 19.04. Your instructions worked perfectly on a fresh install of Ubuntu 19.04. I then compared it to what I had on my host machine and manually deleted /usr/local/lib/wx and /usr/local/include/wx3.0 and everything under them; after doing that, the configure step was able to find everything in its proper place, and compilation finished with no problems.

Once again, if building on Ubuntu, everything you need is installed for you by the sudo apt-get build-dep audacity step in the instructions, so don’t try to build wxWidgets yourself.

Super :slight_smile:
I’ll close this topic as “solved”.