Manifest for my own (native) DLL - visual-c++

NOTE: This question is not about MFC/CRT DLL linking with/without .manifest file, avoiding manifest-lookup (i.e. force load from current path), VC redist installation and similar issues.
I have set of DLLs, which is used by different applications. These applications and the DLL have some product version (like 7.0, 8.0 etc). To summarize, let me use one DLL, and two applications.
App.exe depends on Core.DLL
GoodApp.exe also depends on Core.DLL
App.EXE of version 7.0 would need Core.DLL of version 7.0. Similary, GoodApp of version X, would need DLL of version X.
Since DLL is to be shared by different applications, I have put the DLL into some common path. This avoids DLL to be pasted on all paths. Some \SharedDLL path is setup for this. And (assume), I have set up PATH variable for this.
So, when any of application would load, OS will simply load the Core.DLL from this common path.
All fine. But what if App.exe is 64-bit/Debug, or other configuration? The common-DLL path cannot have all DLLs (32/64, Debug/Release). On the similar lines, App.exe of version Y, cannot use Core.DLL of version X (It is not that X>Y, or Y>X, but just that X!=Y, and App of X version cannot use DLL of version Y).
In short, App-32bit-Release-VersionX, would need exactly DLL-32bit-Release-VersionX, and nothing else! Since DLL name is same, I cannot put them into one common path. And since, there are dozens of applications (and DLLs too!) that depends on Core.DLL, I just don't want to waste space and time for copying the DLL into EXE's path.
Yes, I use post-build-setup to copy the DLL into all paths, appropriately. This solves time, but waste space. And if new application comes in, PBS must be modified to copy to that new path also.
Question is: How to utilizie the .manifest feature, used by Windows/MFC/CRT DLLs? They do utilize WinSxS folder for such thing.

Maybe this will help you:
How to: Embed a Manifest Inside a C/C++ Application,
Manifest Generation in Visual Studio
Working with Visual Studios C++ manifest files
Also follow the links in those pages

Related

vc60.pdb hell with Visual C++ 6.0

We have a C++ 6.0 (stuck there for many reasons) application that uses COM heavily, and I have one of the COM servers (an EXE) that loads 5 or 6 DLLs. In attempting to debug this monstrosity, I get a pop-up on the first breakpoint that demands I "enter the path for vc60.pdb." The file is in both the source folder and the executable folder, but MS insists "A file with the correct name was found in this directory, but it is not the correct one."
I have verified the copy in both folders IS the copy that is created when the project is built, so I don't know where the "correct one" it is asking for is hiding. Of course, without this file, debugging is almost useless, as you can not view any symbols other than local integers, etc. Even custom classes defined within the project itself cannot be viewed.
Anyone know of (or if there is) a way around compiler stupidity?
Thanks in advance.

Including files in VS 2012

I want to include a library - I've downloaded it and found exactly four files inside:
.h
.lib
.dll
.def
I've put the header file inside of my project. That's the only thing I did - and the visual throws an error that it cannot open the .lib file.
So I immediately wanted to beg for help on stackoverflow, but I've decided to do a little research first. I've found out that the .dll file should be placed inside of the windows/SYSWOW64 location (for my 64-bit windows 7), I placed it there but VS still displays the same error.
How should I deal with that? Did I missed some step during the "installation"? If so, which ones?
You have to specify the path to the library (*.lib) in your project settings.
(You can put it also into your directory with sources)
The presence of DLL file during build is not required.

Compiling Libpng in Windows 7 or getting a hold of Libpng12.dll (and understanding how to link .DLL in VS)

I've been using Libpng15 in Windows 7, but I've been getting errors in relation to the
Unresolved External _png_set_longjmp_fn error when I compile my code. I followed the directions in the aforementioned link, and while it DID compile without any errors, I wound up with a message saying that I needed libpng12.dll to continue.
So, I did some Googling for libpng12.dll...nothing came up but generic "find x.dll" websites which appeared to be scams.
I've tried reading the INSTALL docs for the libpng source code on their website, and all that I see is instructions on how to do it via Unix based systems. I tried to do this in Cygwin with no luck, so I'm kind of stuck on how to compile this library.
All in all, I'm willing to do either the compilation or just using the .dll, though the problem is that I can't find a working .dll for version 12.
Another thing I tried was downloading binaries from here, which claimed to be "libpng12 for windows". I then copied the files into my VC compiler directory, which overrode libpng15, I think. Still, when I link against it statically and run my program in VC, it says that I require the .DLL file. The libpng12.dll file was in fact a .dll.a file instead. I honestly am not sure to link these (I tried linking it statically by typing "libpng12.dll.a" in the Linker Input setting through VS).
If I can go the .dll route for libpng12, how do I do this? Where is the file? How do I link it in VS?
Any help would be appreciated, as it seems there really isn't a whole lot of information on this. Either that, or I'm just not looking properly.
Look in the "projects" directory of the libpng distribution, and use one of the visual projects.
As mentioned above Look in the "projects" directory of the libpng distribution
Then make the adjustments outlined here
https://stackoverflow.com/a/38547948/293792
Which I note here for simplicities sake
(as stated there) adding two lib values to
Config -> Linker -> Input -> Additional Dependencies
these values are ucrt.lib;vcruntime.lib
Ensuring the build type is /MD
Allowed me to build these older versions, and fix that error on Windows 10 VS2015.
This link seems to have an installer for 1.2 for you:
http://gnuwin32.sourceforge.net/packages/libpng.htm
it's 32 bit. Not sure if that makes a difference for you.

