Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error C2011: 'timespec': 'struct' type redefinition (Windows 10 issue) #144

Closed
j796160836 opened this issue Jan 24, 2016 · 14 comments
Labels

Comments

@j796160836
Copy link

@j796160836 j796160836 commented Jan 24, 2016

Hi, I got some error during install bleno and I found that might be some issue about installing libusb module.
https://github.com/sandeepmistry/bleno

lenovo-PC:bleno$ npm install usb

> usb@1.1.1 install C:\Users\lenovo\Documents\node\bleno\node_modules\usb
> node-pre-gyp install --fallback-to-build

Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
  core.c
  descriptor.c
  hotplug.c
  io.c
C:\Users\lenovo\Documents\node\bleno\node_modules\usb\libusb\libusb\os/threads_windows.h(47): error C2011: 'timespec':
'struct' type redefinition (compiling source file ..\libusb\libusb\descriptor.c) [C:\Users\lenovo\Documents\node\bleno\
node_modules\usb\build\libusb.vcxproj]
  C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\time.h(39): note: see declaration of 'timespec' (com
  piling source file ..\libusb\libusb\descriptor.c)
C:\Users\lenovo\Documents\node\bleno\node_modules\usb\libusb\libusb\os/threads_windows.h(47): error C2011: 'timespec':
'struct' type redefinition (compiling source file ..\libusb\libusb\io.c) [C:\Users\lenovo\Documents\node\bleno\node_mod
ules\usb\build\libusb.vcxproj]
  C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\time.h(39): note: see declaration of 'timespec' (com
  piling source file ..\libusb\libusb\io.c)
..\libusb\libusb\io.c(1227): warning C4244: '=': conversion from 'time_t' to 'long', possible loss of data [C:\Users\le
novo\Documents\node\bleno\node_modules\usb\build\libusb.vcxproj]
C:\Users\lenovo\Documents\node\bleno\node_modules\usb\libusb\libusb\os/threads_windows.h(47): error C2011: 'timespec':
'struct' type redefinition (compiling source file ..\libusb\libusb\hotplug.c)strerror.c [C:\Users\lenovo\Documents\node
\bleno\node_modules\usb\build\libusb.vcxproj]

  C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\time.h(39): note: see declaration of 'timespec' (com
  piling source file ..\libusb\libusb\hotplug.c)..\libusb\libusb\io.c(1902): warning C4244: '=': conversion from 'time_
  t' to 'long', possible loss of data

..\libusb\libusb\io.c(2435): warning C4244: '=': conversion from 'time_t' to 'long', possible loss of data [C:\Users\le
novo\Documents\node\bleno\node_modules\usb\build\libusb.vcxproj]
C:\Users\lenovo\Documents\node\bleno\node_modules\usb\libusb\libusb\os/threads_windows.h(47): error C2011: 'timespec':
'struct' type redefinition (compiling source file ..\libusb\libusb\core.c) [C:\Users\lenovo\Documents\node\bleno\node_m
odules\usb\build\libusb.vcxproj]
  C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\time.h(39): note: see declaration of 'timespec' (com
  piling source file ..\libusb\libusb\core.c)sync.c

  poll_windows.c
  threads_windows.c
C:\Users\lenovo\Documents\node\bleno\node_modules\usb\libusb\libusb\os/threads_windows.h(47): error C2011: 'timespec':
'struct' type redefinition (compiling source file ..\libusb\libusb\strerror.c) [C:\Users\lenovo\Documents\node\bleno\no
de_modules\usb\build\libusb.vcxproj]
  C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\time.h(39): note: see declaration of 'timespec' (com
  piling source file ..\libusb\libusb\strerror.c)
  windows_usb.c
C:\Users\lenovo\Documents\node\bleno\node_modules\usb\libusb\libusb\os/threads_windows.h(47): error C2011: 'timespec':
'struct' type redefinition (compiling source file ..\libusb\libusb\sync.c) [C:\Users\lenovo\Documents\node\bleno\node_m
odules\usb\build\libusb.vcxproj]
  C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\time.h(39): note: see declaration of 'timespec' (com
  piling source file ..\libusb\libusb\sync.c)
C:\Users\lenovo\Documents\node\bleno\node_modules\usb\libusb\libusb\os/threads_windows.h(47): error C2011: 'timespec':
'struct' type redefinition (compiling source file ..\libusb\libusb\os\threads_windows.c)win_delay_load_hook.c [C:\Users
\lenovo\Documents\node\bleno\node_modules\usb\build\libusb.vcxproj]

  C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\time.h(39): note: see declaration of 'timespec' (com
  piling source file ..\libusb\libusb\os\threads_windows.c)
