VS2015 中卡萨布兰卡的链接器错误,同时尝试构建一个简单的 HTTP 侦听器
Linker Errors with casablanca in VS2015 while trying to build a simple HTTP listener
作为学习Rest服务过程的一部分,我正在尝试使用Microsoft c ++ REST SDK"casablanca"构建一个简单的HTTP侦听器。我最初的目标是测试它是否可以接收指向本地主机的简单 POST 请求并将文本保存在文件中。
我正在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 POSTn");
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 listenn"); })
.wait();
while (true);
}
catch (exception const & e)
{
wcout << e.what() << endl;
}
}
我遇到的错误之一:
未解析的外部符号" __declspec(dllimport) public:_thiscall web::uri::uri(wchar_t const*)" (__imp_??0uri@web@@QAE@PB_W@Z) 在function_main中引用
如果有人能向我指出我做错了什么,将不胜感激
您是否
在Linker->Input中包含cpprest.lib作为其他依赖项。确切的名称取决于您是执行 cpprest 库的静态链接还是动态链接。
此外,如果要执行静态链接,则可能需要添加_NO_ASYNCRTIMP预处理器定义。
希望这有帮助
相关文章:
- 函数向量_指针有不同的原型,我可以构建一个吗
- 构建一个由C和C++文件组成的库
- 如何使用 samtools C API 构建一个简单的主.cpp文件
- 如何构建一个 setup.py 来编译C++使用 Python、pybind11 和 Mingw-w64 的扩展?
- 如何构建一个异常类来报告C++中的哪些文件和行号?
- 在 Visual Studio 中构建一个没有 C/C++ 运行时的静态库
- 创建一个类来访问和指定向量类型,并构建一个获取位置并为其分配区域的类
- 使用步骤c++构建一个向量
- 为什么我们需要构建一个提升库,仅仅包含头文件还不够吗,因为提升是模板
- 我正在尝试构建一个简单的程序来从 mysql 数据库中读取信息
- 构建一个真正、完全静态的Qt 5框架和应用程序(Qt 5.8之后)
- CMake 使用 ECM 构建一个库
- 如何构建一个 Map,其中键是抽象基类(而不是值)
- 从命令行构建一个.sln / .vcxproj项目,并使用Visual C 的免费版本构建
- 如果初始化需要shared_from_this,如何在一次调用中构建一个类
- 可以使用Meson构建一个琐碎的项目,但不能使用CMake
- 我如何构建一个从git克隆的单独的增强库
- 构建一个可执行文件,如果是单个 cpp 文件
- 在 Xcode 8.3 上构建一个C++正态分布式随机数生成器
- 在使用 bazel 构建一个简单的应用程序时,得到错误在 '/usr/lib/java/jdk1.8.0_74/bin/java' 找不到 java