Visual Studio unable to recognise my MFC library for my webcam laser rangefinder code - c++

I tried copying the source code from the internet directly and I couldn't build/debug the whole file because of the error found below.
Please Help
Error occurred while restoring NuGet packages: System.ArgumentException: The path is not of a legal form. at System.IO.Path.NormalizePath(String path, Boolean fullCheck, Int32 maxPathLength,Boolean expandShortPaths)
at System.IO.Path.GetDirectoryName(String path)
at NuGet.VisualStudio.VsUtility.GetNuGetSolutionFolder(Solution solution)
at NuGet.VsEvents.PackageRestorer.UsingOldPackageRestore(Solution solution)
at NuGet.VsEvents.PackageRestorer.BuildEvents_OnBuildBegin(vsBuildScope Scope, vsBuildAction Action).
1>------ Build started: Project: LaserRange, Configuration: Debug Win32 ------
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.CppBuild.targets(369,5): error MSB8031: Building an MFC project for a non-Unicode character set is deprecated. You must change the project property to Unicode or download an additional library. See http://go.microsoft.com/fwlink/p/?LinkId=286820 for more information.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========}

Question : Where do I "change the project property to Unicode"?
Answer :
For C++,
Right Click the project, and select properties, ( or Alt-Enter )
Property Pages should open
Under Configuration Properties
General
[-]Project Defaults
**Character Set** : Use Multi-Byte Character Set
- Change to -
**Character Set** : Use Unicode Character Set
Pain in the butt to find it.

right click your solution, go to properties and set the project properties to use Unicode instead.

you need to install MFC MBCS DLL Add-on As mentioned in your error.
See the below link
http://msdn.microsoft.com/library/dn251007.aspx

I encountered the same issue while building solution in Visual Studio and it got resolved when installed below components:
MFC for C++
Common tools for C++
Windows 8.1 SDK and universal CRT SDK

Related

TRACKER : error TRK0005: Failed to locate: "xsd.exe". The system cannot find the file specified