..\libusb\libusb\os\threads_windows.c(194): warning C4244: '=': conversion from 'time_t' to 'long', possible loss of da
ta [C:\Users\lenovo\Documents\node\bleno\node_modules\usb\build\libusb.vcxproj]
..\libusb\libusb\os\threads_windows.c(196): warning C4244: '=': conversion from 'const time_t' to 'long', possible loss
 of data [C:\Users\lenovo\Documents\node\bleno\node_modules\usb\build\libusb.vcxproj]
C:\Users\lenovo\Documents\node\bleno\node_modules\usb\libusb\libusb\os/threads_windows.h(47): error C2011: 'timespec':
'struct' type redefinition (compiling source file ..\libusb\libusb\os\poll_windows.c) [C:\Users\lenovo\Documents\node\b
leno\node_modules\usb\build\libusb.vcxproj]
  C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\time.h(39): note: see declaration of 'timespec' (com
  piling source file ..\libusb\libusb\os\poll_windows.c)
C:\Users\lenovo\Documents\node\bleno\node_modules\usb\libusb\libusb\os/threads_windows.h(47): error C2011: 'timespec':
'struct' type redefinition (compiling source file ..\libusb\libusb\os\windows_usb.c) [C:\Users\lenovo\Documents\node\bl
eno\node_modules\usb\build\libusb.vcxproj]
  C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\time.h(39): note: see declaration of 'timespec' (com
  piling source file ..\libusb\libusb\os\windows_usb.c)
..\libusb\libusb\os\windows_usb.c(586): warning C4244: '=': conversion from '__int64' to 'unsigned int', possible loss
of data [C:\Users\lenovo\Documents\node\bleno\node_modules\usb\build\libusb.vcxproj]
..\libusb\libusb\os\windows_usb.c(1017): warning C4996: 'GetVersionExA': was declared deprecated [C:\Users\lenovo\Docum
ents\node\bleno\node_modules\usb\build\libusb.vcxproj]
  C:\Program Files (x86)\Windows Kits\8.1\Include\um\sysinfoapi.h(433): note: see declaration of 'GetVersionExA'
..\libusb\libusb\os\windows_usb.c(1020): warning C4996: 'GetVersionExA': was declared deprecated [C:\Users\lenovo\Docum
ents\node\bleno\node_modules\usb\build\libusb.vcxproj]
  C:\Program Files (x86)\Windows Kits\8.1\Include\um\sysinfoapi.h(433): note: see declaration of 'GetVersionExA'
..\libusb\libusb\os\windows_usb.c(1423): warning C4244: '=': conversion from '__int64' to 'unsigned int', possible loss
 of data [C:\Users\lenovo\Documents\node\bleno\node_modules\usb\build\libusb.vcxproj]
..\libusb\libusb\os\windows_usb.c(2558): warning C4018: '<': signed/unsigned mismatch [C:\Users\lenovo\Documents\node\b
leno\node_modules\usb\build\libusb.vcxproj]
gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (C:\Program Files (x86)\Nodist\bin\node_modules\npm\node_modules\node-gyp\lib\build.js:276:23)
gyp ERR! stack     at emitTwo (events.js:87:13)
gyp ERR! stack     at ChildProcess.emit (events.js:172:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Windows_NT 10.0.10586
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files (x86)\\Nodist\\bin\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "build" "--fallback-to-build" "--module=C:\\Users\\lenovo\\Documents\\node\\bleno\\node_modules\\usb\\src\\binding\\usb_bindings.node" "--module_name=usb_bindings" "--module_path=C:\\Users\\lenovo\\Documents\\node\\bleno\\node_modules\\usb\\src\\binding"
gyp ERR! cwd C:\Users\lenovo\Documents\node\bleno\node_modules\usb
gyp ERR! node -v v5.3.0
gyp ERR! node-gyp -v v3.2.1
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute 'C:\Program Files\nodejs\node.exe C:\Program Files (x86)\Nodist\bin\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js build --fallback-to-build --module=C:\Users\lenovo\Documents\node\bleno\node_modules\usb\src\binding\usb_bindings.node --module_name=usb_bindings --module_path=C:\Users\lenovo\Documents\node\bleno\node_modules\usb\src\binding' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (C:\Users\lenovo\Documents\node\bleno\node_modules\usb\node_modules\node-pre-gyp\lib\util\compile.js:83:29)
node-pre-gyp ERR! stack     at emitTwo (events.js:87:13)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:172:7)
node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:818:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
node-pre-gyp ERR! System Windows_NT 10.0.10586
node-pre-gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\lenovo\\Documents\\node\\bleno\\node_modules\\usb\\node_modules\\node-pre-gyp\\bin\\node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd C:\Users\lenovo\Documents\node\bleno\node_modules\usb
node-pre-gyp ERR! node -v v5.3.0
node-pre-gyp ERR! node-pre-gyp -v v0.6.19
node-pre-gyp ERR! not ok
Failed to execute 'C:\Program Files\nodejs\node.exe C:\Program Files (x86)\Nodist\bin\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js build --fallback-to-build --module=C:\Users\lenovo\Documents\node\bleno\node_modules\usb\src\binding\usb_bindings.node --module_name=usb_bindings --module_path=C:\Users\lenovo\Documents\node\bleno\node_modules\usb\src\binding' (1)
npm WARN EBUNDLEOVERRIDE Replacing bundled node_modules\usb\node_modules\node-pre-gyp with new installed version
npm ERR! Windows_NT 10.0.10586
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "usb"
npm ERR! node v5.3.0
npm ERR! npm  v3.3.12
npm ERR! code ELIFECYCLE

