VS2012 Error C1107 - c++

I am getting the following error:
fatal error C1107: could not find assembly 'platform.winmd': please specify the assembly search path using /AI or by setting the LIBPATH environment variable
Steps to reproduce
0) Create a new empty project
1) C/C++ > General > Consume Windows Runtime Extension > YES
2) C/C++ > Code Generation > Enable Minimal Rebuild > No
3) Add a source file *.cpp, file can be blank
4) Attempt to compile
I tried to manually compare and change the project settings to match that in some sample code but nothing seems to work.

I don't understand what the problem you have, so
If you don't want to code against WinRT just set "Consume..." to false and the issue will be gone
If you want to code against WinRT you should perform an additional step: go to General and set Windows Store App Support to true

To create a C++/CX Desktop application:
In C/C++ -> General project properties, set Consume Windows Runtime Extension to Yes
In the same tab enter these to your Additional #using Directories enter the directories containing the windows.winmd and platform.winmd files. For me, with VS2017, that is:
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\lib\store\references;
C:\Program Files (x86)\Windows Kits\10\UnionMetadata;
C:\Program Files (x86)\Windows Kits\10\References\Windows.Foundation.UniversalApiContract\2.0.0.0;
C:\Program Files (x86)\Windows Kits\10\References\Windows.Foundation.FoundationContract\2.0.0.0
Then call RoInitialize or use a WinRT main style function (to remove the warning C4447 about main threading):
using namespace Platform;
int main(Array<String^>^ args) ....
References:
Using C++/CX in Desktop apps,
Calling Windows 10 APIs from a desktop application

Related

Trying to move a MSVC2008 project to MSVC2017

I'm trying to move this project form VisualStudio 2008 to VisualStudio 2017. This project is a C++ project and when I try to compile it there are a lot of errors:
Errors are:
the source file can not be opened (E1696).
the global scope does not have... (E0282).
the identifier ... is not defined (E0020).
The solution file of the project is in the folder kex3_anubis/msvc/
The project is open source.
# EDIT
I have lowered the number of errors to 17, but there are 126 warnings. What I have done is to select Project -> redirect projects (2nd option of project menu) and select Windows SDK version to 10.0.15063.0. I don't know if this is a good step or is not part of the solution, because it's the first time that I'm trying to move a project from different versions of VS.
The new errors are:
The declaration of ... hides the previous local statement (C4456)
Warning treated as error; no generated 'object' file (C2220)
The other errors have disappeared.
# EDIT 2
For the moment I applied this solution found on other question:
Go to project properties -> configurations properties -> C/C++ ->
treats warning as error -> No (/WX-).
Now I only have one error.
can not open the file '...\openal\lib\ eaxguid.lib' from anubis project
instead of
#include "math.h"
use
#include <math.h>
In all the standard includes

cannot open source file "windows.h" "WTypes.h"

Hello and thanks for your help.
I recently downloaded some source files in C++. They build a DLL for managing a camera.
Anyway, when opening with Visual Studio 2015, it notifies me there will be some conversion because the compiler has changed.
After that there are red lines under
#include <windows.h>
#include <WType.h>
passing the mouse over them it says "cannot open source file ..."
Now, I ve googled this error and found some resources, even in this very same site.
However their solutions don't work. Sometimes the OP just say "Oh it worked thanks!" but does not specify what makes it work.
So I am asking for some help here. What is this error and how can I solve it?
(I am supposing it involves some settings in the project)
Thanks again for all the help
(p.S. I have the dlls provided by the writer but would like to build the project myself)
Edit:
When building the output messages are
1>------ Build started: Project: DirectShowFacade, Configuration: Debug Win32 ------
1>C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\V140\Platforms\Win32\PlatformToolsets\v140_xp\Toolset.targets(36,5): warning MSB8003: Could not find WindowsSdkDir_71A variable from the registry. TargetFrameworkVersion or PlatformToolset may be set to an invalid version number.
1>C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppBuild.targets(366,5): warning MSB8003: Could not find WindowsSDKDir variable from the registry. TargetFrameworkVersion or PlatformToolset may be set to an invalid version number.
1> DirectShowFacade.cpp
1>d:\xxxxxxxxxxxxxxxx\cameraprogramming\directshowfacadesources\directshowfacade.h(28): fatal error C1083: Cannot open include file: 'windows.h': No such file or directory
Properties → General → Target Platform Version → change to 8.1

How do you run cl.exe from cmd using the same settings as in MSVS?

