Quantcast
Channel: WE MOVED to github.com/microsoft/cpprestsdk. This site is not monitored!
Viewing all articles
Browse latest Browse all 4845

Closed Issue: SDK 1.1.0 does not work with VS2013 [49]

$
0
0
I tried the 1.1.0 version of the SDK with Visual Studio 2013 Preview and it does not work because of the way the PPL library is used.

I get the following error when I write the code below:

> error LNK2019: unresolved external symbol "__declspec(dllimport) public: class Concurrency::task<void> __thiscall web::http::details::_http_request::reply(class web::http::http_response)" (__imp_?reply@_http_request@details@http@web@@QAE?AV?$task@X@Concurrency@@Vhttp_response@34@@Z) referenced in function "public: class Concurrency::task<void> __thiscall web::http::http_request::reply(class web::http::http_response)const " (?reply@http_request@http@web@@QBE?AV?$task@X@Concurrency@@Vhttp_response@23@@Z)

```
#include <cpprest\http_listener.h>
#pragma comment(lib, "cpprest110_1_1")

using namespace web;
using namespace web::http;
using namespace web::http::experimental::listener;

int _tmain(int argc, _TCHAR* argv[])
{
http_listener listener(L"http://localhost/restdemo");

listener.support(
methods::GET,
[](http_request request) {
request.reply(http::status_codes::OK, L"Hello world!");
});



return 0;
}

```

The files have the following include:

```
#if defined(_MSC_VER) && (_MSC_VER >= 1800)
#include <ppltasks.h>
namespace pplx = Concurrency;
#else
#include "pplx/pplxtasks.h"
#endif

```
So if VS2013 is used, then the PPL deployed with it is used. So the the linker is looking for method.
```
__imp_?reply@_http_request@details@http@web@@QAE?AV?$task@X@Concurrency@@Vhttp_response@34@@Z
```
However, the C++ REST library is not built with that version so the actual method found in cpprest110_1_1.lib is

```
__imp_?reply@_http_request@details@http@web@@QAE?AV?$task@X@pplx@@Vhttp_response@34@@Z.
```

I was able to make it work by simply including __pplx/pplxtasks.h__ regardless of which VS is used.

Of course, one has to also comment this directives in the distributed PPL files:
```
#if (defined(_MSC_VER) && (_MSC_VER >= 1800))
#error This file must not be included for Visual Studio 12 or later
#endif
```

Obviously this was intentional. Why?

Viewing all articles
Browse latest Browse all 4845

Trending Articles