开发者

Class based on wxObject fails to link

开发者 https://www.devze.com 2023-03-29 15:59 出处:网络
First, this is being built on Linux. We have an API that is based on wxObjects (we do not use the GUI objects). Our classes are defined as follows:

First, this is being built on Linux.

We have an API that is based on wxObjects (we do not use the GUI objects). Our classes are defined as follows:

#include <wx/wx.h>

class apibaseclass : public wxObject
{
    apibaseclass();
    ~apibaseclass();
}

About five years ago this compiled and linked just fine. 开发者_如何学GoI've been asked to make changes and now I get the following error:

undefined reference to wxObject::wxObject()'/home/lloyd/Projects/wxtestprogram/main.cpp:7: undefined reference towxObject::wxObject()'

This is the program I was using as a sanity test:

#include <iostream>
#include <wx/wx.h>

class blah : public wxObject
{
public:
int x;

blah();
virtual ~blah();

void setvalue(int value);
int getvalue();
};

blah::blah()
{
}


blah::~blah()
{
}

void blah::setvalue(int value)
{
    x = value;
}

int blah::getvalue()
{
    return x;
}


using namespace std;

int main()
{
    class blah *testvalue = new blah();

    testvalue->setvalue(15);

    wxPrintf(wxT("Hello World 2 %d\r\n"), testvalue->getvalue());

    wxString str1 = wxT("Linux");

    wxString str2 = wxT("Operating");

    wxString str3 = wxT("System");

    wxString str;
    str = str1 + wxT(" ") + str2 + wxT(" ") + str3;

    wxPuts(str);
    wxPrintf(wxGetHomeDir());


    long int mem = wxGetFreeMemory();

    wxPrintf(wxT("Memory: %ld\n"), mem);
    return 0;
}

What is bothersome is that if I replace "public wxObject" with "public wxString" then it links just fine. Why am I unable to access wxObject?!?

NOTE: I've never linked against anything other than libwx_baseu-2.6.so in the past. And in fact when I build without the GUI it only builds libwx_baseu-2.6, libwx_baseu_net-2.6 and libwx_baseu_xml-2.6.

What do I need to do to get things building and LINKING again with minimal muss and fuss?


Using

wx-config --cxxflags --libs base 

gave me the missing items that allowed me to build the project correctly. No doubt this is what I used five years ago.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号