2

I'm using Arch Linux and have successfully built https://github.com/JosephP91/curlcpp However, I have no idea how to build the example program. I keep getting

fatal error: curl_easy.h: No such file or directory

Of course, this is because I don't know how to add it to the library/include path.

In the <curlcpp root>/build/src/ folder, I have a libcurlcpp.a file, which has all the .o files, and <curlcpp root>/include/ has all the .h files needed.

I've tried commands specified in the README, trying -I library/include, and other combinations.

Do I need to manually copy the file somewhere or run some command line app to make it system wide?

I don't think ldconfig is the right program since that's for dynamic libraries.

  • 1
    Can you list more explicitly what you tried? – Faheem Mitha Jul 3 '14 at 18:24
2

What exact command do you use to build executable of your program?

You need to tell g++ about additional directories with project-specific headers and libraries. If you have libcurlcpp.a copied into $proj_home/lib and libcurlcpp.h copied into $proj_home/hdr this will be something like:

$ g++ your_program.cpp -Ihdr -Llib -lcurlcpp -static -o your_executable
  • -I specifies additional directory with headers
  • -L specifies additional directory with libraries
  • -l specifies particular library that you want to link (without lib and .a/.so)
  • -static tells g++ to prefer static libraries (*.a) over dynamic (*.so) (default is reverse)

Paths for -I and -L are specified without space between key and the path itself. Similar thing is for -l.

Arrange project Makefile accordingly when you'll figure out particular command that works for you.

  • This might be a dumb question, but are there such things as global static libraries? I'm looking at /usr/lib and there are many .a files. Does this mean if I put libcurlcpp.a in that directory, I will only need the -l flag? – No_name Jul 4 '14 at 1:46
  • getting compile errors: pastebin.com/zvsMbGXF – No_name Jul 4 '14 at 2:04
  • Regarding compile time errors. Try to remove spaces after -I and -L. Looks like g++ can't find some symbols of the libcurlcpp so maybe source of the problem is that g++ didn't recognize that there is an additional library and header directories in the project. Anyway, strange that there is no explicit mistake. – yaromir Jul 4 '14 at 23:34
  • Regarding your question about library paths. There are common locations for libraries and headers. Typically in Linux headers are placed in /usr/include and libraries are placed into /lib (for root-level privilege programs) and /usr/lib (for user-level privilege programs). – yaromir Jul 4 '14 at 23:39
  • Anyway copying a library into these common paths just to compile a program is a bad practice. If you really want to use static library then it should be stored in the project directory, during compilation it is compiled into executable and you distribute executable. Another way is to link with dynamic version of this library (*.so) if it exists and make a package with your program for target Linux distribution(s) with a dependency from a package with libcurlcpp.so (once again, if this exists). If you have questions about packaging, open a separate question and post a link here. :) – yaromir Jul 4 '14 at 23:46
0

You could simply copy the headers provided in your /usr/include path. No? Obviously don't forget to link the library when you compile your sources. I tried and it works like a charm!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.