title: Create a fully static Libcurl library
body: <p>First I'll explain the big picture :</p>
  
  <p>I am creating an application where I separated most of the features in different libraries. One of them contains some classes that use curl. I actually use Ubuntu 64 bit to develop and test it, but my production environment is a NAS with an ARM processor. I intend to, later, also make it for windows.</p>
  
  <p><strong>Where I am now :</strong></p>
  
  <p>My application is running on linux and the ARM-based NAS. However, I don't link with curl, I use curl from command-line internally to do what I need. This has some drawbacks :</p>
  
  <ul>
  <li>As a programmer, I consider it an ugly practice. I should link to libcurl, this is the normal and clean way of using features from other software components.</li>
  <li>This implies that curl executable is installed on the target. Not only I don't want to rely on this but also after a system upgrade on the NAS, I found out that I can't rely anymore on this.</li>
  </ul>
  
  <p><strong>What I want</strong></p>
  
  <p>As I intended anyway to use curl as a library, I first tried to do it the "soft way" : dynamic linking. Although it worked on my development environment, it didn't work on the production one because I found out that the curl library installed there doesn't work as expected.</p>
  
  <p>So my next try was using libcurl as a static library. I also considered it to be the best future-proof option for me as it would make sure that, either on the NAS or on any other system, the library I will be using will always be the same.</p>
  
  <p><strong>The problems I've solved so far</strong></p>
  
  <ul>
  <li>Including a static library in another static library</li>
  </ul>
  
  <p>This is already well documented in other answers here in StackOverflow : <a href="https://stackoverflow.com/questions/3821916/how-to-merge-two-ar-static-libraries-into-one/23621751#23621751">How to merge two &quot;ar&quot; static libraries into one</a></p>
  
  <p>I did this to create a combined library of my own one and libcurl and as far as I've checked, it worked.</p>
  
  <ul>
  <li>Building libcurl statically from source</li>
  </ul>
  
  <p>There also are other answers that cover this topic, and I managed to create a libcurl.a that has <strong>libcurl features only</strong>.</p>
  
  <p><strong>The problems I am still trying to solve</strong></p>
  
  <ul>
  <li>Building libcurl statically <strong>with all its dependencies</strong></li>
  </ul>
  
  <p>There are some information regarding this, for example <a href="https://curl.haxx.se/mail/archive-2003-05/0041.html" rel="nofollow noreferrer" title="here">here</a>. I did what was suggested, calling the configure script with --disable-shared and --enable-static. I also did the "rm src/curl" before make and called make with LDFLAGS=-all-static, but the resulting libcurl still missed its dependencies (openssl, pthreads, zlib...).
  If I could solve this problem, it would answer my question. But not having succesfully done that, I tried another approach :</p>
  
  <ul>
  <li>Manually merging all libcurl dependencies in a final lib</li>
  </ul>
  
  <p>As I did for merging my library with libcurl into a new library, I also tried do add to it curl dependencies : zlib and openssl. So I compiled both from source to create static libraries and included them in the merge. I was not able to fully check the result as it seems that another one is missing : pthread. And I was not able to find pthread for downloading - compiling - static linking.</p>
  
  <p>Looking at the big picture, my main problem is : how to I include curl in my final application so that there is no external dependency to it?</p>
  
  <p>I think that if either of my two remaining problems would be solved, I would be solving my main problem. But if it is not the case, I also would be glad to hear from someone who knows a better way of solving this, or ideally already solved a similar issue.</p>