0

Libraries like curl require you to have .dll files when running .exe

In theory you should be able to link those .dll statically to the .exe

But I can't find a way to do that without errors and crashes.

But are there libraries which don't require external .dll files at runtime? That allow me to do a HTTP request?

user88888
  • 151
  • 1
  • 1
  • 6
  • Have a look at this question: http://stackoverflow.com/questions/3411259/using-libcurl-without-dll – Mike Dinescu Sep 27 '13 at 02:33
  • @MikyDinescu That didn't work! I can't find a way to do that without errors. See my question here: http://stackoverflow.com/questions/19040583/compile-curllib-static-dll-completely-without-dll-dependency?lq=1 – user88888 Sep 27 '13 at 02:34
  • "This question may already have an answer here: Compile curllib_static.dll completely without dll dependency?" No, there are 0 answers there – user88888 Sep 27 '13 at 03:57

2 Answers2

1

Libraries like curl require you to have .dll files when running .exe In theory you should be able to link those .dll statically to the .exe

No you can't. They are dynamic link libraries. DLLs can't be linked statically. If the supplier also supplies a static .lib file, you can link that instead of the DLL. It isn't the same thing.

But I can't find a way to do that without errors and crashes.

Unsuprising, as there isn't one.

But are there libraries which don't require external .dll files at runtime? That allow me to do a HTTP request?

Very likely, but why? What's your objection to DLLs?

user207421
  • 305,947
  • 44
  • 307
  • 483
  • Well, if you checked my other question, it does mention '.lib' files, but even when you include those '.lib' the '.exe' still asks for the '.dll' files – user88888 Sep 27 '13 at 02:58
  • I want to build a portable app without DLLs – user88888 Sep 27 '13 at 03:24
  • I am answering *this* question. If there is information missing from it that affects the range of correct answers, post it *here.* Don't expect people to chase you all over the site, or the Internet. They won't. There are static .libs, which is what I am talking about, and dynamic .libs, which is obviously what you still have, hence the need for the corresponding DLLs. You still haven't stated *why* you don't want DLLs; you've only reiterated that you don't. 'Portable app' doesn't add any information. No Windows application is portable off Windows anyway. – user207421 Sep 27 '13 at 03:47
  • @user88888 you would like a single executable for distribution? You can make an self-extractor out of your code and dependencies (dlls, graphics, etc). See http://portableapps.com/. – leesei Sep 27 '13 at 03:48
  • @leesei Which self-extractor do you suggest? – user88888 Sep 27 '13 at 05:00
  • If you like an installer interface (this may be and overkill for your use case), try [NSIS](http://nsis.sourceforge.net/Main_Page). If you merely need a self extracting exe, follow [this](http://www.wikihow.com/Use-7Zip-to-Create-Self-Extracting-excutables). And Google is your friend. – leesei Sep 27 '13 at 05:55
1

From my experience, the .lib you are linking is not the dll's implementation, it just contains some metainfo on the dll.

If you are trying to convert a .dll to a .lib, this may help (but it is daunting):

http://adrianhenke.wordpress.com/2008/12/05/create-lib-file-from-dll/

If everything fails, you should consider compiling static version of libcurl on you own

http://fluxxu.com/2010/12/08/building-static-libcurl-with-ssl-support-on-windows/ (note: export CURL_STATICLIB in your app)

Building libcurl with SSL support on Windows

Community
  • 1
  • 1
leesei
  • 6,020
  • 2
  • 29
  • 51
  • Are you sure the '.lib' files inside libcurl-7.19.3-win32-ssl-msvc are incomplete? – user88888 Sep 27 '13 at 03:48
  • I've not used Window's libcurl. Can you check the size of them? – leesei Sep 27 '13 at 03:50
  • @user88888 If using any specific .lib requires the corresponding .dll to be loaded, *obviously* it is 'incomplete'. You can tell by the size. Static .libs are very large, dynamic .libs are small. – user207421 Sep 27 '13 at 03:51
  • I extracted the package and see a `curllib_static.lib` in `lib\Release\` which is 1.8Mb. Could you try that? – leesei Sep 27 '13 at 03:55
  • @user88888 I see, we thought you're linking the `libcurl_imp.lib`. – leesei Sep 27 '13 at 04:00
  • That conversion method requires you to write a regex to filter all the function calls... (there a thousands of them...) Isn't there an easier way??? – user88888 Sep 27 '13 at 04:03
  • Compiling from source? Reference added. – leesei Sep 27 '13 at 04:05
  • On compiling from source, MORE ERRORS: http://stackoverflow.com/questions/19041439/vs2012-nmake-is-not-recognized-as-an-internal-or-external-command – user88888 Sep 27 '13 at 04:06
  • This is getting out of hand. You shouldn't have to change anything in your own source code, just link with a static .lib file. Which exactly are the DLLs that are being loaded when you do that? – user207421 Sep 27 '13 at 04:06
  • @leesei: Try what? I already included curllib_static.lib AND those other .lib files ( libeay32.lib, libeay32.lib, libeay32.lib) in my VS2012 project – user88888 Sep 27 '13 at 04:11
  • @EJP: After linking the .lib files ( libeay32.lib, libeay32.lib, libeay32.lib) and compiling the .exe, it still asks for libeay32.dll, openldap.dll, ssleay32.dll, etc at runtime – user88888 Sep 27 '13 at 04:12
  • So *those* are the components that you need static .libs for, not Curl. Surely this is obvious? – user207421 Sep 27 '13 at 04:14
  • I thought I downloaded those .lib files ( libeay32.lib, libeay32.lib, libeay32.lib) here: http://curl.haxx.se/latest.cgi?curl=win32-ssl-devel-msvc – user88888 Sep 27 '13 at 04:19
  • > When building an application that uses the static libcurl library, you must add 'CURL_STATICLIB' to preprocessor. Otherwise the linker will look for dynamic import symbols. From the link I post, did you tried this one? – leesei Sep 27 '13 at 04:26
  • @leesei yes, I have done that as well... I tried to add 'HTTP_ONLY' as well, but that didn't work either. – user88888 Sep 27 '13 at 04:39
  • When building libcurl on Windows On VS2008, it could not find depencies like windows.h – user88888 Sep 27 '13 at 04:42
  • Alas, then I'm out of ideas, sorry ><. Can you reconsider using the .dll as is? – leesei Sep 27 '13 at 04:43