由於關於REST服務學習過程的一部分,我想建立使用Microsoft Visual C++一個REST SDK「卡薩布蘭卡」一個簡單的HTTP偵聽器。我最初的目標是測試它是否可以接收指向localhost的簡單POST請求並將文本保存在文件中。鏈接器錯誤與卡薩布蘭卡VS2015而試圖建立一個簡單的HTTP偵聽
我在VS2015上構建這個項目。我使用內置的包管理器來查找和安裝sdk,並從github下載所需的頭文件並將它們添加爲其他包含目錄。當試圖建立,我不斷收到「無法解析的外部符號」的錯誤,錯誤代碼LNK2019
這裏是代碼至今
#include <cpprest/http_listener.h>
#include <iostream>
#include <stdlib.h>
using namespace web;
using namespace web::http;
using namespace web::http::experimental::listener;
using namespace utility;
using namespace std;
#define TRACE(msg) wcout << msg;
#define TRACE_ACTION(a, k, v) wcout << a << L" (" << k << L", " << v << L")\n";
map<utility::string_t, utility::string_t> dictionary;
void handle_post(http_request request)
{
TRACE(L"\nhandle POST\n");
utility::string_t input;
input = request.to_string();
utility::ofstream_t out("output.txt");
out << input;
out.close();
}
int main(int argc, char** argv)
{
http_listener listener(L"http://localhost:8080");
listener.support(methods::POST, handle_post);
try
{
listener
.open()
.then([&listener]() {TRACE(L"\nstarting to listen\n"); })
.wait();
while (true);
}
catch (exception const & e)
{
wcout << e.what() << endl;
}
}
一個錯誤我得到的:
懸而未決在function_main中引用的外部符號「__declspec(dllimport)public:_thiscall web :: uri :: uri(wchar_t const *)」(__imp _ ?? 0uri @ web @@ QAE @ PB_W @ Z)
如果有人願意,指出我在做什麼錯了