tags:

views:

380

answers:

3

I'm trying to pull libcurl into a large C++ project.

However I am having trouble getting it to compile. I see errors coming from ws2def.h, winsock2.h, and ws2tcpip.h

Some of the errors look like this:

error C2061: syntax error : identifier 'iSockaddrLength'  ws2def.h  225
error C3646: 'LPSOCKADDR' : unknown override specifier    ws2def.h  225

..

error C2061: syntax error : identifier 'dwNumberOfProtocols'    winsock2.h 1259

I tried compiling the file that #include "curl.h" in straight C mode, but that did not fix the problem.

+2  A: 

Which C++ compiler are you using? Mine does not have ws2def.h at all. Also, keep in mind that winsock.h and winsock2.h are not compatible with each other, and some of the Win32 header files will include winsock.h by default, before your code has a chance to include winsock2.h. So you may have to disable winsock.h by defining _WINSOCKAPI_ in your project's compiler conditionals.

Remy Lebeau - TeamB
IMHO, it's better to include winsock2.h before windows.h (which includes winsock.h), instead of defining _WINSOCKAPI_.
KiNgMaR
That not always a possibility, though, depending on which compiler/framework you are using, whether precompiled headers are being used, etc.
Remy Lebeau - TeamB
A: 

It kinda looks like something else is bringing in winsock defines that are conflicting with curl. Can you try to set up a project that just uses curl? Oh, an I had to add CURL_STATICLIB to my preprocessor definitions to make it link.

Igor Zevaka
A: 

Try including windows.h BEFORE you include winsock2.h or any libcurl headers. Don't ask my why this sometimes works, but it does.

Matt Fichman