I'm new to developing in C++. I've developed a dll where I'm using curllib to make HTTP requests.
When running the dll via depend.exe it notifies me that my dll now depends on the curllib.dll. This simply doesn't work for me. My dll is set as a static library not shared and will be distributed on its own. I cannot rely on a user having libcurl.dll installed.
I thought by including libcurl into my project this is all that would be needed and my dll could be independent.
If this is impossible to resolve is there an alternative method I can use to create HTTP requests? Obviously I would prefer to use libcurl.
Thanks in advance.
You can compile curl as a lib instead of a dll by opening the solution file in visual studio and changing the build project to "lib release". Thus you wont need the dll at all and you can just include the lib in the linker.
Related
Problem
How can I distribute a c++ library as source code along with the source code of libcurl and let the consumer of the library handle building it as needed? I'm using FastBuild as a build system.
Context
I have a C++ library that I distribute as source and let the clients handle building it along with their code.
The repo includes the source for a dependency as well, tinyxml, which is built along with the library itself thus becoming completely transparent for the clients.
It has worked fine up to now but clearly does not scale well for more complex dependencies, such as libcurl.
Things I've considered as an alternative to bundling libcurl's source
have pre-compiled libraries of libcurl. But I don't know which platforms/flags the consumer is going to use
have libcurl installed on the build machine. It would require extra setup steps for the consumer, it won't be just pulling the code and using
Edit 1: Update with build system
You didn't mention which build system are you using.
If you are using cmake, you can make use of ExternalProject_Add to download/build/install the dependent library.
See examples:
https://cmake.org/cmake/help/git-stage/module/ExternalProject.html#examples
If I understand you correctly you need that any client who obtains source code of your library would be able to also obtain corresponding source code of libcurl and tinyxml libraries.
Personally I would use cmake for that purpose as #brokenfoot has already suggested. But instead of ExternalProject_Add it seems that in your case FetchContent would be enough and less complicated: https://cmake.org/cmake/help/latest/module/FetchContent.html
I have written windows gui application using qt and i want to deploy it.Now when i place .exe to other PC it shows error which says that qt5core.dll and etc required.I can install this dll,but is it possible to run exe app with qt without qt's dll as one file?So i can for example give .exe to my friend and he can instantly run it without installing .dll?
Basically, if you want a single exe file, you probably mean static linking.
The legal commercial version makes it possible or if I am not wrong, you will have to build a static qt version.
In the latter case, you will have to provide the source code of your application.
I do this sometimes, but you'll have to be careful with the license requirements: if you go with GPL, it should be OK, if you choose LGPL, it may be a bit less simple. No idea about the commercial version.
What you must do is building Qt statically, and then use that Qt build to build your application. I had a good experience with mxe. MXE builds an entire crossbuild environment and allows you to build your big Qt exe statically. I used it on Mac OS and Linux to build static executables for Windows, but you can probably run it on WSL. It takes a bit to compile, but it is simple to use. Please note that it cannot be used if your app needs QtWebEngine as it won't build with mingw.
Another simpler option is to create an installer. The Qt installer framework is simple to use. If you include the VS runtime, you end up with a single exe to distribute (the installer).
You always need to include the libraries you use (including your compilers runtime libraries in fact) when you deploy your executable - otherwise how would your application be able to use the code in those libraries? You may be able to statically link some/most things, but rarely everything. Look into how to create an installer / package for your application, so you can bundle up everything as one convenient file.
You can buid you app using QT Static (a large .exe file, no external dependencies)
If you are using LGPL Qt, you must read this:
https://www.qt.io/faq/3.7.-what-are-my-obligations-when-using-qt-under-the-lgpl
Yo can use Qt and static linking, but "The user of your application has to be able to re-link your application against a different or modified version of the Qt library"
You can use an application template like this, very useful for LGPL Qt:
https://marketplace.qt.io/products/qt-lgpl-app-template
We have .NET application which uses C++ library via [DllImport]. It works fine on many computers (thousands of customers) excepting 3 computers. All of them have Windows 10 installed (other Windows 10 platforms work fine).
The exception is:
System.DllNotFoundException: Unable to load DLL 'Helper.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
This dll places in the same folder as main executable file.
What already done to fix:
put DLL in system32 folder;
installed different version of vc redist;
run as administrator.
The result is the same.
Any ideas, guys?
Thanks in advance!
Don't put the DLL in the system directory. You aren't supposed to put files there. Put the DLL in the same directory as the executable.
If you do that and the system reports DllNotFoundException that means one of the DLL's dependencies could not be found. Next you need to find out what the dependencies are, and make sure that they are all met.
You can use a tool like Dependency Viewer to check the dependencies, but really the best way to do this is to go to the source. Either the documentation of the library if it is a third party library, or direct from the source code and compilation options if you have built the DLL yourself.
I am fairly new to the C++ dependency management through libraries and dlls.
I fully understand the difference between static and dynamic linking(I guess) which is why I am asking this, as common answers usually relate to issues with not understanding the difference.
I'm using visual studio and my current project is set up like this:
Bridge project: this is a dll project that exports a few classes. This serves as a shared library for bridge between networking code and application code.
Naturally, it has its own dependencies (ZMQ network library, MsgPack serialization, ...) which are statically linked (using .lib files). My .dll is generated normally and it's exported .lib file too. (Before I switched to dll project I kept compiling it as .exe to test the code as I coded...)
App project: This project is an application project and would like to use the bridge to gain full access to networking functionality via bridge. So I add the .lib dependency to it and I know I will have to supply the .dll to the .exe
However my problem is, that the application will not compile, because it is missing header files from ZMQ(which are a bridge .dll dependencies, and not relevant to the app at all, since only bridge internal BL uses them).
Is there any way I can "bake"/include all my required dependencies to the bridge dll (ZMQ, MsgPack, Log4cpp ....) and provided -just- the bridge.dll to the app (ofc, with bridge.lib as a library input)?
Am I misunderstanding something obvious here and am going at this completely the wrong way?
Thanks for help, greatly appreciated :)
I solved the issue so I am gonna write up an answer to my problem.
Many thanks to all that helped, especially #Öö Tiib, #Joachim Pileborg.
The problem was that I included "private" libraries in my public bridge library. (I included "zmq.h" in bridge.h).
Since my header file does not contain anything from that library I have moved the "zmq.h" include to the bridge.cpp file.
I have compiled my Qt application and now have the following question - now my built project requires QtCore4.dll and QtGui4.dll to be located at the same folder where the .exe file is. (I built my project using MSVS2008 with Qt addon)
Q:
Is there any way to combine my final application with these .dll files so that they make one large .exe-file? (I simply don't want to have another bunch of dll files with my release - app)
Thank you.
You need to build and link to Qt statically.
Edit: Here's an updated link to at least similar information.
Bundle them into a self-extracting .exe (e.g. using 7zip) which extracts all files to a temporary directory, runs the program, then deletes the files after the program exits.
This will be easier, less time consuming and less legally constraining than statically linking Qt as previously suggested.
Of course you could statically link someway. But the point of using DLL should be to make program smaller (both on disk and in memory, if other apps are using Qt libs of course)... DLL such as those should be systemwide so that other apps needing them can use them. Basically you have to say to people wanting your program to work, to install the Qt framework.
Deploying the other way is explained here, read the part related to Static Linking.