cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Build environment for C++ .net

From: Saccaggi, Francesco <francesco.saccaggi_at_e-ci.com>
Date: Mon, 14 Sep 2015 14:00:05 -0400

Hi All,

So I am trying to get the example sftpget.c to work on visual studios 2008
- Version 9. NOT the express version. The first thing I did was download
the newest version of curl 7.44.0 zip file. Then I open a new project and
stick sftget.c in the Source Files. When I go to build it the errors I get
are that curl_global_***** and curl_easy_****** are unresolved externally.
So I go into the Project Properites | Configuration Properties | C/C++ |
General | Additional Include Directories| "Here I add the path to the curl
7.44.0\include" Folder because that is where the header files are located
for those functions that are unresolved externally. I still get the same
errors doing that. When I add a path to curl-7.21.2\include it WORKS, which
is a much older version. I also tried
curl-7.22.0-7.23.0-7.24.0-7.25.0-7.26.0-7.27.0 and they all work. Once it
gets to version curl-7.28.0 it gives me the same errors.

But the next error I get is that the CURLSSH_AUTH_AGENT is an undeclared
identifier. I then search the entire solution for the word
CURLSSH_AUTH_AGENT and nothing is found. I then try to locate it and I
found it in the curl.h file in the new version of curl-7.44.0, it is not in
the curl.h file in the version curl-7.21.2.

So I am kind of lost now. I am not sure what version contains
CURLSSH_AUTH_AGENT and still works when I add in the include folder path in
my additional include directories.

I also look at the Build environment for C++ .net in the archives and I
tried doing what that said but all the samples are in C# and in the end I
couldn't even get it to build.

Thanks,

On Mon, Sep 14, 2015 at 1:27 PM, Jon <jon_at_mobilefs.com> wrote:

> Thanks Ray. I was able to compile/build/run my current C++ lib/dll by
> changing the common language run time support parameters in the project
> properties (configuration/general tab). I am also seeing the CURL commands
> communicate with my back end & I’m in the middle of testing that through to
> see if it is working properly.
>
>
>
> *From:* curl-library [mailto:curl-library-bounces_at_cool.haxx.se] *On
> Behalf Of *Ray Satiro via curl-library
> *Sent:* Monday, September 14, 2015 2:15 AM
> *To:* curl-library_at_cool.haxx.se
> *Subject:* Re: Build environment for C++ .net
>
>
>
> On 9/13/2015 4:26 PM, Jon wrote:
>
> Hi All,
>
>
>
> I’m starting to write an application in Microsoft Visual Studio 2012 using
> C++ and .net. I attempted to compile and build with my prior libcurl.lib
> libarary/dependency that I was using in the same VS 2012 but for C++ only
> (without .net) but I’m receiving all sorts of compiler warnings:
>
>
>
> (e.g. warning C4272: 'curl_free' : is marked __declspec(dllimport); must
> specify native calling convention when importing a function.)
>
>
>
> and also linker errors:
>
>
>
> (e.g. error LNK2031: unable to generate p/invoke for "extern "C" void
> __clrcall curl_easy_cleanup(void *)" (?curl_easy_cleanup@@$$J0YMXPAX_at_Z);
> calling convention missing in metadata)
>
>
>
> After looking around a little bit, it appears I’ll need a new lib/dll
> build specifically for C++ .net. I don’t need the code, just the libraries
> will do if you have them.
>
>
> There's a .NET binding for libcurl, libcurl.NET [1]. It is very old from
> ten years ago but it looks as though it still works. I suggest you make a
> few modifications though. After you download and unzip replace the
> bin/libcurl.dll with your own 32-bit libcurl.dll and replace
> bin/ca-bundle.crt with the most recent version [2]. Then you can play
> around with the samples. For more recent versions of Visual Studio you'll
> have to add /platform:x86 when compiling, like this:
>
> cd samples
> csc /platform:x86 /r:../bin/LibCurlNet.dll /out:../bin/SSLGet.exe SSLGet.cs
> cd ../bin
> sslget https://encrypted.google.com
>
> There's probably a way to do it with x64 but you would have to build the
> shim on your own and change the naming of the libcurl DLL I think.
>
> If you see this:
>
> System.DllNotFoundException: Unable to load DLL 'libcurl.dll': The
> operating sys
> tem cannot run . (Exception from HRESULT: 0x800700B6)
>
> It's because some DLL libcurl depends on can't be found. Like if your
> libcurl links to OpenSSL you'll need those DLLs (libeay32.dll,
> ssleay32.dll) in your path or copied to the bin directory.
>
> Also take note of the comment/review on the libcurl.NET homepage [1] about
> a memory leak if you are making a lot of requests.
>
> [1]: http://sourceforge.net/projects/libcurl-net
> [2]: https://github.com/bagder/ca-bundle/blob/master/ca-bundle.crt
>
> -------------------------------------------------------------------
> List admin: http://cool.haxx.se/list/listinfo/curl-library
> Etiquette: http://curl.haxx.se/mail/etiquette.html
>

-- 
Francesco Saccaggi
Software Engineer
Cincinnati Incorporated
(513) 367-7695

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2015-09-14