npm ERR! usb@1.1.1 install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the usb@1.1.1 install script 'node-pre-gyp install --fallback-to-build'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the usb package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-pre-gyp install --fallback-to-build
npm ERR! You can get their info via:
npm ERR!     npm owner ls usb
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     C:\Users\lenovo\Documents\node\bleno\npm-debug.log
lenovo-PC:bleno$

Some info I had install

  1. Python 2.7.11
  2. Visual Studio Community 2015 Edition
  3. node-gyp@3.2.1
  4. node@5.3.0
  5. Windows 10

How can I fix is problem?
Any help or suggestion is appreciate.

@j796160836

This comment has been minimized.

Copy link
Author

@j796160836 j796160836 commented Jan 24, 2016

I closed the thread in node-usb because of duplicate. The problem not solved.

@mcuee

This comment has been minimized.

Copy link
Contributor

@mcuee mcuee commented Jan 25, 2016

@mcuee mcuee closed this Feb 11, 2016
@HollaDieWaldFee0815

This comment has been minimized.

Copy link

@HollaDieWaldFee0815 HollaDieWaldFee0815 commented Apr 13, 2016

I simply removed the typestruc lines in threads_windows.h file and voila its working ;)

@younesherlock

This comment has been minimized.

Copy link

@younesherlock younesherlock commented Nov 8, 2016

@HollaDieWaldFee0815 : I totally agree ! I did the same in it works after five days of struggle !!! :@

SkyLined added a commit to SkyLined/libusb that referenced this issue Dec 30, 2016
Issue was claimed to be fixed, but still happens with Windows SDK 10.0.10240.0 and latest usb 1.2.0 (latest on npm).

The first definition is in time.h in the Windows SDK, which also does a #DEFINE _INC_TIME. Checking for this define allows us to skip redefining the struct and avoid this error.
@SkyLined

This comment has been minimized.

Copy link

@SkyLined SkyLined commented Dec 30, 2016

Alternatively, if you are installing another package through npm that has a dependency on usb and installation is failing, you may want to temporarily remove this struct from the SDK, so you can install usb and your package, before reverting the SDK.

You can comment out the struct in the Windows SDK file by looking for the file that contains it in the error message: you should see a message that refers to this file with a path similar to this:

  C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\time.h(39)

Run notepad (or another editor) as administrator, as this file cannot be edited without admin rights. open the file, look for the struct, it should look like this:

    struct timespec
    {
        time_t tv_sec;  // Seconds - >= 0
        long   tv_nsec; // Nanoseconds - [0, 999999999]
    };

Just put "//" in front of every line to comment them out and save the file. Then try installing again; it should now work. After installation, remove the "//"-s again and save the file to undo your temporary modifications.

@mcuee

This comment has been minimized.

Copy link
Contributor

@mcuee mcuee commented Dec 31, 2016

I tend to think this has been fixed in later version of the Windows SDK. In version 10.0.14393., the above was guarded by the following.
#ifndef _CRT_NO_TIME_T
and
#endif

@mcuee

This comment has been minimized.

Copy link
Contributor

@mcuee mcuee commented Dec 31, 2016

Reopen the issue.

@mcuee mcuee added the windows label Dec 31, 2016
@Good4m

This comment has been minimized.

Copy link

@Good4m Good4m commented Jan 25, 2017

I am going to do some more testing later today. I will post my findings asap.

@mcuee

This comment has been minimized.

Copy link
Contributor

@mcuee mcuee commented Feb 13, 2017

@Good4m Any new updates?

@Good4m

This comment has been minimized.

Copy link

@Good4m Good4m commented Feb 15, 2017

Negative. Sorry I just don't have the time I thought I had. You know how it is =/

@mcuee

This comment has been minimized.

Copy link
Contributor

@mcuee mcuee commented Feb 15, 2017

@dickens

This comment has been minimized.

Copy link
Member

@dickens dickens commented Aug 25, 2017

@Good4m, @mcuee, any update on this?

@mcuee

This comment has been minimized.

Copy link
Contributor

@mcuee mcuee commented Sep 10, 2017

@mcuee

This comment has been minimized.

Copy link
Contributor

@mcuee mcuee commented Sep 10, 2017

Close this for now. Will reopen if someone provides more updates and if later version of Windows SDK shows problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
7 participants
You can’t perform that action at this time.