I am porting a project from Win32 to Win64. We are using make file but we get the following error
1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\codeanalysis\sourceannotations.h(17) : error C2371: 'size_t' : redefinition; different basic types1>
binding.cpp : see declaration of 'size_t'
C:\Program Files\Microsoft SDKs\Windows\v6.0A\Include\winnt.h(81) : fatal error C1189: #error : "No Target Architecture"
We are copmiling with following CFLAGS:
1> cl.exe /nologo /MTd /GR /W3 /Zi /EHsc /Od /I "....\include" /I"C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include" /I"C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\PlatformSDK\include" /I"C:\Program Files\Microsoft SDKs\Windows\v6.0A\Include" /D_X86_ /D_WIN64 /D_WIN32 /D "_DEBUG" /D "_WINDOWS" /D_CRT_SECURE_NO_WARNINGS /Fo".\Debug\" /Fd".\Debug\" /FD /c "test.cpp"
I don't know which settings I am missing.
The header winnt.h expects that either _AMD64_ or _IA64_ should be defined when you're trying to compile the code in 64-bit mode.
They may be set by the compiler automatically if you use the right compiler. Check that you're using the 64-bit version of cl.exe.
Related
As part of upgrading a C++ (Microsoft Visual Studio 2010) with nodejs application from node 0.10.26 to node LTS 18.12.1, to compile and build C++ addons, we used node-gyp(node-gyp#9.3.1., Python version 3.11.1. and VS2019 (16.11.32929.386)), when doing node-gyp build, getting below errors:
C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\shared\rpcndr.h(192,14): error C2872: 'byte': ambiguous symbol
C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\shared\rpcndr.h(191,23): message : could be 'unsigned char byte'
C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\include\cstddef(28,12): message : or 'std::byte'
C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\shared\rpcndr.h(962,25): error C2872: 'byte': ambiguous symbol
C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\shared\rpcndr.h(191,23): message : could be 'unsigned char byte'
Please suggest possible solutions.
referred below link and tried suggestions from below link, but nothing worked.
https://developercommunity.visualstudio.com/t/error-C2872:-byte:-ambiguous-symbol/93889?ftype=problem&q=C%3A%5CProgram+Files+%28x86%29%5CWindows+Kits%5C10%5CInclude%5C10.0.19041.0%5Cshared%5Crpcndr.h%28192%2C14%29%3A+error+C2872%3A+%27byte%27%3A+ambiguous+symbol
I am trying to compile PuTTY for Windows on my Windows 10 machine. After I download the source code, I followed the steps from the README file:
For building on Windows:
- windows/Makefile.vc is for command-line builds on MS Visual C++
systems. Change into the `windows' subdirectory and type `nmake
-f Makefile.vc' to build all the PuTTY binaries.
I needed to add the following path to the PATH environment variable:
C:\Program Files (x86)\Windows Kits\10\bin\10.0.17763.0\x64
Because the Makefile.vc is calling rc without absolute path.
I run the make file and received the following error:
C:\Users\myuser\Desktop\Putty For Windows\windows>"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\nmake.exe" -f Makefile.vc
Microsoft (R) Program Maintenance Utility Version 14.00.24234.1
Copyright (C) Microsoft Corporation. All rights reserved.
rc /Fopageant.res -r -I..\./ -I..\charset/ -I..\windows/ -I..\unix/ -DWIN32 -D_WIN32 -DWINVER=0x0400 ..\windows\pageant.rc
Microsoft (R) Windows (R) Resource Compiler Version 10.0.10011.16384
Copyright (C) Microsoft Corporation. All rights reserved.
..\windows\rcstuff.h(15) : fatal error RC1015: cannot open include file 'winresrc.h'.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Windows Kits\10\bin\10.0.17763.0\x64\rc.EXE"' : return code '0x1'
Stop.
It writes that it can't open the include file winresrc.h.
This file doesn't exist in the PuTTY source folder, so I tried to copy the file from my Windows 10 SDK path:
C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winresrc.h
But I received the same error even after I copied the include file to the folder of Putty For Windows\windows.
nmake -f makefile.vc must be run at a cmd prompt configured for an installation of VC++ (or the VC++ build tools), and that means not just the PATH but also INCLUDE, LIB etc. It will work if run at a VS developer command prompt, which sets the whole environment correctly.
As an alternative, the PuTTY for Windows package comes with Visual C++ .sln and .vcxproj project files for building from the IDE. The windows\vs2012\putty.sln solution imports fine into the latest VS 2019, and builds (albeit with many warnings) after fixing the header references in putty-src\windows\version.rc2.
#include "..\\version.h" // instead of "version.h"
#include "..\\licence.h" // instead of "license.h"
I am trying to use cmake for the first time to compile an old c project with Visual Studio 2015 however I keep getting c compiler is unknown. The error from cmake is as following;
Compiling the C compiler identification source file "CMakeCCompilerId.c" failed.
Compiler:
Build flags:
Id flags:
The output was:
1
Microsoft (R) Build Engine version 14.0.25123.0
Copyright (C) Microsoft Corporation. All rights reserved.
Build started 23/06/2016 14:46:48.
Project "D:\Modules\cmake-test\build\CMakeFiles\3.6.0- rc3\CompilerIdC\CompilerIdC.vcxproj" on node 1 (default targets).
PrepareForBuild:
Creating directory "Debug\".
Creating directory "Debug\CompilerIdC.tlog\".
InitializeBuildStatus:
Creating "Debug\CompilerIdC.tlog\unsuccessfulbuild" because "AlwaysCreate" was specified.
ClCompile:
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\CL.exe /c /nologo /W0 /WX- /Od /Oy- /D _MBCS /Gm- /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Fo"Debug\\" /Fd"Debug\vc140.pdb" /Gd /TC /analyze- /errorReport:queue CMakeCCompilerId.c
CMakeCCompilerId.c
Link:
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\link.exe /ERRORREPORT:QUEUE /OUT:".\CompilerIdC.exe" /INCREMENTAL:NO /NOLOGO kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /manifest:embed /PDB:".\CompilerIdC.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:".\CompilerIdC.lib" /MACHINE:X86 /SAFESEH Debug\CMakeCCompilerId.obj
LINK : fatal error LNK1158: cannot run 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\rc.exe' [D:\Modules\cmake-test\build\CMakeFiles\3.6.0-rc3\CompilerIdC\CompilerIdC.vcxproj]
Done Building Project "D:\Modules\cmake-test\build\CMakeFiles\3.6.0-rc3\CompilerIdC\CompilerIdC.vcxproj" (default targets) -- FAILED.
Build FAILED.
"D:\Modules\cmake-test\build\CMakeFiles\3.6.0-rc3\CompilerIdC\CompilerIdC.vcxproj" (default target) (1) ->
(Link target) ->
LINK : fatal error LNK1158: cannot run 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\rc.exe' [D:\Modules\cmake-test\build\CMakeFiles\3.6.0-rc3\CompilerIdC\CompilerIdC.vcxproj]
0 Warning(s)
1 Error(s)
Time Elapsed 00:00:00.39
I have looked at these answers but not found a working solution.
Cmake Visual Studio 2015 Identification Unknown
CMake cannot identify C compiler from installed Visual Studio 2015
CMake does not find Visual C++ compiler
C compiler identification is unknown despite setting CC and CXX variables
The command I am using is
cmake -G "Visual Studio 14 2015" .
I have tried both 3.6.0-rc3 and 3.5.2 versions of cmake.
I got rc.exe on my path by following instructions from this question.
Visual Studio can't build due to rc.exe
Any help would be greatly appreciated!
Go to MSVC setup from control panel, modify the installation and set this flag
(for me installing SDK from M$ website strangely didn't help)
I am new to Windows driver development and minifilters and I am trying to build the nullFilter sample using command line tools.
So I added #pragma comment(lib, "FltMgr.lib") to the .c file and issued the following commands successfully:
cl.exe /nologo /Fo../../bin\filter.obj /c filter.c /D _AMD64_
rc.exe /nologo /Fo../../bin\filter.res filter.rc
However, when I try to create the sys file:
link.exe /nologo /DRIVER:WDM /out:../../bin\filter.sys ../../bin\filter.obj ../../bin\filter.res
LINK : error LNK2001: unresolved external symbol NtProcessStartup
../../bin\filter.sys : fatal error LNK1120: 1 unresolved externals
I am using VS2012 Express and WDM8. My LIB environment variable is:
C:\Program Files (x86)\Windows Kits\8.0\Lib\win8\um\x64;C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\lib\amd64;C:\Program Files (x86)\Windows Kits\8.0\Lib\win8\km\x64;
What am I doing wrong? Am I missing something?
NtProcessStartup function is to driver development what 'main' is for regular C programs. In other words, it is the program entry function that you need to provide yourself. See the article here for an introduction and explanation of this function. You can overrule the name of the startup function by using the -entry linker option. Setting '-entry:DriverEntry' is a common practice for driver development.
I have project lets say PROJECT in C. It contains a number of header files and source files. I build the project in following way
File->New->project from external files
I gave the location of the project files and Name of the project.
Choose the option as Console
and then finish
The project is seen in the solution bar with
external dependencies, header and source file.
When I build it i get error in header file such as
1>C:\Program Files\Microsoft Visual Studio 10.0\VC\include\sys/_types.h(15): error C2054: expected '(' to follow '__extension__'
1>C:\Program Files\Microsoft Visual Studio 10.0\VC\include\stddef.h(73): error C2085: '__threadid' : not in formal parameter list
1>C:\Program Files\Microsoft Visual Studio 10.0\VC\include\stddef.h(75): error C2085: '__threadhandle' : not in formal parameter list
1>C:\Program Files\Microsoft Visual Studio 10.0\VC\include\sys/_types.h(37): error C2085: '_flock_t' : not in formal parameter list
1>C:\Program Files\Microsoft Visual Studio 10.0\VC\include\sys/_types.h(40): error C2085: '_iconv_t' : not in formal parameter list
1>C:\Program Files\Microsoft Visual Studio 10.0\VC\include\sys/unistd.h(15): error C2082: redefinition of formal parameter '_environ'
1>C:\Program Files\Microsoft Visual Studio 10.0\VC\include\sys/unistd.h(17): error C2082: redefinition of formal parameter '_exit'
1>C:\Program Files\Microsoft Visual Studio 10.0\VC\include\sys/unistd.h(19): error C2085: 'access' : not in formal parameter list
What can be the reason for it?
The __extension__ keyword is used by gcc to indicate that you know that something is an extension but want to use it anyway, and request the compiler not to warn about that.
http://gcc.gnu.org/onlinedocs/gcc/Alternate-Keywords.html
Seems like you include some header that is gcc specific and doesn't work for MSVC.