Can not open boost header from my static lib C++ VS - c++

I have created test C++ static library in VS and I am using boost in that.
Now this static lib is used/linked in DLL I have created. Now I want to link this DLL in a c++ console application.
Static lib and DLL both compiles fine. When I am using this dll in console application, I am getting error in static lib's header file that can not open include file #include "boost/config.hpp"
I copied static lib's header and dll's headers in console application and linked through properties/linker/additional library directores
I really dont want any user who are using my dll to link with boost and all. I just want to supply dll and they should be good to use it.
Please guide me. I am dealing with DLL and static lib. for the first time.
So If I include all boost headers in my application, it should be good to use. Is there any other solution?

The header files from your static library are including boost. When you include these in your application, the compiler is looking for the boost includes as well. If the boost declarations are not a part of your library interface, then these includes need to be moved out of header files referenced by your application.

I really dont want any user who are using my dll to link with boost and all. I just want to supply dll and they should be good to use it.
That's pretty much tough, not least because most of Boost is header-only.

Related

Why using this library needs its internal headers?

I have a library A.dll that used google logging library(glog). Now I want to use this library in another project,in my own project I don't want to use glog. I want to just use A.dll, but during compilation, the compiler says that can't find logging.h header!!!
Why this happens?! it is a header that A.dll uses internally and I want to use A's interface not glog. I think that it is enough to include A.h, I don't need logging.h . Am I wrong? any idea that what is the problem?
A.dll is built with MSVC++ 2015 and I am using MSVC++ 2015 in QT Creator.
You haven't included evidence of how and where the glog header files are included in A library.
But we may suppose it is #included in one of the public library header files,
that your project includes to use the library,
so you inderectly get the glog headers dependency.
One of the reasons is that the developers of A library did a bad job and failed in hiding the internal only dependencies.
How to overcame the indirect include dependency?
It depends on how the A library headers are written and if you or the original A library developers can change it to avoid exposure of the internal dependency.

Include curl library for C++ in dll file

I'm writing a dll as a mod for Skyrim, however I need to use an external library as well. The library I need is the curl library for C++ (curlpp). Skyrim will only load the one DLL I create, therefore I need to have the entire library be compiled into the DLL file along with my code. I've never done this before, so I'm kind of lost on how to do this. Could I just copy the files from the curlpp library into my project?
If anyone could clarify the process needed I'd be very grateful.
So to recap, I'll have my own code, and the library. Those 2 should be merged into a single DLL when compiling.
Thanks!
You could include the libcurl library code directly into your DLL, as libcurl is open-source.
Or you could compile libcurl into its own DLL (or find a 3rd party precompiled DLL) and have your DLL statically link to it. That way, if libcurl fails to load at runtime, your mod DLL will also fail to load, which Skyrim can detect and handle as needed.

How to use FFTW DLL import library .lib as a static .lib in my project?

I've knowledge of C++ and compiling small plug-ins (always based on a similar and laid out workflow). Though currently I need to compile the latest version of FFTW into a static library (or get it from the compiled version which should supposedly be a lot easier) and it's giving me an insanely hard time. Probably because I don't know the ins and outs of compiling. As a note I'm working on Windows with Visual Studio.
Since I really want to know how this should work I'm asking the question here.
Basically I need a static .lib of fftw3f library on Windows that I can include in another Visual Studio project.
The first I did was download the 64 bit dll's of FFTW from the website (hoping I could use this).
http://www.fftw.org/install/windows.html
Then I've done the accompanying step they stated, that is:
Run the following in lib.exe.
lib /def:libfftw3-3.def
lib /def:libfftw3f-3.def
lib /def:libfftw3l-3.def
I've done this as well and got a .lib file that I could use in my project correctly. I've been able to compile my project, yet the output build apparently dynamically linked to the library instead of including it as a static library.
I'm compiling my project to .dll but require the fftw3f library to be statically included in my output.
Using lib.exe /list libfftw3f-3.lib I was able to find out that the lib file was referencing the libfftw3f-3.dll.
According to my google results this would mean the .lib file that I created is a DLL import library instead of static library.
It's hard to figure out how to phrase my question because I'm not sure what the terminology is and what's going on behind the scenes. I guess:
How can I use the libfftw3f-3.lib file created from lib.exe as a static library in my own project. So that it is included in my output .dll instead of dynamically linked?
Based on what I learn from comments/answers I'll be happy to update/edit/rephrase my question to make more sense for most other users as I'm likely way of with the terminology
You cannot expect to convert a DLL into a static library.
In order to create a static library you need to re-compile the library from its source code, with an output target that is a static library. If you cannot obtain the source code, then your goal cannot be achieved.

C++: Static and Dynamic libraries ( compiling and running)

I'm working on a library project which is pretty much finished. So I'm giving it a test run now. I have no problem running my test project. However I'm not entirely sure if I'm doing it right. Mainly because I don't really understand what is happening exactly( at least im not entirely sure).
I've compiled both the DLL and Static library(.a). For my test project i'm using the Headers from my library and linking against the static library. I'm able to compile. But then It seems that I also need the DLL where the executable resides in order for it to run.
So to my understanding, I compile using the static library but I don't exactly embed it into my executable, therefor at runtime it's looking for the DLL?
My confusion comes from the fact that I read that static libraries are usually embedded into the executable. But doesn't that only happen if you specify that in the compiler options?
I'm rather confused about the relationship in my sittuation. Can someone clarify this?
Edit:
I'm using GCC.
Codelite as my IDE.
lib is static (cannot be dynamically linked at run time) at compile time. So you are correct that the lib is "embedded" in the executable. More precisely, the lib is linked to other object files that the compiler has produced to build the exe file. A lib cannot link to another lib, only an exe or a dll can link to a lib.
dll is dynamically linked by the exe while the exe is run. dll is like another exe, but its entry function is "dllmain" instead of "main". dll can be built with lib's just like exe. dll can also link to other dll's at runtime to interface with these dlls' functionalities. The interface to dll is defined by a def file.
As to why your project would need the dll, you might want to check the calls of LoadLibrary in your project.

when you create C++ shared library do you need to attach only headers of what your lib would depend?

So I create a library. I want to use shared ffmpeg libs. On mac os with xcode. I create project file with premake4. Shall I connectshared libs to my project or shall I only connect includes?
If I understand your question correctly, you're asking if you need both the shared libraries and the headers, or just the headers, for your project to work.
You need both. The libraries are generally were the actual code for the functions and classes declared in the headers lives. Your project will compile just fine with only the headers present, but unless there is corresponding code in a lib or shared lib, you can count on linker errors.
I have to say I'm not familiar with the actual build process on OS X, but I believe the above is inherent to any C/C++ project regardless of OS.
Also, since you're probably working with the Standard Library you might have the impression that all you're doing is #includeing headers (iostream, stdio.h, etc), but the libraries are still there and have been added by default by your IDE.