Cannot register COM DLL built with VS2012/VC++ on 32-bit machine - visual-c++

I built a C++ based COM object using Visual Studio 2012. It registers and works fine on 64-bit machines (called by 32-bit code and calling a 32-bit out-of-process COM server) but does not register on 32-bit machines (neither XP nor Win7 32-bit). The message from regsvr32 is
LoadLibrary("comobj.dll") failed - The specified procedure could not be found.
The project was originally built with Visual Studio 6 (7 years ago). It uses ATL macros such as BEGIN_COM_MAP and BEGIN_SINK_MAP to declare its implementation of various interfaces. It had to be re-compiled because the COM server it was invoking changed (new ProgID, new GUID, new type library, etc). Other than making those adjustments, and using current VS, there were no (intentional) changes -- there certainly was nothing in the old equivalent of the project file that would have pointed to 64-bitness.
Examining the DLL with the 64-bit version of DEPENDS.EXE shows "64" icons next to the standard referenced DLLs like KERNEL32 and USER32. Other than having built the DLL on a 64-bit machine, there is nothing "64-bit" about the DLL that I can find. The target is explicitly Win32 (not X64).
Examining the DLL with the 32-bit version of DEPENDS.EXE (on Windows XP running under Virtual PC) shows KERNEL32.DLL with a red icon, apparently because there are references to FlsAlloc FlsFree FlsGetValue FlsSetValue that do not exist in the 32-bit KERNEL32.DLL. (I have no idea what those are and don't know where those references come from -- perhaps from the copy of MFC on the 64-bit machine where the compile was done?)
Could it be that I have to install VS2012 on XP and re-compile there? How could that really be what needs to be done to build a Win32 COM object in C++ using current Visual Studio?
Does anyone know where I might look? I've checked all the project and solution options and nothing seems set to 64-bit. The option under "Use of MFC" is set to "Use Standard Windows Libraries" -- that's probably the answer but if that's not portable to 32-bit Windows it's hardly using only "standard libraries". (I will be trying changes to that after sending this.)
Thanks in advance for any advice.

Default toolset coming with Visual Studio 2012 produces output incompatible with Windows XP, through using certain APIs introduced only later with Vista.
In order to both utilize the power and feature richness of the latest Microsoft C++ compiler, and be still compatible with Windows XP, you need to use an alternate toolset codename "v110_xp" introduced with Visual Studio 2012 Update 1. At the moment the latest update available is Visual Studio Update 3, and you might want to simply install latest available updates for Visual Studio.
You have the setting available under Project Settings:
See more here: Configuring C++ 11 Programs for Windows XP.

Related

Visual Studio remote Debugging, choose custom gdb.exe (linux makefile project)

I've got Visual Studio 2017 (Linux and IOT extension installed) and a linux makefile project. The code is compiled using an arm cross-compiler.
When I try to debug, visual studio will always choose one of the gdb.exe in Common7/IDE/VC/Linux/bin/gdb/8.1. The decision is made based on the choosen architecture (x86, x64, ARM, ARM64) of the VS project.
However my cross-compiler and the gdbserver running on my device are not compatible with the provided aarch64-linux-gnu-gdb.exe.
Is there a way to tell VS to use a specific gdb.exe on my pc?
Replacing files within the VS installation is not an option.
Within Common7/IDE/VC/VCTargets/Application Type/Linux/1.0/Linux.props I've found the GDBRoot property pointing towards the first directoy, but I failed to override this property.
I prefer to keep a solution instead of a project with thelaunch.vs.json if possible.

How to package/run 32-bit application built with VS 2015 using libcef.dll from Spotify

I am trying to build a few different 32-bit C++ applications with Visual Studio 2015 that use CEF. To use CEF, I am currently acquiring the CEF prebuilts from Spotify. The dll wrapper for CEF is built using Visual Studio 2015 with some modifications to its CMake files to force it to build with MD and MDd mode regardless of other settings. This was sufficient to make these C++ applications run on some machines. Any machine on which Visual Studio 2015 is installed on before anything else they can run on, however some machines seem to exist in a state such that the program will produce an error on starting when lacking the MSVC 2015 runtime (as expected), but when adding the MSVC 2015 runtime the program simply crashes; however, it only crashes after CEF is used. These programs work fine when they don't link to libcef.dll and don't include the browser functionality.
Upon investigating, I found that libcef.dll, as built by spotify, links to MSVCP110_WIN.DLL, which is from the Visual C++ 2012 Redistributable package. Naturally, the application I am building links to MSVCP140.DLL, which is from the Visual C++ 2015 Redistributable package. This means that the application ultimately links to two runtimes simultaneously. I do not know if this is an issue, but so far it seems to be my best lead. Installing the Visual C++ 2012 Redistributable does not change the outcome and it continues to crash when CEF is used.
This issue has been witnessed on both Windows 7 and Windows 10 and the application works without CEF on both of those operating systems as well, so the operating system is not likely to be the cause of the failure on these systems specifically.
Has anyone else encountered this issue and does anyone know a workaround? Also, does anybody know if it is okay to mix these two runtimes and what the limitations are? It seems that the installation history of a given machine affects the success of running the application, so any hints into what combination of things leads to this failure would be helpful as well.
You have some options:
Use the lastest version of VS that will allow a selection of Platform Toolset that matches libdef.dll. For example, VS2013 might allow the selection of the 2012 CRT.
Or convince Spotify to rebuild libcef.dll such that it matches your version of CRT
Or convince Spotify to not release libraries that depend on the CRT (yes that's probably a bit of work).
Or make a small app built against the older CRT, this app can then successfully use libcef.dll. Then you get to use any IPC technique so that your main VS2015 app can talk to this wrapper. Running out-of-process is one way to segregate the unruly third party libraries.
EDIT:
This is open source? Well good news, you can fix this yourself, built the CEF against your favorite version of VS.

Use x86 platform in C++ projects

My Visual Studio 2012 solution has C# projects, VB.NET projects, C++/CLI projects and C++ projects. Currently, I have three platforms: x86, x64 and Win32. When I added x64, I noticed it was used by all projects. I'd like to do the same with x86, so that I can remove Win32.
So I went to Configuration Manager, selected a C++ project and in the platform combo box I only had the options: Win32, x64, New and Edit. If I selected New, the only option available is ARM.
So then I thought of just replacing Win32 with x86 in my .vcxproj. Didn't work (it defaulted to x64). Then I looked at the .sln file, but couldn't see how x64 manages to work for every project.
The IDEs differ too much to get a common platform name for 32-bit code. Otherwise reflective of managed code being rather fundamentally different from C++ code. Managed project platform names can only be AnyCPU, x86, x64. C++ project platform names can only be Win32, x64 and ARM. History plays a role, Win32 comes from the early 1990s, back when Windows NT introduced the 32-bit version of the winapi. Distinguished from the 16-bit version. There was no real opportunity to ever change it again without risking breaking existing projects.
The x86 platform name for managed projects isn't exactly standard either, that was a mistake in VS2010 that you appear to have inherited. VS2012 creates new projects with the AnyCPU platform name like old VS versions used to do. Which pretty accurately describes the true platform for managed code, it runs on any thanks to the jitter. The name is otherwise irrelevant, only the Project + Properties, Build tab settings matter to force a specific jitter to be used at runtime. In other words, if you don't force x86 there then your program is still going to run as a 64-bit process, even though the platform name is x86. That was the VS2010 mistake, it caused a lot of misery.
So you're pretty stuck with this. It is not a real problem, the IDE can handle the mix just fine. You already know about the Build + Configuration Manager dialog, it unambiguously shows which platforms are going to be built when you use Build + Build or press F5.

recompile VC++ 6 code for X64 plateform

I have an old VC++ 6 code compiled as DLL, I used it for many years without problems, now i need it in a x64 application, can i recompile the old code to produce a X64 DLL?
Am I need the same VC++ 6 IDE or another compiler?
Unfortunately, the answer to both of your questions is: maybe.
I have had good luck taking VC++ source code for old 32-bit DLLs and recompiling it for 64-bit. Sometimes it is a simple recompile. Other times, minor adjustments have to be made. My biggest concern would be if the 32-bit DLL relies on other 32-bit DLLs that you may not have source code for. In that case, unless you have 64-bit copies of the other DLLs, you are probably out of luck.
Now, I have never tried to do this with VC++ 6. I've done it with Visual Studio 2010. However, the windows platform SDK used to support compiling for 64-bit with VC6. My understanding is that the last version of the SDK that supported this was the February 2003 version. I just checked MSDN and I do not see this available for download. That doesn't mean you cannot get a copy (and you may already have one). It does mean that getting a copy won't be as easy as going to MSDN and downloading it.
Now, having said that, my recommendation is to use a newer compiler to make your 64-bit DLL. Assuming Windows, all recent Visual Studio compilers (2008, 2010, 2012) will do 64-bit, provided you've installed the 64-bit tools.

Side by side installation problems with Visual Studio 2008

I develop an unmanaged DLL with Visual C++ which is part of my application. I have always had various problems with linking the VC runtime library. Somehow I managed with VS 2005, but since I moved to VS 2008, the release version of my DLL no longer works on any PC other than the one with my development tools (namely VS 2008).
I link the runtime library as multi-threaded DLL (/MD). I tried the /MT option but that causes a lot of error messages. I allow isolation of the manifest file, and of course installed the VC++ 2008 runtime (although I don't think it should be needed). I also tried the dependency walker to check what is missing. On my development PC (VS 2008 SP1 installed) three files are reported missing:
MSVCR90.DLL, GPSVC.DLL, IESHIMS.DLL
But that does not stop the application (and my DLL) from running.
On all other PCs I tried to install my application on, apart from these three, a fourth file is reported as missing by dep. walker: MSVCP90.DLL.
More importantly, my own DLL is not working as well.
I know this is nothing new and I tried to read everything I could find about SxS problems but I still don't know what to do. Hopefully my description of the 'phenomenon' is good enough for someone more experienced to give me some help.
Thanks in advance.
You may need to distribute and install Microsoft Visual C++ 2008 Redistributable, OR SP1 versionf of it.

Resources