跳到主要內容

發表文章

目前顯示的是有「Qt」標籤的文章

Setting Boost library in Qt for Windows 64-bits

Qt 是一個很優質的 C++ IDE,在前些日子 Qt Project release Qt 5.1.1 for Windows 64-bit (VS 2012, OpenGL, 522 MB) 的版本,於是重新安裝了這個版本。但是自己卻忘記之前 compile Boost 是 msvc 32-bits 的版本(Boost 的 compile 設定可以參考之前寫的 Building Wt with Visual Studio 2012 on Windows 8 x64 PC 這篇文章),在使用 Boost Getting Started on Windows 的 Regex source code 做測試時,卻出現 error LNK2019 : unresolved external symbol 錯誤,參考了 stack overflow 的這篇文章 ,才知道用到 32-bits 的 regex Library ,整個修正的過程,紀錄在底下的文章,以後才不至於忘記。 Qt 5.1.1 for Windows 64-bit (VS 2012, OpenGL) 這個版本主要是使用 Visual Studio 2012 做為後端的 Compiler,然而安裝 VS 2012 Express for Desktop 可以使用 x64 or x86 的版本,所以安裝完  VS 2012 Express for Desktop 以後,再安裝 Qt 5.1.1 for Windows 64-bit (VS 2012, OpenGL) 就可以使用,並不需要做特別的設定。相同地,使用 Boost 也是一樣,只要不需要特別 link 到 Boost library 的程式,皆可以 compile 成功,並且可以執行。底下省略了安裝 VS 2012 及 Qt 的過程,並且使用之前 Boost 32-bits 的 library 來測試 Boost Getting Started on Windows 的 lambda 程式,整個過程為: 1. 在 Qt 中新增一個 Plain C++ Project:    File > New File or Project > Non-Qt Project >...

Using Qt for Windows x64(VS 2012) with Boost Library

在 Qt 5.0 版本發行時,最早只有 Visual Studio 2010 的版本,後來分別發行 MinGW 4.7 以及 VS 2012 的版本,對於 Qt 這個 IDE 如何使用 Boost Library,設定的過程說明如下: Qt for MinGW compiler: 1. 下載 STL 所 compile 的 MinGW 套件 ,其中包含了 boost library 2. 開啟 Qt,然後建立一個 new project for c++ 3. 加入 Boost Library 的路徑: 在 .pro 的設定檔中加入下面的路徑 INCLUDEPATH += D:/libraries/ include LIBS += -LD:/libraries/lib/ -lboost_regex 4. 將 main.cpp 的內容改成 boost's Getting Started 的程式 : #include <boost/regex.hpp> #include <iostream> #include <string> int main() { std::string line; boost::regex pat( "^Subject: (Re: |Aw: )*(.*)" ); while (std::cin) { std::getline(std::cin, line); boost::smatch matches; if (boost::regex_match(line, matches, pat)) std::cout << matches[2] << std::endl; } } 5. 測試: 輸入 "Subject: Hello Boost" ------------------------------------------------------------------------------- Qt for Visual Studio 2012 compiler: ...