wxAnimationCtrl linker errors

Do you have a question about makefiles, a compiler or IDE you are using and need to know how to set it up for wxWidgets or why it doesn't compile but other IDE's do ? Post your questions here.
Post Reply
MrBurgerAt
In need of some credit
In need of some credit
Posts: 2
Joined: Wed Apr 10, 2019 6:57 pm

wxAnimationCtrl linker errors

Post by MrBurgerAt » Wed Apr 10, 2019 8:20 pm

Hello,

I really hope that you can help me with a problem that I am facing with wxWidgets.

Currently, I am developing an application that could use a throbber (e.g. a wxAnimationCtrl), because there is a heavy loading operation that needs to be communicated to users. I am unable to succeed in adding such an object to a window, because I consistently get linker errors for which I could not find a solution (compiler stage is fine).

Here's a minimal example of what I am trying to do. It simply contains a frame with a wxAnimationCtrl instance that is created by a wxApp instance, nothing much (as in the anitest.cpp from the samples I intended to use wxAnimationCtrl::LoadFile to then set the animation in this control):

Code: Select all

#include <wx/animate.h>
#include <wx/app.h>
#include <wx/frame.h>
#include <wx/sizer.h>

#if !wxUSE_ANIMATIONCTRL
    #error Cannot compile this sample if wxAnimationCtrl is not enabled
#endif

class MinimalFrame : public wxFrame
{
public:

    MinimalFrame() : wxFrame(nullptr, wxID_ANY, "wxAnimCtrlMinimal", {640, 480}) 
    {
        auto AnimCtrl = new wxAnimationCtrl(this, wxID_ANY); 

        auto RootSizer = new wxBoxSizer(wxVERTICAL); 
        RootSizer->Add(AnimCtrl, 0, 0); 
        SetSizer(RootSizer); 
    }

    virtual ~MinimalFrame() { /**/ }
};

class MinimalApp : public wxApp
{
public:

    virtual bool OnInit() override
    {
        auto Frame = new MinimalFrame();
        Frame->Show(true);

        return true;
    }
};

IMPLEMENT_APP(MinimalApp)
The build system I am forced to use is CMake, so here is a minimal CMakeLists.txt:

Code: Select all

cmake_minimum_required(VERSION 3.0)
set(CMAKE_CXX_STANDARD 14)
project(wxAnimCtrl-LinkerError CXX)

# wxWidgets
# Use: target_link_libraries(${PROJECT_NAME} ${wxWidgets_LIBRARIES})
find_package(wxWidgets COMPONENTS core base REQUIRED)
include(${wxWidgets_USE_FILE})

add_executable(wxAnimCtrl-LinkerError main.cpp)
target_link_libraries(wxAnimCtrl-LinkerError ${wxWidgets_LIBRARIES})
To reproduce the problem I just need to do the following. In a first step I create a build directory, and use CMake to produce a makefile. Its output contains the version I am running (wx_gtk2u 3.0.4), which I likely installed with a packet-manager at some point in the past:

Code: Select all

> mkdir -p build
> cd build
> cmake ..
-- The CXX compiler identification is GNU 7.3.0
-- Check for working CXX compiler: /usr/bin/g++
-- Check for working CXX compiler: /usr/bin/g++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found wxWidgets: -L/usr/lib/x86_64-linux-gnu;-pthread;;;-lwx_gtk2u_core-3.0;-lwx_baseu-3.0 (found version "3.0.4") 
-- Configuring done
-- Generating done
-- Build files have been written to: /home/mrburger/Desktop/Tests/wxAnimControl/build
And in the build step:

Code: Select all

> make
Scanning dependencies of target wxAnimCtrl-LinkerError
[ 50%] Building CXX object CMakeFiles/wxAnimCtrl-LinkerError.dir/main.cpp.o
[100%] Linking CXX executable wxAnimCtrl-LinkerError
CMakeFiles/wxAnimCtrl-LinkerError.dir/main.cpp.o: In function 'wxAnimationCtrlBase::wxAnimationCtrlBase()':
main.cpp:(.text._ZN19wxAnimationCtrlBaseC2Ev[_ZN19wxAnimationCtrlBaseC5Ev]+0x1b): undefined reference to 'vtable for wxAnimationCtrlBase'
CMakeFiles/wxAnimCtrl-LinkerError.dir/main.cpp.o: In function 'wxAnimationCtrlBase::~wxAnimationCtrlBase()':
main.cpp:(.text._ZN19wxAnimationCtrlBaseD2Ev[_ZN19wxAnimationCtrlBaseD5Ev]+0xf): undefined reference to 'vtable for wxAnimationCtrlBase'
CMakeFiles/wxAnimCtrl-LinkerError.dir/main.cpp.o: In function 'wxAnimationCtrl::wxAnimationCtrl(wxWindow*, int, wxAnimation const&, wxPoint const&, wxSize const&, long, wxString const&)':
main.cpp:(.text._ZN15wxAnimationCtrlC2EP8wxWindowiRK11wxAnimationRK7wxPointRK6wxSizelRK8wxString[_ZN15wxAnimationCtrlC5EP8wxWindowiRK11wxAnimationRK7wxPointRK6wxSizelRK8wxString]+0x2f): undefined reference to 'vtable for wxAnimationCtrl'
main.cpp:(.text._ZN15wxAnimationCtrlC2EP8wxWindowiRK11wxAnimationRK7wxPointRK6wxSizelRK8wxString[_ZN15wxAnimationCtrlC5EP8wxWindowiRK11wxAnimationRK7wxPointRK6wxSizelRK8wxString]+0x58): undefined reference to 'wxAnimationCtrl::Init()'
main.cpp:(.text._ZN15wxAnimationCtrlC2EP8wxWindowiRK11wxAnimationRK7wxPointRK6wxSizelRK8wxString[_ZN15wxAnimationCtrlC5EP8wxWindowiRK11wxAnimationRK7wxPointRK6wxSizelRK8wxString]+0x83): undefined reference to 'wxAnimationCtrl::Create(wxWindow*, int, wxAnimation const&, wxPoint const&, wxSize const&, long, wxString const&)'
CMakeFiles/wxAnimCtrl-LinkerError.dir/main.cpp.o: In function 'MinimalFrame::MinimalFrame()':
main.cpp:(.text._ZN12MinimalFrameC2Ev[_ZN12MinimalFrameC5Ev]+0xdc): undefined reference to 'wxAnimationCtrlNameStr'
main.cpp:(.text._ZN12MinimalFrameC2Ev[_ZN12MinimalFrameC5Ev]+0x121): undefined reference to 'wxNullAnimation'
collect2: error: ld returned 1 exit status
CMakeFiles/wxAnimCtrl-LinkerError.dir/build.make:94: recipe for target 'wxAnimCtrl-LinkerError' failed
make[2]: *** [wxAnimCtrl-LinkerError] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/wxAnimCtrl-LinkerError.dir/all' failed
make[1]: *** [CMakeFiles/wxAnimCtrl-LinkerError.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
Here's the system I am using:

Code: Select all

> cat /etc/lsb-release 
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=18.04
DISTRIB_CODENAME=bionic
DISTRIB_DESCRIPTION="Ubuntu 18.04.2 LTS"

>wx-config --libs
-L/usr/lib/x86_64-linux-gnu -pthread   -lwx_gtk2u_xrc-3.0 -lwx_gtk2u_html-3.0 -lwx_gtk2u_qa-3.0 -lwx_gtk2u_adv-3.0 -lwx_gtk2u_core-3.0 -lwx_baseu_xml-3.0 -lwx_baseu_net-3.0 -lwx_baseu-3.0 
Tomorrow I will have a chance to test this on another distribution as well, and I'll update this post afterwards
If you need any further information, I'll be happy to help

DavidHart
Site Admin
Site Admin
Posts: 3820
Joined: Thu Jan 12, 2006 6:23 pm
Location: IoW, UK

Re: wxAnimationCtrl linker errors

Post by DavidHart » Wed Apr 10, 2019 9:24 pm

Hi,
find_package(wxWidgets COMPONENTS core base REQUIRED)
wxAnimationCtrl is in wxAdvanced so I suspect that line should include 'core base adv'.

Regards,

David

MrBurgerAt
In need of some credit
In need of some credit
Posts: 2
Joined: Wed Apr 10, 2019 6:57 pm

Re: wxAnimationCtrl linker errors

Post by MrBurgerAt » Thu Apr 11, 2019 6:58 am

Hello David.

yes, this fixed my problem; I completely overlooked looking at the library list
Thank you very much

Post Reply