3

I've been having a bit of trouble using LibCurl with Visual Studio 2010. Keep in mind I'm pretty new to C++.

I built the library according to the instructions on the libcurl website and tried to point my project to the include directory, libcurl.lib, etc but when I try to build the project I get a bunch of LNK2019 errors.

Can someone please walk me through how to tell Visual Studio where the include files, .lib file, etc are (i.e. all the steps after building LibCurl up to using sample code in a test project)?

Thanks in advance.

JonaGik
  • 1,533
  • 5
  • 24
  • 35
  • 1
    Ok I got it working: added ws2_32.lib and Wldap32.lib. That got it to compile. Then I fixed the error I got by rebuilding libcurl and replacing libcurl.lib and libcurl.dll in my application and it worked. Thanks for your help guys. – JonaGik Jun 11 '11 at 02:53

2 Answers2

4

error LNK2001: unresolved external symbol __imp__send@16

Hurray, we have an error message. Add ws2_32.lib to the Additional Dependencies setting. The MSDN Library lists the required import library at the bottom of the article for each API function.

Interpreting the linker error is important to diagnose these errors. Ignore the __imp__ prefix, that's linker glue. You can tell it is trying to find the definition of the send() function. That's a standard socket API function. The MSDN Library article for send() told me you need to add ws2_32.lib to the dependencies. The article is here, scroll to the bottom. This same information should also be available in the library documentation.

Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536
  • How do you know to include "ws2_32.lib"? This has solved a great number of the errors (now 16 errors down from 42). – JonaGik Jun 10 '11 at 13:14
0

open the project settings dialog window first (right click >> properties)

this contains everything in regards to getting the project configured

find "Linker", then expand it and go to "Linker >> General"

under "Additional library directories" add the location of the ".lib" files

then go to "Linker>>input" and add the name of the library files you want to include

Pepe
  • 405
  • 5
  • 12
  • Get Ivor Hortons Begining visual C++ 2010, it'll set you off in the right direction. – Pepe Jun 10 '11 at 12:09
  • I get the same errors when I do this - the errors are all similar to "libcurl.lib(telnet.obj) : error LNK2001: unresolved external symbol __imp__send@16" – JonaGik Jun 10 '11 at 12:11
  • @StefanK I get the same errors when I do this - the errors are all similar to "libcurl.lib(telnet.obj) : error LNK2001: unresolved external symbol __imp__send@16" – JonaGik Jun 10 '11 at 13:04
  • @user792680 ws2_32.lib is WinSock2 and curl is a networking library, make sense? – Pepe Jun 10 '11 at 14:18
  • @StefanK OK so it compiles now (I've added ws2_32.lib and Wldap32.lib). I've got another error though: when compiling it gives me the warning "warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library" twice. Then when I run it says it's triggered a breakpoint in the program which "may be due to a corruption of the heap, which indicated a bug in [the program name] or any of the DLLs it has loaded." – JonaGik Jun 10 '11 at 23:37
  • that is to do with you trying to compile one library with a Multi-threaded debug dll and the other with a multi-threaded static lib. You need to go to each project and make sure that the c/c++ >> code generation >> Runtime library settings are the same accross the projects and libraries that you are using. best look in the documentation for Curl – Pepe Jun 14 '11 at 10:08