(How) does a cmake configuration differ conceptually from a Visual-C++ project file?

To get from C++ sourcecode to a binary module, the process is roughly as follows:
set_of_source_files[a.cpp, b.cpp, ...] // conceptually, it doesn't matter where these are
||
|| Compiler <- [compiler_settings]
\/
set_of_object_files
||
|| Linker <- [linker_settings]
\/
binary module (dynamic library or executable)
Now, I know Visual Studio projects, they
Define a set of source files (directory structure and layout basically doesn't matter / is defined inside the project file)
Define the compiler settings for all (optionally each) of the source files
Define the linker settings
Define where to put generated output files
I don't know cmake, but apparently(?), the info one configures with cmake differs slightly from the info one puts into vc[x]proj files.
Is a "cmake configuration" just a differently formatted "vcproj file" or is there a conceptual difference? (Except for the obvious one (I assume) that the info I put into a cmake configuration is platform independent.)
An alternative twist to this question would be to answer -- in the context of above -- why/if(?) one would switch to cmake when only compiling for Windows with Visual-C++.
Cmake is a cross-platform make -- it starts from a set of source files and a relatively abstract set of directions about what to do with them. Based on those, it generates a set of platform-specific files. If you specify Windows/Visual Studio as the target, it can/will generate a vx[x]proj file for you to use.
Even if you're only using Visual C++ on Windows, it's possible you could benefit from cmake. The obvious possibility would be if you want to target a number of different versions of Visual Studio, and be able to directly generate the correct files for each, instead of generating files for the oldest version you want to support, and then depend on Visual Studio's upgrade feature to convert those to the target version.
Based on my experience with VS's upgrade capability (not particularly great), I'd say that could/would be a reasonable and valid use.

Visual C++ 2008 Express - cpp filename conflict

I'm developing application for GNU/Linux using gcc 4 and cmake to manage compilation process. I found that is has no problems when there are two files with the same name but in other directory and namespace like this:
.
|-- gfx
| |-- Object.cpp
| `-- Object.h
`-- logic
|-- Object.cpp
`-- Object.h
First Object class is in Gfx namespace and second in Logic namespace.
Then I've tried to compile this project using Visual C++ 2008 Express Edition. Linker threw several errors about non-existing implementation of Gfx::Object class. After few checks I found out that:
Visual C++ is tracking two of Object.cpp files
When change occurs in first or second file the recompilation of Object unit is queued
It always recompile only the second Object.cpp regardless of which file was actually modified
I also found out that Visual C++ don't allow to create two classes with same name.
Is there a solution for this? I don't really want to refactor quite big part of code.
Both Object.cpp files will be compiled to Object.obj. Into the same directory. In other words, the last one that is compiled will overwrite the Object.obj of the first one. Yes, the linker isn't going to be thrilled by that, you'll get multiply defined symbols since it links the same Object.obj file twice.
The fix is easy, right-click one of the Object.cpp files, Properties, C/C++, Output Files. Change the Object File Name from $(IntDir)\ to, say, $(IntDir)\$(InputName)2.obj
The problem is that by default VC++2008 places all the object files into a single output folder, so the existence of the first object.obj file satisfies the dependency for the second so it is not compiled; and even if it were, it would overwrite the first one.
What you need to be able to do is make the intermediate directory setting dependent in the file being compiled. However I have tried setting it to $(InputDir) and various other combinations, but could not succeed in achieving a configuration that works, although it may be possible. The available macros are documented here.
Failing that you could use a "makefile" project, and manage the build with make, nmake, or cmake or whatever, since there is nothing fundamentally wrong with what you are doing (even if it is ill-advised), it is just that it is not easily supported by the IDE.
This has already been answered, but I also want to add Visual Studio 2010 will automatically put the two .obj files into different directories if there is a conflict, based on my experience with Beta 2.
EDIT: Uh oh, this is wrong! The real answer is that CMake was automatically doing this for me.
The accepted solution is not optimal because it does not scale.
In Visual Studio 2010, I set
Properties -> C/C++ -> Output Files -> Output File Name
to
V:\%(Directory)$(PlatformName)_$(ConfigurationName)_%(Filename).obj
for OBJ files to end up next to the sources assuming the project lies on drive V (no idea whether there is a macro for it, yet).
Not optimal, either - but at least I can easily fork subsystems of many source files without getting tenosynovitis.
By the way: $(InputDir) refers to the solution/project directory and will cause the same problem in another directory.

Resources