I have a c++ project in MSVS 2010 Express. I have been planning to write several unit tests to validate this project. Right now they go along the following lines:
#include "header.h" //Header is the header for the source I want to test
void testSomeFunction()
{
//Call function (from external src, prototype in header.h)
//Save output to file
}
int main()
{
testSomeFunction();
return 0;
}
I am creating these source files outside my project because I want to be able to run each of them as individual executable, but I am having trouble getting the Microsoft linker to link them.
This is my problem so far (CMD output):
cl ut_Converter.cpp Converter.obj
ut_Converter.cpp
c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\xlocale(323) : warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc
Microsoft (R) Incremental Linker Version 10.00.40219.01
Copyright (C) Microsoft Corporation. All rights reserved.
/out:ut_Converter.exe
ut_Converter.obj
Converter.obj
Converter.obj : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '2' doesn't match value '0' in ut_Converter.obj
Converter.obj : fatal error LNK1313: pure module detected; cannot link with ijw/native modules
I never really use Microsoft products, I'm familiar with using the GNU tools GCC and make but I have to use the Microsoft tools for this and I have no idea how they work.
Maybe I'm going about building these tests the stupid way but it's the best way I can think of right now.
This is what I want to do:
Compile the source files in my project into object files
Compile my test files into object files
Link the test object file with the appropriate project object files to produce the test executable
How do I go about doing that? (I'm guessing there are some settings I need to set to make everything compatible but I have no idea what they are or how I would go about setting them)
Extra: I know it mentions the debug level but I'd be willing to bet that there will be other incompatible settings. Is there a way to find out what the settings are in the program so I can pass them to cl.exe when I run it?
Edit: When I say command prompt I do mean the one that comes with Visual Studio with all the environment variables setup.
Have you tried going to Programs / Microsoft Visual ... / ... Tools / ... Command Prompt, and running from that dos console window which has the environment variables setup?

Visual Studio C++ NPAPI plugin with Twain support

I want to make a Google Chrome plugin that use Twain to remote control a Digital Camera.
I want this to run on Windows and I'm using Visual Studio Express 2012 C++.
I have this sample for NPAPI and this sample of CppWrapper for Twain which has 3 interesting files (TwainCpp.cpp TwainCpp.h twain.h)
Before doing anything, I want to merge these two projects.
First step: putting twain.h in the npsimple project which failed, twain.h errors caught.
Second step: putting CppTwain in npsimple, which also failed because twain.h "contains" errors.
Problem is that when I create an empty project, and put twain.h in it, there is no error! So I tried to put npsimple files in that empty project, and this time I get error from npsimple files..
Error type :
I have this code in twain.h :
#ifdef _MSWIN_
typedef HANDLE TW_HANDLE;
typedef LPVOID TW_MEMREF;
and I get plenty of errors like :
error C2146: syntax error : missing ';' before identifier 'TW_HANDLE'
How can I merge these projects?
HANDLE is an unspecified type because you don't include anything that is specificing it. You'll want to include windows.h.
Obviously there is no error when you add only the twain.h header file to the empty project - you haven't added any sources to compile, hence there can be no compilation errors.

Can not find mpirxx.h after building the mpir-2.6.0 library in vc++

I need to use mpir-2.6.0 library with visual c++ 2010. My code is going to be in c++.
I extracted both folders (mpir-2.6.0 and vsyasm-1.2.0-win32). Then, I copied the content of the folder vsyasm-1.2.0-win32 (including vsyasm.exe after renaming it to yasm.exe and placing it in: C:\Program Files\Microsoft Visual Studio 11.0\VC\bin\. Then, I opened the project: mpir.sln which is placed in: \mpir-2.6.0\build.vc10. Then, I changed the Project configuration to: Release.
When I try to build the whole solution, I get a lot of errors such as:
error C1020: unexpected #endif c:\proj\mpir-2.6.0\mpir-2.6.0\mpir.h 4 1 lib_mpir_gc
error C1020: unexpected #endif c:\proj\mpir-2.6.0\mpir-2.6.0\mpir.h 4 1 lib_mpir_gc
error C1020: unexpected #endif c:\proj\mpir-2.6.0\mpir-2.6.0\mpir.h 4 1 lib_mpir_gc
But when I build every library separately, it is successful.
After the build, I went to: \mpir-2.6.0\build.vc10\Win32\Release
and find the files:
mpir.lib
mpirxx.lib
mpir.pdb
mpirxx.pdb
But I can not find the files:
mpir.h
mpirxx.h
Which I need to copy them the visual studio include file.
My main source for these configuration is: http://www.exploringbinary.com/how-to-install-and-run-gmp-on-windows-using-mpir/ (but this was for old versions for the library and the ysam). I do not understand the reasons for these errors. I was able to configure the library with old version. But I need to upgrade as there are improvements in the library and mine is very old one.
The output files are now located in mpir\lib\Win32\Release or mpir\dll\Win32\Release.
The recommended way to build MPIR specifcally for your CPU is to first run mpir_config.py which is located in the build.vc10 directory. mpir_config.py will prompt you with a list of CPU options. Then when you open mpir.sln, you should only compile code for the specific CPU. And then you compile the C++ wrapper (i.e. compile lib_mpir_p3 first, and then lib_mpir_cxx).
Edit: I just noticed another error from your original post. You need to rename the directory "mpir-2.6.0" to "mpir". The directory layout needs to be "<>\mpir\build.vc10"
I had the same problem with MPIR 2.6.0 and VS 2012. What I did to make MPIR work was to build lib_gc and lib_cxx, both with win32 and release mode. Because my c++ application is win32 console, this way it worked perfectly.
Becuase my windows is 64, I thought I had to build 64 versions, but turned out that I was wrong.