In the intent of converting a Microsoft Visual Studio 2015 (VS2015) project with VisualGDB to VS2017 without VisualGDB, I get the following error:
Notes: VS2017 includes a native feature for remote build/debugging.
TRACKER : error TRK0005: Failed to locate: "xsd.exe". The system cannot find the file specified.
Why is that happening and how to solve it?
More details
Opening the project with VS2017 and going to the properties, most of the required settings for remote build are missing. I tried to add/modify the ``.vcxproj` xml to match an new empty project which seem to build correctly remotely.
After this step, the property window of the project seem pretty similar, except an additional XML Data generator Tool section in the not-working project.
When building the project, it shows the following:
1>------ Rebuild All started: Project: project, Configuration: Debug x64 ------
1>Cleaning remote project directory
1>TRACKER : error TRK0005: Failed to locate: "xsd.exe". The system cannot find the file specified.
1>
1>
1>Done building project "project.vcxproj" -- FAILED.
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
EDITED: it seem related with the inclusion of some sources like:
<Xsd Include="C:\Users\...\xml_file.xsd" />
I just faced the same issue and resolved it through a combination of the following two steps:
Locating xsd.exe on my file system. If it doesn't exist (although it should when Visual Studio is installed), this answer might help.
Adding the path it is in to the "Executable Directories" variable in the properties of the Visual Studio project. (Personally, I don't have Visual Studio installed, so I added <ExecutablePath> properties next to the <IncludePath> ones in the .vcxproj file via text editor)

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.

After upgraded from VS2008, build project in VS2012 shows error

Our team is migrating whole baseline from VS2008 to VS2012. There're over 400 C++ projects. There're 6 C++ project show wired error, such as :
1>------ Rebuild All started: Project: SSLT, Configuration: Release Win32 ------
1> stdafx.cpp
1> ???
1>c1xx : fatal error C1083: Cannot open source file: '???': No such file or directory
1> ??????????????????????????????
1>c1xx : fatal error C1083: Cannot open source file: '??????????????????????????????': No such file or directory
All files which are the parameters of cl.exe seems in wrong encoding, and cl.exe can't find them.
Firstly, i think it must be encode issues of .vcxproj, so i save as other encoding style. But still happens.
Then i re-upgrade these projects with such issue, but always build error.
At last, I change the project platform toolset back to VS2008, then build pass. So i think it's not because project file encode format. I don't know what wrong with them when using 2012 compiler. These projects build no error using 2008 compiler. And as i know from VS2010, project format changed a lot, so i can't find any clue.
Btw, there's another reason cause such issue. After upgrade, there's one property in *.vcxproj file made an unproper line break, such as:
/Zm300
/bigobj %(AdditionalOptions)
if i change it back to:
/Zm300 /bigobj %(AdditionalOptions)
Then works well, build pass.
The projects which has such issue, 80% of them are because of such issue.
Create a new sample project to see which encoding the VS expects and then convert your files to it.
Alternatively, How to: Upgrade Visual C++ Projects to Visual Studio 2012 says that you must upgrade a VS2008 project upon opening it in VS2012.
I don't have a VS2012 installation to check this, but there may be a function to convert a project programmatically in one of its DLLs - try searching with a dumpbin-based script or by examining stack traces with procmon while converting a sample project.
Thanks for your reply, i automatically upgrade our projects using: devenv.exe /upgrade *.vcproj in script.
Today i find the root cause is precompile header file: stdafx.h.
It is because that wrong precompiling head file reference. It will cause mess file name issue.

c++ project, vs2010, "build failed" with no errors

I am trying to create a new c++ cli project in visual studio 2010.
After i create the new project, i try to build it, and get "build failed" message, with no errors, or other description of what went wrong
1>------ Build started: Project: TestProject3, Configuration: Debug Win32 ------
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
I am working on windows 7, 64 bit.
This is happening also if i try to create the project with another template (like win32 console application).
I tried to create the project under "c:\Test", to make sure that the problem is not with the folder's path, or write permissions.
This solution also contains a c# project, that is working with no problems.
Does anyone know this problem? do i need to change something in the project properties?
Thanks in advance :)
Amir
Did you include any source files to be built? It would seem natural that compilation fails without any errors only when there are no source files (included for build) or they are empty, perhaps.

Problem in first program in driver programming using Visual Studio 2010

I am starting to learn this type of programming (driver programming) since a short while of the time.
I started by using the traditional way _> I mean I only used WDK to bulid and compiled driver and was working properly with simple method of projects but I faced small problems in advanced when i wanted to start to expand my program or make a little developed one.
So, I started using VS2010 in windows 7, I really faced a lot of problems because i do not have a background how can i used it as good as possible.
Finally, I reach to a good point, this point is say (If you want to start with driver programming in VS2010, 1- you should install WDK 2- install VS2010 3- Enter the paths of WDK headers dirctories into VS2010 Dirctories to be compatiple. 4- Start tor create new project and go on.
makefile project
Finally, I am really not sure, it is a correct way or not I am just beginner.
But I did like this and i found a good results
#include "wdm.h"
NTSTATUS DriverEntry( IN PDRIVER_OBJECT theDriverObject, IN PUNICODE_STRING theRegistryPath )
{
DbgPrint("Hello World!");
return STATUS_SUCCESS;
}
And i got:
1>------ Build started: Project: 1, Configuration: Debug Win32 ------ 1>C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\Microsoft.MakeFile.Targets(37,5): warning MSB8005: The property 'NMakeBuildCommandLine' doesn't exist. Skipping... ========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
My question is:
Is this the correct way? How can I know this program is working properly?
Should I do something else to make my program work correctly in kernal mode?
Never build drivers in Visual Studio!
The only way to build driver is: open WDK Build Environment command prompt, cd to the driver project directory, and type "build".
You can use Visual Studio only as source code editor, but don't build driver with it! There are number of ways to do this, published in different programming sites, but professional driver developers strongly recommend to use only WDK build for this.
To open WDK build environment, click main Windows menu - Programs - Windows Driver Kits - WDK - Build Environments - select target OS - select build environment, according to target computer processor type. Checked build environment means Debug, free build environment means Release.
Look into DDKWizard. It tackles exactly the issue you're handling, and does it well.
You shouldn't use the compiler of Visual Studio. The WDK compiler may contain changes to the standard WinSDK or Visual Studio compiler.
On the other hand, using a build macro from the makefile step is a nice enough way to utilize Visual Studio for developing the driver, and building it with the build toolkit used by the WDK.
There is a nice batch file which calls the necessary build environment and redirects the error outputs to the Visual Studio output pane.
To clarify, I use a makefile project in visual studio where all source files are added, when building I call a batch file which calls in turn ddkbuild with the right parameters.