So I have a library I am using as a .lib and I also have the .dll version of it. Whenever I run the exe I have coded in c++ it requires the .dll of the library. Is there any way to avoid this? I remember in the past I was able to have the library be compiled inside of the exe but I cannot recall how I achieved that.
Asked
Active
Viewed 370 times
1
-
Your question needs clarification (and punctuation!). You even didn't tell what's your programming language. – Steve B Jan 25 '21 at 14:54
-
1There are two kinds of libraries, import libraries try to load a DLL at run time, and static libraries which don't. Clearly at present you are using an import library. If you want to do without the dll then you are going to have to find a corresponding static library. If that doesn't exist then there's nothing you can do. – john Jan 25 '21 at 15:09
1 Answers
0
what build system are you using? The problem is arising as you are linking to the .dll file, not the .lib file. You will have to tell your linker which version he should use, this is an option in CMake or VS (or whatever you use). See: https://learn.microsoft.com/en-us/cpp/build/walkthrough-creating-and-using-a-static-library-cpp?view=msvc-160.
Edit: Usually, you cannot use a .dll as a .lib or vice-versa. These are two very different things. You will have to find a .lib version of the library you are using, and link against that.

BarFoo
- 1
- 3
-
-
Yes, you do not directly link. DLL = Dynamically Linked Library. You tell the linker that the code will be linked at runtime. – BarFoo Jan 25 '21 at 15:09
-
The problem I am having is I have libcurl_imp.lib in the Additional Dependencies so it builds but when I run the exe outside of Visual Studio it requires the libcurl.dll which is not what I want. – helpme Jan 25 '21 at 15:09
-
1You can check this out too: https://stackoverflow.com/questions/20985631/static-library-of-libcurl-on-windows – BarFoo Jan 25 '21 at 15:14
-
Thanks but that is also part of the problem, I have a dll which uses pipes to communicate with my exe and that dll uses a hooking library which makes the dll only load if the library dll is present (like the libcurl problem). The library is called PolyHook. – helpme Jan 25 '21 at 15:25
-
@helpme libcurl_imp.lib is an *import* library, it just a "bridge" between the exe and the dll. If you want to link with curl statically, you need a static curl library. – Igor R. Jan 25 '21 at 15:33