I am compiling my C source code in MS visual Studio C++ 2010.I am getting following following errors while building. What can be the reasons for it?
C:\Program Files\Microsoft Visual Studio 10.0\VC\include\sys/time.h(18): error C2061: syntax error : identifier 'suseconds_t'
C:\Program Files\Microsoft Visual Studio 10.0\VC\include\sys/time.h(19): error C2059: syntax error : '}'
C:\Program Files\Microsoft Visual Studio 10.0\VC\include\sys/time.h(37): error C2079: 'it_interval' uses undefined struct 'timeval'
C:\Program Files\Microsoft Visual Studio 10.0\VC\include\sys/time.h(38): error C2079: 'it_value' uses undefined struct 'timeval'
[EDIT ]
Following is the code in my program:
#ifndef _DWORD_DEFINED
#define _DWORD_DEFINED
typedef unsigned long DWORD;
#endif
int getTime(struct timeval * tp, void * tzp)
{
DWORD milliseconds;
milliseconds = timeGetTime();
tp->tv_sec = milliseconds / 1000;
tp->tv_usec = (milliseconds % 1000) * 1000;
return 0;
}
Without any code, all I can say is this:
The first error cause is this.
The second error cause is this.
The third and fourth error cause is this.
Edit: After the OP's edit, the errors are more than obvious. Look at the struct timeval.
Where is it's definition? You access members of that struct and still you there is no visible definition of the struct.
Related
I have a TensorFlow Lite C API library that I am using on Windows and I want it to use a GPU delegate. I do not have any trouble compiling the TensorFlow Lite C API library with bazel on my Windows machine, but I cannot get the GPU delegate to compile.
TensorFlow version: 2.10.0
Windows version: 10.0.19044
Even though TFLite does not support the Windows platform there is a clear indication that it should be possible to compile a GPU delegate for the Windows platform using ANGLE library (see https://github.com/tensorflow/tensorflow/issues/28830#issuecomment-522325199).
It feels like I am close to the solution but I must be missing something fundamental. I am quite new to most of the tools and concepts involved, but I managed to stitch together the following procedure:
Installed ANGLE according to https://chromium.googlesource.com/angle/angle/+/main/doc/DevSetup.md (COMMIT=596c2acfa5071eb643eaffe855a5ccb51c345427)
Built ANGLE libraries with following args (args.gn):
is_component_build = false
target_cpu = "x64"
is_debug = false
angle_assert_always_on = false
Added ANGLE build output directory (containing libEGL.dll, libEGL.dll.lib, libGLESv2.dll, libGLESv2.dll.lib, d3dcompiler_47.dll) to PATH environment variable.
Added ANGLE library dependency in bazel:
In WORKSPACE file:
new_local_repository(
name = "angle",
path = "../../../angle/angle/include",
build_file_content = """
package(default_visibility = ["//visibility:public"])
cc_library(
name = "headers",
srcs = glob(["**/*.h"])
)
"""
)
Added necessary dependencies (copts = ["-Iexternal/angle"] and "#angle//:headers") to targets in bazel BUILD files (all targets that failed compilation due to missing OpenGL headers):
Example:
cc_library(
name = "gl_errors",
srcs = ["gl_errors.cc"],
hdrs = ["gl_errors.h"],
copts = ["-Iexternal/angle"], <--- ADDED THIS
deps = [
"#angle//:headers", <--- ADDED THIS
":portable",
"//tensorflow/lite/delegates/gpu/common:status",
"#com_google_absl//absl/strings",
],
)
Updated .bazel to use '/std:c++latest'
---build:windows --cxxopt=/std:c++17
---build:windows --host_cxxopt=/std:c++17
+++build:windows --cxxopt=/std:c++latest
+++build:windows --host_cxxopt=/std:c++latest
Build TensorFlow Lite GPU delegate (v2.10.0) //tensorflow/lite/delegates/gpu:libtensorflowlite_gpu_delegate.so
bazel2 build --local_cpu_resources=3 --features=windows_export_all_symbols -s -c opt --copt="-DMESA_EGL_NO_X11_HEADERS" --copt="-DEGL_NO_X11" //tensorflow/lite/delegates/gpu:libtensorflowlite_gpu_delegate.so
I expected to get the two files libtensorflowlite_gpu_delegate.so.dll and libtensorflowlite_gpu_delegate.so.if.lib but I get errors that I do not know how to mitigate.
ERROR: C:/users/magnusg/src/tensorflow_lite/tflite_2.10.0_gpu_delegate_build_bazel/tensorflow_src/tensorflow/lite/delegates/gpu/cl/kernels/BUILD:129:11: Compiling tensorflow/lite/delegates/gpu/cl/kernels/converter.cc failed: (Exit 2): cl.exe failed: error executing command
cd /d C:/users/magnusg/_bazel_magnusg/4du655w4/execroot/org_tensorflow
SET INCLUDE=C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.28.29910\include;C:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um;C:\Program Files (x86)\Windows Kits\10\include\10.0.20348.0\ucrt;C:\Program Files (x86)\Windows Kits\10\include\10.0.20348.0\shared;C:\Program Files (x86)\Windows Kits\10\include\10.0.20348.0\um;C:\Program Files (x86)\Windows Kits\10\include\10.0.20348.0\winrt;C:\Program Files (x86)\Windows Kits\10\include\10.0.20348.0\cppwinrt
SET PATH=C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.28.29910\bin\HostX64\x64;C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\Common7\IDE\VC\VCPackages;C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\Common7\IDE\CommonExtensions\Microsoft\TestWindow;C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer;C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\bin\Roslyn;C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools\x64\;C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\Common7\Tools\devinit;C:\Program Files (x86)\Windows Kits\10\bin\10.0.20348.0\x64;C:\Program Files (x86)\Windows Kits\10\bin\x64;C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\\MSBuild\Current\Bin;c:\Windows\Microsoft.NET\Framework64\v4.0.30319;C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\Common7\IDE\;C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\Common7\Tools\;;C:\Windows\system32;C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin;C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\Common7\IDE\CommonExtensions\Microsoft\CMake\Ninja
SET PWD=/proc/self/cwd
SET PYTHON_BIN_PATH=C:/Users/magnusg/anaconda3/envs/sa/python.exe
SET PYTHON_LIB_PATH=C:/Users/magnusg/anaconda3/envs/sa/lib/site-packages
SET RUNFILES_MANIFEST_ONLY=1
SET TEMP=C:\Users\magnusg\AppData\Local\Temp
SET TF2_BEHAVIOR=1
SET TMP=C:\Users\magnusg\AppData\Local\Temp
SET avariable=3
C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.28.29910\bin\HostX64\x64\cl.exe #bazel-out/x64_windows-opt/bin/tensorflow/lite/delegates/gpu/cl/kernels/_objs/converter/converter.obj.params
# Configuration: 4692499b740a707abb55d09dbd7c915fbefe7b433a9f783356c086c94c980334
# Execution platform: #local_execution_config_platform//:platform
cl : Command line warning D9035 : option 'experimental:preprocessor' has been deprecated and will be removed in a future release
cl : Command line warning D9036 : use 'Zc:preprocessor' instead of 'experimental:preprocessor'
cl_version.h: CL_TARGET_OPENCL_VERSION is not defined. Defaulting to 300 (OpenCL 3.0)
.\tensorflow/lite/delegates/gpu/cl/opencl_wrapper.h(526): error C2059: syntax error: '__cdecl'
.\tensorflow/lite/delegates/gpu/cl/opencl_wrapper.h(532): error C2065: 'cl_command_buffer_khr': undeclared identifier
.\tensorflow/lite/delegates/gpu/cl/opencl_wrapper.h(532): error C2165: 'left-side modifier': cannot modify pointers to data
.\tensorflow/lite/delegates/gpu/cl/opencl_wrapper.h(532): error C2513: 'cl_int *': no variable declared before '='
.\tensorflow/lite/delegates/gpu/cl/opencl_wrapper.h(535): error C2065: 'cl_command_buffer_khr': undeclared identifier
.\tensorflow/lite/delegates/gpu/cl/opencl_wrapper.h(535): error C2165: 'left-side modifier': cannot modify pointers to data
.\tensorflow/lite/delegates/gpu/cl/opencl_wrapper.h(535): error C2513: 'cl_int *': no variable declared before '='
.\tensorflow/lite/delegates/gpu/cl/opencl_wrapper.h(538): error C2065: 'cl_command_buffer_khr': undeclared identifier
.\tensorflow/lite/delegates/gpu/cl/opencl_wrapper.h(538): error C2165: 'left-side modifier': cannot modify pointers to data
.\tensorflow/lite/delegates/gpu/cl/opencl_wrapper.h(538): error C2513: 'cl_int *': no variable declared before '='
.\tensorflow/lite/delegates/gpu/cl/opencl_wrapper.h(542): error C2061: syntax error: identifier 'cl_command_buffer_khr'
.\tensorflow/lite/delegates/gpu/cl/opencl_wrapper.h(547): error C2065: 'cl_command_buffer_khr': undeclared identifier
.\tensorflow/lite/delegates/gpu/cl/opencl_wrapper.h(548): error C2275: 'cl_command_queue': illegal use of this type as an expression
external/angle\CL/cl.h(32): note: see declaration of 'cl_command_queue'
.\tensorflow/lite/delegates/gpu/cl/opencl_wrapper.h(549): error C2059: syntax error: 'const'
.\tensorflow/lite/delegates/gpu/cl/opencl_wrapper.h(559): error C2065: 'cl_command_buffer_khr': undeclared identifier
.\tensorflow/lite/delegates/gpu/cl/opencl_wrapper.h(560): error C2065: 'cl_command_buffer_info_khr': undeclared identifier
.\tensorflow/lite/delegates/gpu/cl/opencl_wrapper.h(560): error C2275: 'size_t': illegal use of this type as an expression
tensorflow/lite/delegates/gpu/cl/kernels/converter.cc: note: see declaration of 'size_t'
.\tensorflow/lite/delegates/gpu/cl/opencl_wrapper.h(561): error C2062: type 'void' unexpected
.\tensorflow/lite/delegates/gpu/cl/opencl_wrapper.h(682): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
.\tensorflow/lite/delegates/gpu/cl/opencl_wrapper.h(682): error C2146: syntax error: missing ';' before identifier 'clCreateCommandBufferKHR'
.\tensorflow/lite/delegates/gpu/cl/opencl_wrapper.h(687): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
.\tensorflow/lite/delegates/gpu/cl/opencl_wrapper.h(687): error C2146: syntax error: missing ';' before identifier 'clCommandNDRangeKernelKHR'
.\tensorflow/lite/delegates/gpu/cl/opencl_wrapper.h(688): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
.\tensorflow/lite/delegates/gpu/cl/opencl_wrapper.h(688): error C2146: syntax error: missing ';' before identifier 'clGetCommandBufferInfoKHR'
Target //tensorflow/lite/delegates/gpu:libtensorflowlite_gpu_delegate.so failed to build
INFO: Elapsed time: 375.856s, Critical Path: 62.04s
INFO: 686 processes: 15 internal, 671 local.
FAILED: Build did NOT complete successfully
I do not know if I am on the right track and simply missing a minor detail or if I am missing the target completely. Any feedback would be helpful.
I'm trying to write a simple program to display shapes using 3dCoin
however when starting to debug the program it gives me 51 errors in cmath file in which I did not change anything in it since it is a standard file.
#include <Inventor/Win/SoWin.h>
#include <Inventor/Win/viewers/SoWinExaminerViewer.h>
#include <Inventor/nodes/SoSeparator.h>
#include <vector>// when I include vector it gives me the errors
int main(int, char ** argv) {
HWND window = SoWin::init("0.off");
if (window == NULL) exit(1);
SoSeparator * root = new SoSeparator;
root->ref();
SoWinExaminerViewer *viewer = new SoWinExaminerViewer(window);
viewer->setSize(SbVec2s(640, 480));
viewer->setSceneGraph(root);
viewer->show();
SoWin::show(window);
SoWin::mainLoop();
delete viewer;
root->unref();
return 0;
}
The type of errors I'm getting are:
Severity Code Description Project File Line Suppression State
Error C2589 '(': illegal token on right side of '::' project c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.10.25017\include\cmath 19
Severity Code Description Project File Line Suppression State
Error C2440 'type cast': cannot convert from 'float' to 'unknown-type (__cdecl *)(float)' project c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.10.25017\include\cmath 19
and many more.....
Can anyone help find the reason I have been trying to find a solution for a while but could not understand the reason behind such errors?
I've received exactly the same error with you. More than 30 lines of cmath and also int8_t type redefinition error. I've solved this problem by putting each of my header files above Inventors and then I've put #define HAVE_INT8_T above everything in my source files due to the int8_t type redefinition error. Then, compile error is gone.
I have got an issue after using the Platform Toolset v141 in Visual Studio 2017 for Debug 64 bit compilation.
typedef std::map<int, msclr::gcroot<cli::array<short>^>> MapIntToManaged;
int main(array<System::String ^> ^args)
{
MapIntToManaged testMap;
for (auto &it : testMap) {}
return 0;
}
This results in the linker error
error LNK2022: metadata operation failed (8013118D) : Inconsistent layout information in duplicated types (std._Tree_unchecked_const_iterator< ?? :: ?? >): (0x02000048).
1>LINK : fatal error LNK1255: link failed because of metadata errors
I found a couple of workarounds to get rid of this error:
changing the Platform Toolset back to v140
using this syntax instead of the auto iterator:
for (MapIntToManaged::iterator it = testMap.begin(); it != testMap.end(); ++it) {}
changing the Runtime Library from Multi-threaded Debug DLL (/MDd) to Multi-threaed DLL (/MD) and use NDEBUG instead of _DEBUG as preprocessor define
using 32 bit instead of 64 bit
I'd like to understand this issue.
And I want to use the newest toolset, the new iterator syntax and the Debug runtime DLL.
I am using below snippet in my code.
//from Vista WinNT.h
//
typedef struct _TOKEN_MANDATORY_LABEL {
SID_AND_ATTRIBUTES Label;
} TOKEN_MANDATORY_LABEL, *PTOKEN_MANDATORY_LABEL;
When I build this through VS2005 it give no error. But when I am building using make file i am getting below error in cmd:
Test.cpp(337) : error C2011: '_TOKEN_MANDATORY_LABEL' : 'struct' type redefinition
C:\Program Files\Microsoft SDKs\Windows\v6.1\include\winnt.h(7351) : see declaration of '_TOKEN_MANDATORY_LABEL'
I am using Opus software to use make file. Please let me know if I am missing something or needs to add some libs to overcome this error.
I'm porting some C++ code from UNIX to Windows which detects the occurrence of the EDQUOT error, which indicates that there was an unsuccessful attempt to exceed the current user's disk quota. Visual Studio's <errno.h> doesn't have an EDQUOT, although I know that Windows has disk quota functionality. Visual Studio's <errno.h> does have an ENOSPC, which might be how the CRT expresses what UNIX would express as EDQUOT. Can anybody confirm or deny this theory? And if this isn't the way to handle this, what is?
C:\Program Files\Microsoft SDKs\Windows\v7.0A\Include\WinSock.h
C:\Program Files\Microsoft SDKs\Windows\v7.1\Include\WinSock.h
#if 0
#define EDQUOT WSAEDQUOT
#endif
C:\Program Files\Microsoft SDKs\Windows\v7.0A\Include\WinError.h
C:\Program Files\Microsoft SDKs\Windows\v7.1\Include\WinError.h
//
// MessageId: WSAEDQUOT
//
// MessageText:
//
// Ran out of disk quota.
//
#define WSAEDQUOT 10069L