Localize an MFC-based DLL? - c++

I use Visual C++ 2008 to create a DLL which is statically linked with MFC. Now I need to localize the DLL so that it supports both English and German. I read the article at http://msdn.microsoft.com/en-us/library/x6h91d9w and it says to use localized MFC resources, one needs:
To cause your application to use these RC files instead of the files
located in MFC\INCLUDE, add a /IC:\PROGRAM FILES\MICROSOFT VISUAL
STUDIO .NET 2003\VC7\MFC\INCLUDE\L.DEU to your RC command line (this
is just an example; you would need to substitute your locale of choice
as well as the directory into which you installed Visual C++).
Then how to do that in the Visual Studio environment, since I do not call the RC command line directly when compiling the project.
Thanks
Alan

You open the project properties in Visual Studio (one way is to right click on the project in solution explorer, properties is on the bottom) In the common properties there is a Resources section, in this there is a Command line section which allows you to add arbitrary strings which will get added to the command line.

Related

Linker: cannot open file 'nafxcwd.lib'

I have problem with compiling my project via visual studio 2013. I got this linker error:
LINK : fatal error LNK1104: cannot open file 'nafxcwd.lib'
According to this page, I must use MFC in shared library. But I don't use MFC at all.
All my libraries and main project compiled using Use Standard Windows Libraries settings. This problem occurs only when I try to build project via Visual Studio 2013 toolchain, but it successfully built with Visual Studio 2010 toolchain.
P.S. project has been moved from Visual Studio 6.0 to Visual Studio 2013.
It appears that in Microsoft Visual C++ 6.0 Standard Edition does not support statically linking with the MFC libraries as the Microsoft page says . But in Visual Studio 2013 you can link staticaly with Microsoft Libraries . Check this link https://support.microsoft.com/en-us/kb/243458 in order to solve your problem.
From The Microsoft Site :
To change your MFC project setting to link dynamically to the MFC libraries, perform the following steps:
Open your MFC project.
From the Project menu, click Settings.
In the Settings For combo box, select All Configurations. Click the
General tab. If it is not visible, use the tab scroll buttons to
scroll to the left.
In the Microsoft Foundation Classes combo box, select Use MFC in a
Shared DLL. Click OK to save the changes.
I had the same issue except it compiled on one machine but not another. Solved by installing the Multibyte MFC Library for Visual Studio 2013 as suggested in: MBCS Error building MFC C++ project with Visual Studio
To isolate the culprit that consumes MFC, link with /VERBOSE and search the output for nafxcwd. Most probably it would appear after a /DEFAULTLIB directive - just note which library was loaded exactly before the directive.
Going through updating a VS 2008 project which did not use MFC at all, I faced this same problem and fixed it doing these three steps. Please see the shot to have a glance on the properties of the project (VS 2008) highlighted.
Step-1
Please add this line #define _AFXDLL in your stdafx.h file
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#define _AFXDLL
Step-2
Go to your VS 2013 solution and open "Project Properties -> C/C++ -> Code Generation -> Runtime Library" and change the value to Multi-threaded Debug DLL (/MDd) (adjust your release configuration to Multi-threaded DLL (/MD), once you will complete these two steps you will start getting this linking error
error LNK1104: cannot open file 'mfc120d.lib'
Now, here you have to set the "Character Set" for your project to Unicode instead of _MBCS
Step-3
Now open "Project Properties -> General -> Project Defaults -> Character Set" and change the value to Use Unicode Character Set, now this part requires little more patience and work, you have to change your string traits to either wchar_t or TCHAR in your source files.
Hope it would solve your problem.

Using Visual Studio 2012 IDE, but compile with Visual Studio 2008

Where I work, we are stuck on VS2008 and will be for quite some time as converting the projects/solutions and integrating them back into our build process would take significant time; we're planning on moving to 2013 at some point though. However, I use VS2012 at home and love a lot of the features in the IDE that are missing in 2008.
I've read that you can use 2012 as an IDE and build with the 2008 compiler, but I can't find details on how this is accomplished. Any ideas? If I open one of the masterbuild files in 2012, it inevitably asks to convert them to the 2012 format, which I really don't want to do.
Thoughts? Thanks!
Yes it is possible as can be found on the Visual Studio site. However, I believe it will only give you options of the versions you have currently installed on the machine in question.
Here are the steps as laid out in the link, provided here to ensure the information link does not get broken:
(authored and published by Microsoft)
To change the target Framework
In Visual Studio, in Solution Explorer, open the shortcut menu for your project and then choose Unload project. This unloads the project (.vcxproj) file for your project.
Note: A C++ project cannot be loaded while the project file is being modified in Visual Studio. However, you can use another editor such as Notepad to modify the project file while the project is loaded in Visual Studio. Visual Studio will detect that the project file has changed and prompt you to reload the project.
On the menu bar, select File, Open, File. In the Open File dialog box, navigate to your project folder, and then open the project (.vcxproj) file.
In the project file, locate the entry for the target Framework version. For example, if your project is designed to use the .NET Framework 4.5, locate v4.5 in the element of the element. If the element isn't present, your project doesn't use the .NET Framework and no change is required.
Change the value to the Framework version you want.
Save the changes and close the editor.
In Solution Explorer, open the shortcut menu for your project and then choose Reload Project.
In Solution Explorer, open the shortcut menu for your project and then choose Properties. In the Property Pages dialog box, in the left pane, expand Common Properties and then select Framework and References. Verify that Targeted framework shows the new Framework version.
To change the project toolset
In Visual Studio, in Solution Explorer, open the shortcut menu for your project and then choose Properties.
In the Property Pages dialog box, open the Configuration drop-down list and then select All Configurations.
In the left pane of the dialog box, expand Configuration Properties and then select General.
In the right pane, select Platform Toolset and then select the toolset you want from the drop-down list. For example, if you want to compile with the Visual Studio 2010 toolset, select Visual Studio 2010 (v100).
Choose the OK button.
Try to use CMake. It could manage out of source build. You could create a VS2012 for edit and another VS2008 based for compiling. The source will be common.
From Visual Studio 2012 Compatibility page on MSDN
Some solutions, projects, files, and other assets that you created in
Visual Studio 2010 Service Pack 1 (SP1) will run without modification
in Visual Studio 2012, but others have to be upgraded.
If your original project is 2008 then you won't be able to use it in 2012, sorry.

VS2010 - About the Resource Relative Path - Where are variables declared

I am trying to build a cpp project. On the project resources section there is a resource whose relative path is something like
$(QPID_BUILD_ROOT)\src\windows\resources\org.apache.qpid.messaging.rc
Where am I suppose to define this variable ? I mean where does VS2010 read this variables value from ?
These are environment variables. You can set them for user only, or for the whole system. You also can set what you want "ad-hoc", for example (assuming that your Visual Studio is installed in c:\Program Files\Microsoft Visual Studio 10 and that you want x86 build environment):
Go to start
Type cmd.exe
At the command prompt:
"c:\Program Files\Microsoft Visual Studio 10\VC\vcvarsall.bat" x86
set QPID_BUILD_ROOT=[some path]
Launch Visual Studio IDE: devenv
In the Visual Studio IDE you can use a dropdown list (e.g. on one of the VC++ directories) and the click Edit. In the dialog window click Macros - this will show you all the variables (including the one set above) currently available to Visual Studio.
Of course you don't have to set entire build environment (as shown in 3), this step is only needed to be able to just type devenv instead of typing the whole path to devenv.exe in 5.
Im assuming that you know how to set environment variables for user or the whole system and that you know that you need (at least) to lauch any application again (or even login/logout or reboot) in order for that application to inherit those new variables.

How to get started with directshow?

I'm having a great trouble trying to understand this,
what's the least set up to compile/run directshow apps?
I've already installed visual c++ 2008 express.
A hello world will be nice,
RGS!
Setting up Your Environment
Setting up the environment is a cumbersome process, since DirectShow has now been buried deep in the Windows 7 SDK. If you don't already have the baseclasses built, which you'lll need to do any DirectShow development, you must first compile the DirectShow baseclasses.
You'll find the baseclasses in the Windows SDK. The latest Windows SDK is v7.1.
You can download the Windows SDK from microsoft's website.
If you install the Windows SDK to it's default folder, you'll find the baseclasses here:
C:\Program Files\Microsoft SDKs\Windows\v7.1\Samples\multimedia\directshow\baseclasses
In that folder, you'll find a Visual Studio solution file. Open that solution in Visual Studio and compile it for both Debug and Release modes.
Next, in Visual Studio, go to the following menu option:
Tools -> Options,
Projects & Solutions -> VC++ Directories
Show directories for -> Include files
Add this:
C:\Program Files\Microsoft SDKs\Windows\v7.1\Samples\multimedia\directshow\baseclasses
Show directories for -> Library files
Add these:
C:\Program Files\Microsoft SDKs\Windows\v7.1\Samples\multimedia\directshow\baseclasses\Debug
C:\Program Files\Microsoft SDKs\Windows\v7.1\Samples\multimedia\directshow\baseclasses\Release
You should now be all set to build DirectShow programs. You may also want to add extra libraries like the DirectX libraries, (which you'll need if you're doing more advanced rendering with VMR9) and the WMFSDK (if you're working with Windows Media Format stuff).
Writing a Hello World program is a little long for pasting into Stack Overflow. I'll have a look at posting one sometime this weekend, but you might like to check out CodeProject in the meantime, which is bound to have oodles of DirectShow examples.
DirectShow has an active community of developers, where you can discuss problems and solutions.
Good luck!
Try downloading SDK such as Windows SDK "http://www.microsoft.com/downloads/details.aspx?FamilyID=6b6c21d2-2006-4afa-9702-529fa782d63b&displaylang=en".
There are usually a bunch of samples for directshow. But, mainly they either use commandline "nmake" (not make) or "cl" (not cc or gcc) to build. Sometimes they provide *.sln files to be used under VS.
Your vcam package is only a dll and you still need to write an application to test this.
Based on the samples from there, I believe you can be able to cook up one hello-world app for your vcam ;)
To get the vcam example, you basically have to create a fresh new "dll" project in VC 2010, add the old files into it, then setup the .def file to export all the methods you need.
Here's some links for ya:
http://betterlogic.com/roger/?p=3096
To make it easier on ya, I add a "visual studio express 2010 project" to the vcam_vs_2010 folder of
http://github.com/rdp/directshow-demo-audio-input-source
(checkout its README.txt)
GL.
-r

Extend the Visual Studio C++ Build Process

A found an article (Extend the Visual Studio Build Process) that explained how to override build targets in a C# project file. I tested this, and it seems to work well. However, what I really want to do is override a build target in a C++ project (with Visual Studio 2005). The problem is that C++ projects use different XML. Instead of having <project> as the root, C++ projects have <VisualStudioProject> as the root. When I add the <target> tag to a C++ project file and try to open the project in Visual Studio, I get this error:
The following error has occurred during XML parsing:
File:
[Path to Project File].vcproj
Line: 304 Column: 30 Error Message:
Element 'Target' is unexpected
according to content model of parent
element 'VisualStudioProject'.
The file
'[Path to Project File].vcproj'
has failed to load.
How can I override a Visual Studio build target for a C++ project? Or is there a better way to customize what happens during a C++ build?
In Visual Studio 2005 there are no build "targets" for C++ builds as the C++ build system does not use MSBuild.
However, VC++2005 defines the Pre-Build, Pre-Link, Post-Build Events as well as the ability to add a Custom Build Step for non-standard files.
You may be able to achieve what you want using these settings.
Note:
VC++2005 projects can be built using MSBuild, it's just not what Visual Studio does out of the box.
Visual Studio 2010 uses MSBuild for all project types.