我想使用带有gcc编译器和wxSmith的wxWidgets绘制图形。有用于添加mpWindow,mpVector等的图标,但是当我尝试对其进行编译时,它将不起作用。所以我下载了mathplot.h文件并包含了它,但是现在编译器说:
||=== Build: Debug in Lizenz_Logfile_Reader (compiler: GNU GCC Compiler) ===|
D:\Lizenz_Logfile_Reader\Lizenz_Logfile_ReaderMain.cpp||In member function 'void Lizenz_Logfile_ReaderFrame::parse()':|
D:\Lizenz_Logfile_Reader\Lizenz_Logfile_ReaderMain.cpp|187|warning: comparison between signed and unsigned integer expressions [-Wsign-compare]|
D:\Lizenz_Logfile_Reader\Lizenz_Logfile_ReaderMain.cpp|193|warning: comparison between signed and unsigned integer expressions [-Wsign-compare]|
ld.exe||cannot find -lmathplot|
||=== Build failed: 1 error(s), 2 warning(s) (0 minute(s), 3 second(s)) ===|
我搜索了互联网,发现自己自己编译了libmathplot.a,但是当我尝试时出现错误:
||=== Build: Debug in libmathplot (compiler: GNU GCC Compiler) ===|
C:\wxWidgets-3.0.2\include\wx\platform.h|183|fatal error: wx/setup.h: No such file or directory|
||=== Build failed: 1 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|
我遵循this answer in german,它说一个应该创建一个新的静态库项目,在main中添加mathplot.h和mathplot.cpp,在
wxWidgets3.0.2\include
路径中添加Project->Build Oprtions->Search
Project->Build Oprtions->Compiler
并进行编译。我还有什么需要做的吗?谢谢您的帮助。编辑:链接的答案的另一部分是也包括mathplot.cpp。
我尝试如下
Lizenz_Logfile_ReaderMain.cpp:
#include "Lizenz_Logfile_ReaderMain.h"
#include <wx/msgdlg.h>
#include <wx/textfile.h>
#include "mathplot.h"
Lizenz_Logfile_ReaderMain.h:
#ifndef LIZENZ_LOGFILE_READERMAIN_H
#define LIZENZ_LOGFILE_READERMAIN_H
#include <wx/textfile.h>
#include <wx/list.h>
#include <wx/vector.h>
#include "mathplot.h"
#include "mathplot.cpp"
然后,我得到大量关于在mathplot中重新定义的错误:
||=== Build: Debug in Lizenz_Logfile_Reader (compiler: GNU GCC Compiler) ===|
D:\Lizenz_Logfile_Reader\mathplot.cpp|15|warning: #pragma implementation for 'mathplot.h' appears after file is included [enabled by default]|
D:\Lizenz_Logfile_Reader\mathplot.cpp||In member function 'bool mpWindow::SaveScreenshot(const wxString&, int, wxSize, bool)':|
D:\Lizenz_Logfile_Reader\mathplot.cpp|2239|warning: 'bool wxImage::SaveFile(const wxString&, long int) const' is deprecated (declared at C:\wxWidgets-3.0.2\include/wx/image.h:560) [-Wdeprecated-declarations]|
D:\Lizenz_Logfile_Reader\Lizenz_Logfile_ReaderMain.cpp||In member function 'void Lizenz_Logfile_ReaderFrame::parse()':|
D:\Lizenz_Logfile_Reader\Lizenz_Logfile_ReaderMain.cpp|188|warning: comparison between signed and unsigned integer expressions [-Wsign-compare]|
D:\Lizenz_Logfile_Reader\Lizenz_Logfile_ReaderMain.cpp|194|warning: comparison between signed and unsigned integer expressions [-Wsign-compare]|
obj\Debug\Lizenz_Logfile_ReaderMain.o||In function `ZNK7mpLayer12GetClassInfoEv':|
D:\Lizenz_Logfile_Reader\mathplot.cpp|78|multiple definition of `mpLayer::GetClassInfo() const'|
obj\Debug\Lizenz_Logfile_ReaderApp.o:D:\Lizenz_Logfile_Reader\mathplot.cpp|78|first defined here|
obj\Debug\Lizenz_Logfile_ReaderMain.o||In function `ZN7mpLayerC2Ev':|
D:\Lizenz_Logfile_Reader\mathplot.cpp|80|multiple definition of `mpLayer::mpLayer()'|
obj\Debug\Lizenz_Logfile_ReaderApp.o:D:\Lizenz_Logfile_Reader\mathplot.cpp|80|first defined here|
obj\Debug\Lizenz_Logfile_ReaderMain.o||In function `ZN7mpLayerC2Ev':|
D:\Lizenz_Logfile_Reader\mathplot.cpp|80|multiple definition of `mpLayer::mpLayer()'|
obj\Debug\Lizenz_Logfile_ReaderApp.o:D:\Lizenz_Logfile_Reader\mathplot.cpp|80|first defined here|
obj\Debug\Lizenz_Logfile_ReaderMain.o||In function `ZN7mpLayer15GetColourSquareEi':|
D:\Lizenz_Logfile_Reader\mathplot.cpp|91|multiple definition of `mpLayer::GetColourSquare(int)'|
obj\Debug\Lizenz_Logfile_ReaderApp.o:D:\Lizenz_Logfile_Reader\mathplot.cpp|91|first defined here|
obj\Debug\Lizenz_Logfile_ReaderMain.o||In function `ZNK11mpInfoLayer12GetClassInfoEv':|
D:\Lizenz_Logfile_Reader\mathplot.cpp|106|multiple definition of `mpInfoLayer::GetClassInfo() const'|
obj\Debug\Lizenz_Logfile_ReaderApp.o:D:\Lizenz_Logfile_Reader\mathplot.cpp|106|first defined here|
obj\Debug\Lizenz_Logfile_ReaderMain.o||In function `ZN11mpInfoLayer14wxCreateObjectEv':|
D:\Lizenz_Logfile_Reader\mathplot.cpp|106|multiple definition of `mpInfoLayer::wxCreateObject()'|
obj\Debug\Lizenz_Logfile_ReaderApp.o:D:\Lizenz_Logfile_Reader\mathplot.cpp|106|first defined here|
obj\Debug\Lizenz_Logfile_ReaderMain.o||In function `ZN11mpInfoLayerC2Ev':|
D:\Lizenz_Logfile_Reader\mathplot.cpp|108|multiple definition of `mpInfoLayer::mpInfoLayer()'|
obj\Debug\Lizenz_Logfile_ReaderApp.o:D:\Lizenz_Logfile_Reader\mathplot.cpp|108|first defined here|
obj\Debug\Lizenz_Logfile_ReaderMain.o||In function `ZN11mpInfoLayerC2Ev':|
D:\Lizenz_Logfile_Reader\mathplot.cpp|108|multiple definition of `mpInfoLayer::mpInfoLayer()'|
obj\Debug\Lizenz_Logfile_ReaderApp.o:D:\Lizenz_Logfile_Reader\mathplot.cpp|108|first defined here|
obj\Debug\Lizenz_Logfile_ReaderMain.o||In function `ZN11mpInfoLayerC2E6wxRectPK7wxBrush':|
D:\Lizenz_Logfile_Reader\mathplot.cpp|118|multiple definition of `mpInfoLayer::mpInfoLayer(wxRect, wxBrush const*)'|
obj\Debug\Lizenz_Logfile_ReaderApp.o:D:\Lizenz_Logfile_Reader\mathplot.cpp|118|first defined here|
obj\Debug\Lizenz_Logfile_ReaderMain.o||In function `ZN11mpInfoLayerC2E6wxRectPK7wxBrush':|
D:\Lizenz_Logfile_Reader\mathplot.cpp|118|multiple definition of `mpInfoLayer::mpInfoLayer(wxRect, wxBrush const*)'|
obj\Debug\Lizenz_Logfile_ReaderApp.o:D:\Lizenz_Logfile_Reader\mathplot.cpp|118|first defined here|
obj\Debug\Lizenz_Logfile_ReaderMain.o||In function `ZN11mpInfoLayerD2Ev':|
D:\Lizenz_Logfile_Reader\mathplot.cpp|128|multiple definition of `mpInfoLayer::~mpInfoLayer()'|
obj\Debug\Lizenz_Logfile_ReaderApp.o:D:\Lizenz_Logfile_Reader\mathplot.cpp|128|first defined here|
obj\Debug\Lizenz_Logfile_ReaderMain.o||In function `ZN11mpInfoLayerD2Ev':|
D:\Lizenz_Logfile_Reader\mathplot.cpp|128|multiple definition of `mpInfoLayer::~mpInfoLayer()'|
obj\Debug\Lizenz_Logfile_ReaderApp.o:D:\Lizenz_Logfile_Reader\mathplot.cpp|128|first defined here|
obj\Debug\Lizenz_Logfile_ReaderMain.o||In function `ZN11mpInfoLayerD0Ev':|
D:\Lizenz_Logfile_Reader\mathplot.cpp|128|multiple definition of `mpInfoLayer::~mpInfoLayer()'|
obj\Debug\Lizenz_Logfile_ReaderApp.o:D:\Lizenz_Logfile_Reader\mathplot.cpp|128|first defined here|
obj\Debug\Lizenz_Logfile_ReaderMain.o||In function `ZN11mpInfoLayer10UpdateInfoER8mpWindowR7wxEvent':|
D:\Lizenz_Logfile_Reader\mathplot.cpp|134|multiple definition of `mpInfoLayer::UpdateInfo(mpWindow&, wxEvent&)'|
obj\Debug\Lizenz_Logfile_ReaderApp.o:D:\Lizenz_Logfile_Reader\mathplot.cpp|134|first defined here|
obj\Debug\Lizenz_Logfile_ReaderMain.o||In function `ZN11mpInfoLayer6InsideER7wxPoint':|
D:\Lizenz_Logfile_Reader\mathplot.cpp|139|multiple definition of `mpInfoLayer::Inside(wxPoint&)'|
obj\Debug\Lizenz_Logfile_ReaderApp.o:D:\Lizenz_Logfile_Reader\mathplot.cpp|139|first defined here|
obj\Debug\Lizenz_Logfile_ReaderMain.o||In function `ZN11mpInfoLayer4MoveE7wxPoint':|
D:\Lizenz_Logfile_Reader\mathplot.cpp|144|multiple definition of `mpInfoLayer::Move(wxPoint)'|
obj\Debug\Lizenz_Logfile_ReaderApp.o:D:\Lizenz_Logfile_Reader\mathplot.cpp|144|first defined here|
obj\Debug\Lizenz_Logfile_ReaderMain.o||In function `ZN11mpInfoLayer15UpdateReferenceEv':|
D:\Lizenz_Logfile_Reader\mathplot.cpp|150|multiple definition of `mpInfoLayer::UpdateReference()'|
obj\Debug\Lizenz_Logfile_ReaderApp.o:D:\Lizenz_Logfile_Reader\mathplot.cpp|150|first defined here|
obj\Debug\Lizenz_Logfile_ReaderMain.o||In function `ZN11mpInfoLayer4PlotER4wxDCR8mpWindow':|
D:\Lizenz_Logfile_Reader\mathplot.cpp|157|multiple definition of `mpInfoLayer::Plot(wxDC&, mpWindow&)'|
obj\Debug\Lizenz_Logfile_ReaderApp.o:D:\Lizenz_Logfile_Reader\mathplot.cpp|157|first defined here|
obj\Debug\Lizenz_Logfile_ReaderMain.o||In function `ZN11mpInfoLayer11GetPositionEv':|
D:\Lizenz_Logfile_Reader\mathplot.cpp|189|multiple definition of `mpInfoLayer::GetPosition()'|
obj\Debug\Lizenz_Logfile_ReaderApp.o:D:\Lizenz_Logfile_Reader\mathplot.cpp|189|first defined here|
obj\Debug\Lizenz_Logfile_ReaderMain.o||In function `ZN11mpInfoLayer7GetSizeEv':|
D:\Lizenz_Logfile_Reader\mathplot.cpp|194|multiple definition of `mpInfoLayer::GetSize()'|
obj\Debug\Lizenz_Logfile_ReaderApp.o:D:\Lizenz_Logfile_Reader\mathplot.cpp|194|first defined here|
obj\Debug\Lizenz_Logfile_ReaderMain.o||In function `ZN12mpInfoCoordsC2Ev':|
D:\Lizenz_Logfile_Reader\mathplot.cpp|198|multiple definition of `mpInfoCoords::mpInfoCoords()'|
obj\Debug\Lizenz_Logfile_ReaderApp.o:D:\Lizenz_Logfile_Reader\mathplot.cpp|198|first defined here|
obj\Debug\Lizenz_Logfile_ReaderMain.o||In function `ZN12mpInfoCoordsC2Ev':|
D:\Lizenz_Logfile_Reader\mathplot.cpp|198|multiple definition of `mpInfoCoords::mpInfoCoords()'|
obj\Debug\Lizenz_Logfile_ReaderApp.o:D:\Lizenz_Logfile_Reader\mathplot.cpp|198|first defined here|
obj\Debug\Lizenz_Logfile_ReaderMain.o||In function `ZN12mpInfoCoordsC2E6wxRectPK7wxBrush':|
D:\Lizenz_Logfile_Reader\mathplot.cpp|203|multiple definition of `mpInfoCoords::mpInfoCoords(wxRect, wxBrush const*)'|
obj\Debug\Lizenz_Logfile_ReaderApp.o:D:\Lizenz_Logfile_Reader\mathplot.cpp|203|first defined here|
obj\Debug\Lizenz_Logfile_ReaderMain.o||In function `ZN12mpInfoCoordsC2E6wxRectPK7wxBrush':|
D:\Lizenz_Logfile_Reader\mathplot.cpp|203|multiple definition of `mpInfoCoords::mpInfoCoords(wxRect, wxBrush const*)'|
obj\Debug\Lizenz_Logfile_ReaderApp.o:D:\Lizenz_Logfile_Reader\mathplot.cpp|203|first defined here|
obj\Debug\Lizenz_Logfile_ReaderMain.o||In function `ZN12mpInfoCoordsD2Ev':|
D:\Lizenz_Logfile_Reader\mathplot.cpp|208|multiple definition of `mpInfoCoords::~mpInfoCoords()'|
obj\Debug\Lizenz_Logfile_ReaderApp.o:D:\Lizenz_Logfile_Reader\mathplot.cpp|208|first defined here|
||More errors follow but not being shown.|
||Edit the max errors limit in compiler options...|
||=== Build failed: 50 error(s), 4 warning(s) (0 minute(s), 5 second(s)) ===|
我已经按照答案中的建议在行2610、2749-2751、2763、2847和2877中删除了
::
,这使一些错误消失了,但是现在上面的错误日志显示了。 最佳答案
首先,请确保您的应用程序构建时没有wxMathPlot(没有包含#include的内容,没有库等)。 YourWXdir / include必须在Project-> Build Options-> Search中设置。
其次,将mathplot.cpp与应用程序中的任何其他文件一样添加到您的项目中。在您的应用需要wxMathPlot API的文件中#include mathplot.h,但每个文件仅包含一次(您必须将其复制)。不要#include mathplot.cpp。
重复的定义来自同时使用mathplot.cpp及其库。选择仅一种使用方式。
无符号转换位于您的代码Lizenz_Logfile_ReaderMain.cpp中。
关于c++ - 如何获取libmathplot.a,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/41592884/