簡體   English   中英

配置Eclipse CDT以與wxWidgets一起使用

[英]Configuring Eclipse CDT to work with wxWidgets

我一直在嘗試配置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

注意我沒有收到任何包含在內的警告,建議編譯器和鏈接器可以找到這些庫。

問題解決了。

在執行EDIT之后 ,我嘗試通過終端在makefile上運行make命令。 該程序編譯良好,因此我認為它只是代碼分析工具。 我最終轉到“ 項目”>“屬性”>“ C / C ++常規”>“代碼分析”>“啟動”,並在鍵入時取消選擇運行,然后選擇“ 帶構建運行”選項。

我假設這將迫使Eclipse使用編譯器輸出來創建錯誤和警告,而不是使用其他一些內置方法。 不過,也許有人可以澄清一下。

注意 :在步驟生效之前,我需要重新啟動eclipse。

非常感謝。

配置eclipse以使用wxWidgets有點復雜。 以我的經驗,有一些編譯器標志和鏈接器選項需要相應地設置,這可能會引起初學者的困惑。

在使用eclipse的經驗中,我發現了一種使eclipse與wxWidgets配合使用的簡便方法,請檢查此簡化的安裝程序,以幫助您配置eclipse。

該安裝程序最初針對樹莓派板卡,因為它包含使用buildroot構建的交叉編譯器工具鏈。 但是,還提供了針對Linux x86_64的目標版本,已經在Ubuntu 14.04-LTS上進行了測試。

請嘗試並告知您的里程。

http://yasriady.blogspot.co.id/2016/01/raspberry-pi-toolchain.html

Rgrds / DDY

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM