Qt - linking an external static lib that uses WinBase - windows

I'm trying to build a GUI using Qt 5.3.1 and having that link to a static lib (built with VisualStudio 2010 using /MD and /MDd). When linking in QtCreator IDE, I get 2 unresolved external linker errors generated from these two function calls from within the static lib.
Both of these (unresolved) functions are declared in WinBase.h.
::InitializeSecurityDescriptor
::SetSecurityDescriptorDacl
What is the easiest solution to get QtCreator to compile this lib? Ideally if possible, I'd like to also link whatever dependency in the static lib itself.

As the documentation of both functions specifies, you have to link against advapi32.lib. In general, all functions of the Windows SDK specify in a box at the end of the documentation the header where they are declared, the header that you should actually include and their import library.
As for the other dependencies, AFAIK there's no way to know - static libraries are just collections of object modules, that specify their dependencies only in terms of imported functions.

Related

Howto use on bcc32 an static lib built with bcc32c

I need to use a C++11 library on a bcc32 project.
The library doesn't compile with bcc32, but does with bcc32c.
I would like to prevent exposing this library on a DLL. The library compiles with bcc32c, but I wasn't able to use bcc32c static libs on bcc32 projects.
Static libraries are compiler-specific. You cannot make a static lib in one compiler and use it in another compiler. Your only options are to either wrap the static lib inside a DLL, or else change the library's code to address whatever is preventing it from compiling in bcc32.

Static Library in a Project: Why the frameworks used by the static library needs to be added also to the Project?

I am developing a static library, which is added to my main project that tests the static library's functions. The static library inside is using some 3rd party components, and this third party components needs to add some additional libraries (e.g.: libz.dylib, SystemConfiguration.Framework). It's fine, but when I try to build my main project that contains my static library, I got bunch of linker errors. I figured out, if I add the same frameworks and libraries to the main projects what I needed to add to my static library, the linker errors disappear and the project is built succesfully. The question is do I really need to add all of those resources to the main Project? I find it crazy that if I give my static library to someone else to use, I need to include a bunch of frameworks and libraries in the documentation that has to be added also in the integrator project? Or am I missing something important?
It's because a static library is not linked, unlike an executable or dynamic library.
A static library is just an archive of object files, and object files contain external references to symbols they use. Those references are not resolved until the executable/dynamic library is linked.
Therefore when you link-in a static library you are responsible for providing any dependant libraries to the linker, which can themselves be either static or dynamic.

how to link staticially with third party libraries in visual studio 2010?

I am wondering how to link third party libraries in visual studio?
the third party I mean they gave you *.dll, *.lib and *.pdb.
for example, zmq:
lib/
libzmq-v100-mt-gd-3_2_4.lib (static library)
libzmq-v100-mt-gd-3_2_4.pdb (debug file)
bin/
libzmq-v100-mt-gd-3_2_4.dll (dynamic library)
my vs project need libzmq, and I want to link zmq statically. however, I looked
at project property pages. there is no option to allow us force the program linked statically or dynamically. (perhaps, I missed something)
I set linker/general, linker/input, c_c++/general (include) to the corresponding zmq path. But, it does not work.
libzmq-v100-mt-gd-3_2_4.lib in this case is the import library rather than the full static library. Linking against libzmq-v100-mt-gd-3_2_4.lib will result in your application requiring libzmq-v100-mt-gd-3_2_4.dll.
You'll need to either build a static library from source if they don't provide one, or use it as a DLL.

Compiling a C++ library both as a static lib and dynamic dll with VS

I need to compile an existing C++ library both as a lib and a dll, and then use the static and dynamic libraries in different applications. I use VS2010.
What I can't do is to edit all the header files in order to add __declspec(dllexport) instructions to export, as the library must be kept as it is.
Under Mac I was able to compile and use a dylib without problems, but I know that VS is lacking in this regard.
In VS is it feasible to compile a static lib first and then a dll in order to have functions "exported" (i.e. linkable from an application at compilation time)? In other words, can I use the static lib as if was the export lib generated with __declspec(dllexport)?
Are there better workarounds?
I need to compile an existing C++ library both as a lib and a dll, and
then use the static and dynamic libraries in different applications. I
use VS2010.
Create configurations for that. For example Release LIB, Release DLL, etc.
What I can't do is to edit all the header files in order to add
__declspec(dllexport) instructions to export, as the library must be
kept as it is.
Simply add module definition file (*.def) with a list of exported functions.
In other words, can I use the static lib as if was the export lib
generated with __declspec(dllexport)?
No, those libs are different. When you build a DLL you get a binary and a lib files.

Dependency on VCOMP90.DLL in VS2008 Pro OpenMP project

I have a DLL project in VS 2008 Pro which uses OpenMP. I use /MT as 'code generation' option, because I want all my dependencies statically linked into my DLL, since I do not want to distribute many libraries to my clients - everything shall be included in this one DLL file. The problem is that my resulting DLL still depends on VCOMP90.DLL.
How can I get rid of this dependency?
Some information:
/openmp is set in compiler options
I statically link against vcomp.lib
include is set
using multithreaded library (/MT)
Thanks a lot for your help!
I don't think you'll be able to get rid of the DLL dependency - vcomp.lib is an import library for the VCOMP90.DLL - it's not a static library:
http://msdn.microsoft.com/en-us/library/0h7x01y0.aspx
It doesn't look like a static lib is provided.

Resources