【发布时间】:2014-02-18 21:27:30
【问题描述】:
我一直在尝试配置 Eclipse CDT(在 Ubuntu Precise 上)以使用 wxWidgets 编译程序。我收到 Eclipse 的错误,但程序可以使用我提供的 makefile 编译得很好。我已按照http://wiki.wxwidgets.org/Eclipse#Linux 中的说明进行操作,但仍然没有成功。 (即,我相信我已经正确设置了编译器和链接器标志。)
我的头文件如下:
#ifndef READIMAGE_H_
#define READIMAGE_H_
class Image{
wxImage *loadedImage;
public:
Image(string filename);
void loadImage(string filename){};
};
#endif /* READIMAGE_H_ */
我的源文件如下:
#include <wx/wx.h>
#include <wx/image.h>
#include <iostream>
using namespace std;
#include "readImage.h"
Image::Image(string file){
loadImage(file);
}
int main(){
Image img("example.jpg");
}
我收到的错误是:
make: *** [Image_IO] Error 1
Type 'wxImage' could not be resolved
undefined reference to `wxRect2DInt::operator=(wxRect2DInt const&)'
undefined reference to `wxRect2DInt::operator=(wxRect2DInt const&)'
undefined reference to `wxThread::~wxThread()'
如果有帮助,makefile 如下:
INCS =
LIBP =
ARCH_CFLAGS =
#The code below should be used rather than the
#specific 2.4 version one. With this one we ensure
#that we run the latest release of wxGTK rather
#than a specific one:
WX_LIBS = `wx-config --libs --gl-libs`
WX_FLAGS = `wx-config --cxxflags`
LIBS = $(WX_LIBS)
ARCH_CFLAGS =
EXES = readImage
CFLAGS = $(ARCH_CFLAGS) $(WX_FLAGS) -Wall -Wno-unused -Wno-reorder \
-O3 -fomit-frame-pointer -fforce-addr
# ------------------
all : clean $(EXES)
clean :
find -name "*.o" -exec rm {} \;
rm -f ${EXES} -R
# ------------------
readImage : readImage.o
g++ readImage.o -o readImage $(ARCH_CFLAGS) $(LIBS) $(CFLAGS)
readImage.o : readImage.cpp readImage.h
g++ -c readImage.cpp $(ARCH_CFLAGS) $(INCS) $(WX_FLAGS)
# ------------------
有什么想法吗?
非常感谢。
编辑
在 C++ 编译器和链接器的命令行模式中(分别是 Project>Properties>GCC C++ Compiler 和 >GCC C++ Linker),如果我将 ${FLAGS} 移动到模式的末尾,那么我只会收到一个错误:
Type 'wxImage' could not be resolved
注意我没有收到任何包含的警告,这表明编译器和链接器可以找到这些库。
【问题讨论】:
标签: c++ wxwidgets eclipse-cdt