LibCurl: how do I compile the example code?

7,204
  1. copy the source file to a directory where you have write permissions (so that the compiler is able to create the executable) e.g.

    mkdir ~/src && cd ~/src
    cp /usr/share/doc/libcurl4-doc/examples/ftpget.c ./
    
  2. compile and link the file using gcc

    gcc -Wall -o ftpget ftpget.c -lcurl
    

This will create an executable called ftpget which you should be able to run from the current directory using ./ftpget

Share:
7,204

Related videos on Youtube

Admin
Author by

Admin

Updated on September 18, 2022

Comments

  • Admin
    Admin almost 2 years

    I have install libcurl by running:

    sudo apt-get install libcurl4-gnutls-dev

    Now, the folder locates at my /usr/share/doc/libcurl4-gnutls-dev/examples$.

    Say I want to compile ftpget.c. How do I do that?