casablanca120.xp import failure

Oct 18, 2014 at 7:52 AM
Edited Oct 18, 2014 at 9:36 AM
  Question1.  

      I download casablanca 2.2 from the [source page](https://casablanca.codeplex.com/SourceControl/latest)  and release the casablanca-9cc7758d714bebbc00d66bf9a49bb648e9a57c17.zip to E:\soft\CPPREST\casablanca 2.2\casablanca, then open the casablanca120.desktop.sln with VS2013.  The casablanca120 project can be open normally but the casablanca120.xp cannot. The error tip is "cannot modify the calculation object from import file 'E:\soft\CPPREST\casablanca 2.2\casablanca\Release\src\buildsources.proj".  Is there any idea about this error?

     Question2.  

         I released the casablanca 2.1 to E:\soft\CPPREST\casablanca and configed the casablanca120 and casablanca120.xp project to build static lib and used the static libraries to build my MFC win32 application several weeks ago. Now  I want to use the dynamic library as the official configuration does, and  put cpprest120_2_1.dll and cpprest120_2_1.lib into my project folder, set cpprest120_2_1.lib to link configuration-->input .  But I have got a link error 
1>DatabaseOperation.obj : error LNK2001: unresolved external symbol "public: static class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > const web::http::methods::POST" (?POST@methods@http@web@@2V?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@B)
       I find the method::POST is defined in a .dat file,    It seems that the definiation cannot be link into the dll. What can I do?


      The program is developed in win7 and hoped to be compatible with XP, WIN7 and WIN8. 
Coordinator
Oct 18, 2014 at 5:01 PM
Hi joeccmou,

Question 1 - yes this was a known issue and has been already fixed in the development branch. It also will be in the master at our next release 2.3.0.

Question 2 - Do you have any trouble using the 2.1.0 version of our NuGet package for the dynamic case? All you should need to do is add the NuGet package reference and be all set. Also please note there is a different lib and dll for targeting XP. The name contains 'xp', so for example for version 2.1.0 it is called cpprest120_xp_2_1.dll. I think it is easier to let the NuGet package manage the lib/dll dependencies for you.

Steve
Oct 20, 2014 at 7:17 AM
Edited Oct 21, 2014 at 6:32 AM
Hi Steve,
          Thank you very much for the reply, I'm sorry to misunderstand the use of dynamic library and the static library. 
But I still encounter the problem after I use the nuget to download the packages. I typed "Install-package cpprestsdk -Version 2.1.0" and got the packages set. However, I still got the linker error "unresolved external symbol web::http::methods::DEL, web::http::methods::GET, web::http::methods::POST".
           My project has 4 configurations: Debug XP 2.1, Debug Win7 2.1, Release XP 2.1, Release Win7 2.1.
And I have another problem when I download files from the company's server. Sometimes I got exceptions like "Error in: WinHttpSendRequest", "Error in: WinHttpReceiveResponse", "Error in: WinHttpQueryDataAvaliable",what exactly the errors are?

the simplified download code looks like
    build_uri.clear();
build_uri.append_path(U("/FingerprintImages/"));
build_uri.append_path(guid);

request.set_method(methods::GET);
request.set_request_uri(build_uri.to_uri());
request.headers().add(U("Authorization"), authorization.c_str());

try
{
    http_resp = client.request(request).get();

    if (http_resp.status_code() == status_codes::OK)
    {
        concurrency::streams::istream bodyStream;
        bodyStream = http_resp.body();

        size_t size = http_resp.headers().content_length();
        data = new uint8_t[size];
        rawptr_buffer<uint8_t>  tbuf(data, size);

        size_t          k = 0;
        k = bodyStream.read_to_end(tbuf).get();
             }
            else
    {
                     js_value = http_resp.extract_json().get();
        err_msg = (js_value[L"Message"].is_null() ? js_value[L"Message"].serialize() : js_value[L"Message"].as_string()).c_str();
        return FALSE;
    }
}
catch (const std::exception& e)
{
            /* here gets the EXCEPTIONS  */
    err_msg.Format(_T("%S"), e.what());
    if (data != NULL)
    {
        delete[]data;
        data = NULL;
    }
    return FALSE;
}

      I'm now using a static library complied from casablanca 2.1 and going to change to dynamic library to see whether the exceptions will disapear or not.
Coordinator
Oct 23, 2014 at 1:31 AM
Hi joeccmou,

I'm confused and don't really understand your first problem. If you are getting unresolved symbol errors it sounds like you are not linking to a .lib file.

For the second problem getting exceptions. You are seeing errors being returned from the underlying platform API, in this case WinHttp. They can be caused for a variety of reasons, for example network connectivity. Try catching http_exception instead of std::exception. This is the exception type thrown by the http_client library. On the http_exception class there is a an API http_exception::error_code(). It returns a std::error_code which contains an error code from the OS and an error string with more information.

Steve
Dec 9, 2014 at 12:54 PM
Hi Steve,

I still got the link error

BrowseImageDlg.obj : error LNK2001: unresolved external symbol "public: static class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > const web::http::methods::GET" (?GET@methods@http@web@@2V?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@B)


I have put "cpprest120_2_3.lib" into "Project Property --> Linker --> Input -->Additional Dependencies" and $(SolutionDir)packages\cpprestsdk.2.3.0\build\native\bin\Win32\v120\Release\Desktop into "Project Property --> VC++ Path--> Executable Path", do I need any more settings to make it right?
The platform is VS2013 running on Win7.
Coordinator
Dec 9, 2014 at 4:29 PM
Hi joeccmou,

It sounds like you have some setting on your project file messed up. I'm not aware of any issues with unresolved symbols from other users. Did you manually do the settings on your Visual Studio project file yourself or did you just add a reference to our NuGet package?

Can you share with me a solution the reproduces the issue? You can email me at stgates at Microsoft dot com if you'd like.

Thanks,
Steve
Dec 12, 2014 at 2:18 AM
Hi Steve,
       Sorry, the project has been encrypted because its copyright belongs to my company. But I can send you the  .vcxproj  file.
       In the one which fails to resolve symbols I have 4 configurations in the project:  Release Win7 2.3, Release XP 2.3, Debug Win7 2.3, Debug Win7 2.3 ( no Release and Debug ).   Another one that only has  Release and Debug configurations works fine. Both this two projects are setting by Nuget and  the  .vcxproj file are sent to your e-mail. Thanks a lot for your reply.

Coordinator
Dec 12, 2014 at 9:16 PM
Hi joeccmou,

I'm really puzzled as to what could be the problem here if NuGet is handling setting libs. Sorry but for some reason I can't seem to find the email, I don't know if I it got lost or what. Could you perhaps try sending it again?

Steve
Apr 28, 2015 at 12:20 AM
I have the exact same problem and it is just this single function that is unresolved. Was there any fix to this or was it resolved?
Coordinator
Apr 29, 2015 at 12:52 AM
Hi ehaddan,

joeccmou never responded back further so I don't know if the latest NuGet package resolved his issue or not. How our NuGet packages are created and organized entirely changed for the 2.5.0 release so I don't have much interest in going back to investigate older NuGet packages like 2.3.0. What version are you using and what exactly are the problems you are seeing?

Thanks,
Steve
Apr 29, 2015 at 6:00 PM
I had to download version 2.5 and used other directions to create static libraries. A debug build compiles just fine, but a release build gives me an unresolved external:

error LNK2001: unresolved external symbol "public: static class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > const web::http::methods::POST" (?POST@methods@http@web@@2V?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@B)

It worked fine in version 2.4, but we had to upgrade to 2.5 because of an XP bug.

I have to use a static link because the code needs to be in 1 all inclusive dll to use in a WiX extension DLL.
Coordinator
Apr 29, 2015 at 6:08 PM

Hi ehaddan,

Ok so you aren’t using our NuGet package at all…

This is really going to be hard for me to figure out then because you are using some modified build for static linking of your own.

Steve

Apr 29, 2015 at 7:04 PM
That is correct. I wish they had a way to do static builds with the NuGet package. I'll keep messing around with it and let you know if I figure it out.