基于wxObject的类无法链接
首先,这是在 Linux 上构建的。
我们有一个基于 wxObjects 的 API(我们不使用 GUI 对象)。我们的类定义如下:
#include <wx/wx.h>
class apibaseclass : public wxObject
{
apibaseclass();
~apibaseclass();
}
大约五年前,这个编译和链接得很好。我被要求进行更改,现在出现以下错误:
对 wxObject::wxObject()'/home/lloyd/Projects/wxtestprogram/main.cpp:7 的未定义引用:未定义的引用
wxObject::wxObject()'
这是我用作健全性测试的程序:
#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;
}
令人烦恼的是,如果我用“public wxString”替换“public wxObject”,那么它链接得很好。为什么我无法访问wxObject?!?
注意:过去我从未链接过除 libwx_baseu-2.6.so 之外的任何内容。事实上,当我在没有 GUI 的情况下构建时,它只构建 libwx_baseu-2.6、libwx_baseu_net-2.6 和 libwx_baseu_xml-2.6。
我需要做什么才能以最少的混乱和麻烦再次构建和链接?
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. I'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 to
wxObject::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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用
给了我缺少的项目,使我能够正确构建项目。毫无疑问,这是我五年前使用的。
Using
gave me the missing items that allowed me to build the project correctly. No doubt this is what I used five years ago.