Node Addon node-gyp build error C2872 'byte': ambiguous symbol - node-gyp

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

Related

MSVC Manually Linking stdlib

Currently I am trying to use the C standard library in my EDK2 project.
As my Visual Studio 2019 did not automatically add the necessary include directories,
I manually added the following folders to my include directories:
C:\edk2\MdePkg\Include\X64
C:\edk2\MdePkg\Include
C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Tools\MSVC\14.28.29812\include
C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Tools\MSVC\14.28.29812\atlmfc\include
C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Auxiliary\VS\include
C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\ucrt
C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\um
C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\shared
C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\winrt
C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\cppwinrt
C:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\Include\um
As this fixed my missing #include directives, the only thing left for me was to manually
add the missing libraries to the linker arguments.
I did this as follows:
1.) After a quick Google search i found out, that I have to link my application against libucrt.lib, which i then tried to locate inside of my Windows 10 SDK by performing a simple search, which yielded me the following results:
C:\Program Files (x86)\Windows Kits\10\Lib\10.0.19041.0\ucrt\x64
As a result, I added this directory to my library directories inside Visual Studio 2019.
Not to forget, I added libucrt.lib as well:
My problem is, that after compiling my project, I still get an error from the linker:
I already tried out using different include directories, as well as different Windows SDK versions,
but none seemed to solve my problem.
I am grateful for any kind of help, thank you.
I settled on implementing the functions I needed from the stdlib myself, as #user123 proposed, in order to solve this problem and save me a lot of time.

getting cstdio errors despite it not being included? (Visual Studio)

I'm trying to compile a C program in Visual Studio 2019, I have 'Compile As' set to 'Compile as C Code (/TC)' and cstdio is not included anywhere in my project, yet it still gives me cstdio errors
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\include\cstdio(33,1): error C2061: syntax error: identifier 'std'
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\include\cstdio(33,1): error C2059: syntax error: ';'
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\include\cstdio(33,1): error C2449: found '{' at file scope (missing function header?)
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\include\cstdio(91,1): error C2059: syntax error: '}'

Unresolved external symbol "for_realloc_lhs" at compilation

I am trying to compile a SDK with pre-built Fortran libraries.
The SDK requires Intel Fortran redistributables libraries parallel studio XE 2017.
When trying to compile the SDK's example files, i get multiple errors: LNK2001 "unresolved external symol _for_realloc_lhs"
From what i read, this could be caused by the SDK's fortran library being compiled with a version of the Intel's fortran compiler that is too old.
(see here), however i do not own the SDK's fortran sources thus, i could not recompile them.
I would like to know if i am missing someting here or if the SDK's fortran library was imply built with the wrong tools.
[EDIT]
i read what you said (thanks for your very clear explanation) and it seems my problem is really close to what you just explained, i seem to link against the 11.1 version of Intel redistributables. However, it seems that the library i got on Intel's website does not feature all the files the linker is looking for. (or at least i could not find them).
There is the command visual studio used.
Unfortunately, i am unable at the moment to produce the log, as it exceeds maximum message size.
Here is a summarized version of the log
1>------ Build started: Project: Tutorials, Configuration: Debug Win32 ------
1>
1> Searching libraries
1> Searching ..\..\lib\CK_IO.lib:
1> Searching C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x86\kernel32.lib:
1> Searching C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x86\user32.lib:
1> Searching C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x86\gdi32.lib:
1> Searching C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x86\winspool.lib:
1> Searching C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x86\comdlg32.lib:
1> Searching C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x86\advapi32.lib:
1> Searching C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x86\shell32.lib:
1> Searching C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x86\ole32.lib:
1> Searching C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x86\oleaut32.lib:
1> Searching C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x86\uuid.lib:
1> Searching C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x86\odbc32.lib:
1> Searching C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x86\odbccp32.lib:
1> Searching C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\lib\legacy_stdio_definitions.lib:
1> Searching C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\lib\LIBCMT.lib:
1> Searching C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\lib\OLDNAMES.lib:
1> Searching C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\lib\libvcruntime.lib:
1> Searching C:\Program Files (x86)\Windows Kits\10\lib\10.0.10150.0\ucrt\x86\libucrt.lib:
1> Searching ..\..\lib\CK_IO.lib:
1> Searching C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x86\kernel32.lib:
1> Searching C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x86\user32.lib:
1> Searching C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x86\gdi32.lib:
1> Searching C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x86\winspool.lib:
1> Searching C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x86\comdlg32.lib:
1> Searching C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x86\advapi32.lib:
1> Searching C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x86\shell32.lib:
1> Searching C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x86\ole32.lib:
1> Searching C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x86\oleaut32.lib:
1> Searching C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x86\uuid.lib:
1> Searching C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x86\odbc32.lib:
1> Searching C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x86\odbccp32.lib:
1> Searching C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\lib\legacy_stdio_definitions.lib:
1> Searching C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\lib\LIBCMT.lib:
1> Searching C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\lib\OLDNAMES.lib:
1> Searching C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\lib\libvcruntime.lib:
1> Searching C:\Program Files (x86)\Windows Kits\10\lib\10.0.10150.0\ucrt\x86\libucrt.lib:
1> Searching C:\Program Files (x86)\Common Files\Intel\Shared Files\fortran\Lib\ia32\ifconsol.lib:
1> Searching C:\Program Files (x86)\Common Files\Intel\Shared Files\fortran\Lib\ia32\libifcoremt.lib:
1> Searching C:\Program Files (x86)\Common Files\Intel\Shared Files\fortran\Lib\ia32\libmmt.lib:
1> Searching C:\Program Files (x86)\Common Files\Intel\Shared Files\fortran\Lib\ia32\libirc.lib:
1> Searching C:\Program Files (x86)\Common Files\Intel\Shared Files\fortran\Lib\ia32\svml_dispmt.lib:
1> Searching C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x86\ImageHlp.lib:
1> Searching ..\..\lib\CK_IO.lib:
1> Searching C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x86\kernel32.lib:
1> Searching C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x86\user32.lib:
1> Searching C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x86\gdi32.lib:
1> Searching C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x86\winspool.lib:
1> Searching C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x86\comdlg32.lib:
1> Searching C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x86\advapi32.lib:
1> Searching C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x86\shell32.lib:
1> Searching C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x86\ole32.lib:
1> Searching C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x86\oleaut32.lib:
1> Searching C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x86\uuid.lib:
1> Searching C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x86\odbc32.lib:
1> Searching C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x86\odbccp32.lib:
1> Searching C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\lib\legacy_stdio_definitions.lib:
1> Searching C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\lib\LIBCMT.lib:
1> Searching C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\lib\OLDNAMES.lib:
1> Searching C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\lib\libvcruntime.lib:
1> Searching C:\Program Files (x86)\Windows Kits\10\lib\10.0.10150.0\ucrt\x86\libucrt.lib:
1> Searching C:\Program Files (x86)\Common Files\Intel\Shared Files\fortran\Lib\ia32\ifconsol.lib:
1> Searching C:\Program Files (x86)\Common Files\Intel\Shared Files\fortran\Lib\ia32\libifcoremt.lib:
1> Searching C:\Program Files (x86)\Common Files\Intel\Shared Files\fortran\Lib\ia32\libmmt.lib:
1> Searching C:\Program Files (x86)\Common Files\Intel\Shared Files\fortran\Lib\ia32\libirc.lib:
1> Searching C:\Program Files (x86)\Common Files\Intel\Shared Files\fortran\Lib\ia32\svml_dispmt.lib:
1> Searching C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x86\ImageHlp.lib:
1> Searching C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\lib\legacy_stdio_wide_specifiers.lib:
1> Searching ..\..\lib\CK_IO.lib:
1> Searching C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x86\kernel32.lib:
1> Searching C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x86\user32.lib:
1> Searching C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x86\gdi32.lib:
1> Searching C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x86\winspool.lib:
1> Searching C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x86\comdlg32.lib:
1> Searching C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x86\advapi32.lib:
1> Searching C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x86\shell32.lib:
1> Searching C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x86\ole32.lib:
1> Searching C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x86\oleaut32.lib:
1> Searching C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x86\uuid.lib:
1> Searching C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x86\odbc32.lib:
1> Searching C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x86\odbccp32.lib:
1> Searching C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\lib\legacy_stdio_definitions.lib:
1> Searching C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\lib\LIBCMT.lib:
1> Searching C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\lib\OLDNAMES.lib:
1> Searching C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\lib\libvcruntime.lib:
1>
1> Finished searching libraries
1>
1> Searching libraries
1> Searching ..\..\lib\CK_IO.lib:
1> Searching C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x86\kernel32.lib:
1> Searching C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x86\user32.lib:
1> Searching C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x86\gdi32.lib:
1> Searching C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x86\winspool.lib:
1> Searching C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x86\comdlg32.lib:
1> Searching C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x86\advapi32.lib:
1> Searching C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x86\shell32.lib:
1> Searching C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x86\ole32.lib:
1> Searching C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x86\oleaut32.lib:
1> Searching C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x86\uuid.lib:
1> Searching C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x86\odbc32.lib:
1> Searching C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x86\odbccp32.lib:
1> Searching C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\lib\legacy_stdio_definitions.lib:
1> Searching C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\lib\LIBCMT.lib:
1> Searching C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\lib\OLDNAMES.lib:
1> Searching C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\lib\libvcruntime.lib:
1> Searching C:\Program Files (x86)\Windows Kits\10\lib\10.0.10150.0\ucrt\x86\libucrt.lib:
1> Searching C:\Program Files (x86)\Common Files\Intel\Shared Files\fortran\Lib\ia32\ifconsol.lib:
1> Searching C:\Program Files (x86)\Common Files\Intel\Shared Files\fortran\Lib\ia32\libifcoremt.lib:
1> Searching C:\Program Files (x86)\Common Files\Intel\Shared Files\fortran\Lib\ia32\libmmt.lib:
1> Searching C:\Program Files (x86)\Common Files\Intel\Shared Files\fortran\Lib\ia32\libirc.lib:
1> Searching C:\Program Files (x86)\Common Files\Intel\Shared Files\fortran\Lib\ia32\svml_dispmt.lib:
1> Searching C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x86\ImageHlp.lib:
1> Searching C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\lib\legacy_stdio_wide_specifiers.lib:
1>
1> Finished searching libraries
========== Build: 0 succeeded, 1 failed, 1 up-to-date, 0 skipped ==========
I would also like to mention that the directory in which the redistributables are supposed to be installed (as mentioned here : "redist[ia32|intel64]\mpirt (for Fortran packages)") there is no library named libifcore...
Actually, there is almost nothing that looks like anything that i need to link.) an image of the mentionned folder
First, a nit. The error is coming from the link step, not compiling. Contrary to your guess about the compiler version used for the library being "too old", instead it's the set of Intel libraries (redistributables) you're linking against that are too old (or missing?) If you are truly linking against the 2017-version libraries, that routine should be in libifcore. Double and triple check how you are doing the link and which libraries you name, if any, in the link step.
An easy way to see what's going on is to add the linker option /verbose to the link step. You haven't shown how you build the application and which command is used for linking. If you're using Visual Studio, set the project property Linker > General > Show Progress to "Display all progress messages". If using the ifort command, add at the end /link /verbose If using some other command, look at its documentation to see how you should specify link options. Capture the linker output (build log or whatever) - it will name each library it searches and which symbols come from where.
It may be as simple a matter as making sure you name the Intel libraries after the SDK libraries in the link step.
If this doesn't help, edit your question to add the commands you're using to link (compile doesn't matter) and show the actual output (do not summarize).

error C2375: 'printf' : redefinition; different linkage c:\program files (x86)\microsoft visual studio 11.0\vc\include\stdio.h

I have a solution which is originally compiled for VS2015. I'm trying to compile the same code in VS2012. To do this, I've created a new solution, added these projects to the new solution and changed the project properties Platform Toolset to v110 instead of v140.
While building this solution, I am facing the error:
error C2375: 'printf' : redefinition; different linkage c:\program files (x86)\microsoft visual studio 11.0\vc\include\stdio.h 271
The line which seems to be causing this error is:
_Check_return_opt_ _CRTIMP int __cdecl printf(_In_z_ _Printf_format_string_ const char * _Format, ...);
I'm unable to figure out the root cause of this problem. Any help would be appreciated.

Errors in building C project in visual studio 2010

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.

Resources