Jacob
Jacob

Reputation: 659

Compile C++ code in Ubuntu with gcc linking a library

I'm stuck in a very simple problem: I cannot manage to make work my simple code example in C++. I want to include the "curl" library but when I compile with the command:

g++ -o myprog.out myprog.cpp -L/curl/include/ -lcurl

I get the following error message:

myprog.cpp:3:71: fatal error: /curl/include/curl/curl.h: No such file or directory

My folder contains:

My headers file are configured in this way:

include<iostream>
include<string>
include<curl.h>

What I'm doing wrong? It's probably a very simple problem but it's driving me crazy :-/

Upvotes: 1

Views: 2415

Answers (1)

Maxim Egorushkin
Maxim Egorushkin

Reputation: 136256

  1. Change #include <curl.h> to #include <curl/curl.h>.
  2. Change -L/curl/include/ to -I/curl/include.
  3. Add -L/curl/lib -Wl,-rpath=/curl/lib (or whatever the path to curl built libraries).

Upvotes: 1

Related Questions