系統環境:windows10
編譯環境:vs2015
cmake:3.4.1
1.下載和安裝
下載rabbitmq-c最新代碼包:https://github.com/alanxz/rabbitmq-c/releases/tag/v0.8.0
下載cmake最新安裝包:https://cmake.org/download/
2.使用cmake編譯生成適合自己編譯環境的工程
第一步:填寫源代碼路徑
第二步:填寫建立后的路徑,build的文件夾一般建立在源代碼路徑里,也可以放在其他位置
第三步:點擊配置按鈕,在配置里面選擇屬於自己編譯環境的名字
第四步:點擊生成按鈕,不出現運行失敗就說明已經編譯成功了


特別說明:在編譯rabbitmq-c是如果出現如圖的錯誤,可以去掉ENABLE_SSL_SUPPORT括號里的對勾。


生成了VS2015的工程文件后,先編譯,然后install到你選定的路徑,我的安裝目錄是:D:\rabbitmq-c。


二、Windows下編譯SimpleAmqpClient
1、編譯boost庫
因為需要用到boost庫,所以在編譯SimpleAmqpClient之前,先要編譯boost庫。
https://www.cnblogs.com/oloroso/p/6050596.html
下載Boost庫的源碼,我下的是1.66版的。
通過VS2015的native tools來編譯Boost庫。
命令如下:
#編譯
b2.exe --prefix=d:\boost_1_66_0 --build-type=complete--build-dir=build toolset=msvc-14.0 address-model=64 stage –j4
#安裝
b2.exe --prefix=d:\boost_1_66_0 --build-type=complete--build-dir=build toolset=msvc-14.0 address-model=64 install


編譯boost,參考http://archive.cnblogs.com/a/1979730/(建議使用--build-type=complete全編譯,如果采用動態鏈接編譯不會生成靜態鏈接庫文件,如libboost_chrono-vc100-mt-1_47.lib,編譯SimpleAmqpClinet時會報鏈接錯誤:缺少libboost_chrono-vc100-mt-1_47.lib文件)。boost庫文件命名規則參考http://blog.csdn.net/zzvnzz/article/details/7082263
2、編譯SimpleAmqpClient
我沒有選擇支持SSL,所以編譯出現一個錯誤,Channel.cpp(194): error C2511:'AmqpClient::Channel::Channel(const std::string &,int,const std::string&,const std::string &,const std::string &,int,const std::string&,const std::string &,const std::string &)': overloaded memberfunction not found in 'AmqpClient::Channel'.
我修改了一下這個構造函數,如下:


采用CMAKE生成VS2015工程。CMAKE配置如下圖:


3、使用樣例:
http://blog.csdn.net/csm201314/article/details/76377214
