Howto use on bcc32 an static lib built with bcc32c - c++11

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.

Related

compiling static library issue

I'm creating a static library with some frameworks and a third part static library.
To avoid the conflicting problem, how to manage the static library when I release the library ?
And if my library users has import the same frameworks, when I compiling the static library, should I select the link binary?

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.

Qt - linking an external static lib that uses WinBase

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.

Linker doesn't use a default runtime library when linking together libraries only (no objects)

I want the users to be able to re-link my Qt-using application to their own build of Qt, without being forced to rebuild all of the sources. This could be used for LGPL compliance, for example. To do this, I need to provide object files for all of my sources. To make it easy, using qmake, I've partitioned the project internally into:
A static library project that contains objects for all of the source files, including the file that has int main(int, char**).
An application project that links the static library above with Qt. Qt may be either a static library or dynamic. There are no source files for this project.
I then distribute the static library (.lib) and the application project file so that anyone can relink the application with their own version of Qt, in whichever fashion they prefer (either statically linked Qt or dynamically linked Qt), as long as they have the necessary version of MSVC.
I'm doing the build under both MSVC 2008 (Qt 4) and 2012 (Qt 5). The makefiles are generated by qmake.
The problem is that the linking fails when building the application project.
LINK : error LNK2001: unresolved external symbol _WinMainCRTStartup
As soon as I add a dummy source file dummy.cpp to the application project, the linking succeeds. Is there a way of avoiding this workaround?
//dummy.cpp (this is the entire source)
int dummy;
It turns out that the linker isn't clever enough to figure out what default runtime library is needed for the executable if only static libraries are given to link, with no discrete object files. This can be corroborated by asking the linker to be verbose in the .pro file:
win32-msvc*: QMAKE_LFLAGS += /VERBOSE /VERBOSE:LIB /VERBOSE:REF
When the dummy file is present in the application project, the linker lists the following default libraries:
Processed /DEFAULTLIB:msvcprt
Processed /DEFAULTLIB:MSVCRT
Processed /DEFAULTLIB:OLDNAMES
Processed /DEFAULTLIB:uuid.lib
Without the dummy file, no default libraries are chosen by the linker at all. It is then unable to find the entry point, since the C runtime is not linked in.
Adding the relevant C runtime library is sufficient to link the application. In the application project file, one adds:
win32-msvc*:CONFIG(release, debug|release): QMAKE_LFLAGS += /DEFAULTLIB:msvcrt
win32-msvc*:CONFIG(debug, debug|release): QMAKE_LFLAGS += /DEFAULTLIB:msvcrtd

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.

Resources