Click here to Skip to main content
15,891,204 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I'm writing a very simple program in MS Visual Studio Community 2015 that uses cURL. cURL installs header files here:
C:\Program Files (x86)\CURL\include\curl

A little embarrassing, but I cannot figure out why MS Visual Studio cannot find include file curl.h which is in that directory.

I've included that path in:
C/C++ | General | Additional Include files

My stadfx.h has the line:
C++
#include <curl.h>

but I get this error when I compile:
fatal error C1083: Cannot open include file: 'curl.h': No such file or directory

The project compiles OK when I change the line in stadfx.h to:
C++
#include "C:\Program Files (x86)\CURL\include\curl\curl.h"

I could just go with that but I have a similar problem with the library paths. I want to link with libcurl_imp.lib, which is here:
C:\Program Files (x86)\CURL\lib

I've included that path in:
Linker | General | Additional Library Directories

and I added libcurl_imp.lib to:
Linker | Input | Additional Dependencies

but I get unresolved externals for all of the LIBCURL function calls I make.

Suggestions are most welcome!

Thanks

What I have tried:

I've also tried including the path in:
VC++ Directories | Include Directories
Posted
Updated 19-Jun-16 21:47pm
Comments
[no name] 19-Jun-16 22:17pm    
This may be of value: http://www.codeproject.com/Tips/588022/Using-Additional-Include-Directories

For a single application (the only application using these dependencies) add the properties to your project:

C++ - General - Additional Include Directories: "C:\Program Files (x86)\CURL\include"
Linker - General - Additional Library Directories: "C:\Program Files (x86)\CURL\lib"

Include the header files in your source files as usual.

To link against additional libraries you have two options:

  1. Add the names to the project settings at Linker - Input - Additional Dependencies
  2. Import the library in one of your source files using a pragma comment (C/C++)[^] statement:
    C++
    #pragma comment(lib, "lib-name")
 
Share this answer
 
Comments
Member 3018373 23-Jun-16 1:34am    
Thanks Jochen, but I already have the paths set in the project properties and the library added just as you describe (see my original post). Gratifying to know that I didn't miss anything!

Interestingly, I got the project to build using this pragma:
#pragma comment(lib, "C:\\Program Files (x86)\\CURL\\lib\\libcurl_imp.lib")

I really don't understand why it doesn't work with property settings though.
Jochen Arndt 23-Jun-16 2:42am    
So it is working now for the include files with the additional path?

For the linker use the /VERBOSE:LIB option (see https://msdn.microsoft.com/en-us/library/wdsk6as6.aspx).
It will display information about the library search process and should help finding out where the problem is.
You are on the right track, but it looks like you use the wrong library.

Take a look at the discussion at stackoverflow because they use antoher and additional libraries and on the original sample code from curl.
 
Share this answer
 
Comments
Member 3018373 23-Jun-16 1:35am    
Thanks for responding, but I think I have the right library because I can get it to build using this pragma:
#pragma comment(lib, "C:\\Program Files (x86)\\CURL\\lib\\libcurl_imp.lib")

I really don't understand why it doesn't work with property settings though.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900