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

Windows support? #3

Closed
adrai opened this issue Mar 4, 2013 · 4 comments
Closed

Windows support? #3

adrai opened this issue Mar 4, 2013 · 4 comments

Comments

@adrai
Copy link

adrai commented Mar 4, 2013

Is there a plan to support Windows operating systems, too?

@kevinmehall
Copy link
Contributor

Yes, at some point. Have you tried building it on Windows? What breaks?

@adrai
Copy link
Author

adrai commented Mar 5, 2013

C:\Users\user\Desktop\node-usb-master>node-gyp configure
gyp info it worked if it ends with ok
gyp info using node-gyp@0.8.5
gyp info using node@0.8.21 | win32 | ia32
gyp info spawn C:\Python27\python.exe
gyp info spawn args [ 'C:\Users\user\AppData\Roaming\npm\node_modules\node-gyp\gyp\gyp',
gyp info spawn args 'binding.gyp',
gyp info spawn args '-f',
gyp info spawn args 'msvs',
gyp info spawn args '-G',
gyp info spawn args 'msvs_version=auto',
gyp info spawn args '-I',
gyp info spawn args 'C:\Users\user\Desktop\node-usb-master\build\config.gypi',
gyp info spawn args '-I',
gyp info spawn args 'C:\Users\user\AppData\Roaming\npm\node_modules\node-gyp\addon.gypi',
gyp info spawn args '-I',
gyp info spawn args 'C:\Users\user.node-gyp\0.8.21\common.gypi',
gyp info spawn args '-Dlibrary=shared_library',
gyp info spawn args '-Dvisibility=default',
gyp info spawn args '-Dnode_root_dir=C:\Users\user.node-gyp\0.8.21',
gyp info spawn args '-Dmodule_root_dir=C:\Users\user\Desktop\node-usb-master',
gyp info spawn args '--depth=.',
gyp info spawn args '--generator-output',
gyp info spawn args 'C:\Users\user\Desktop\node-usb-master\build',
gyp info spawn args '-Goutput_dir=.' ]
gyp info ok

C:\Users\user\Desktop\node-usb-master>node-gyp build
gyp info it worked if it ends with ok
gyp info using node-gyp@0.8.5
gyp info using node@0.8.21 | win32 | ia32
gyp info spawn C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe
gyp info spawn args [ 'build/binding.sln',
gyp info spawn args '/clp:Verbosity=minimal',
gyp info spawn args '/nologo',
gyp info spawn args '/p:Configuration=Release;Platform=Win32' ]
endpoint.cc
interface.cc
c:\users\user\desktop\node-usb-master\src\node_usb.h(5): fatal error C1083: Datei (Include) kann nicht geöffn
et werden: "unistd.h": No such file or directory [C:\Users\user\Desktop\node-usb-master\build\usb_bindings.vc
xproj]
usb.cc
c:\users\user\desktop\node-usb-master\src\node_usb.h(5): fatal error C1083: Datei (Include) kann nicht geöffn
et werden: "unistd.h": No such file or directory [C:\Users\user\Desktop\node-usb-master\build\usb_bindings.vc
xproj]
stream.cc
c:\users\user\desktop\node-usb-master\src\node_usb.h(5): fatal error C1083: Datei (Include) kann nicht geöffn
et werden: "unistd.h": No such file or directory [C:\Users\user\Desktop\node-usb-master\build\usb_bindings.vc
xproj]
transfer.cc
c:\users\user\desktop\node-usb-master\src\node_usb.h(5): fatal error C1083: Datei (Include) kann nicht geöffn
et werden: "unistd.h": No such file or directory [C:\Users\user\Desktop\node-usb-master\build\usb_bindings.vc
xproj]
device.cc
c:\users\user\desktop\node-usb-master\src\node_usb.h(5): fatal error C1083: Datei (Include) kann nicht geöffn
et werden: "unistd.h": No such file or directory [C:\Users\user\Desktop\node-usb-master\build\usb_bindings.vc
xproj]
bindings.cc
c:\users\user\desktop\node-usb-master\src\node_usb.h(5): fatal error C1083: Datei (Include) kann nicht geöffn
et werden: "unistd.h": No such file or directory [C:\Users\user\Desktop\node-usb-master\build\usb_bindings.vc
xproj]
node_usb.cc
c:\users\user\desktop\node-usb-master\src\node_usb.h(5): fatal error C1083: Datei (Include) kann nicht geöffn
et werden: "unistd.h": No such file or directory [C:\Users\user\Desktop\node-usb-master\build\usb_bindings.vc
xproj]
c:\users\user\desktop\node-usb-master\src\node_usb.h(5): fatal error C1083: Datei (Include) kann nicht geöffn
et werden: "unistd.h": No such file or directory [C:\Users\user\Desktop\node-usb-master\build\usb_bindings.vc
xproj]
gyp ERR! build error
gyp ERR! stack Error: C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe failed with exit code: 1
gyp ERR! stack at ChildProcess.onExit (C:\Users\user\AppData\Roaming\npm\node_modules\node-gyp\lib\build.j
s:256:23)
gyp ERR! stack at ChildProcess.EventEmitter.emit (events.js:99:17)
gyp ERR! stack at Process._handle.onexit (child_process.js:678:10)
gyp ERR! System Windows_NT 6.1.7600
gyp ERR! command "node" "C:\Users\user\AppData\Roaming\npm\node_modules\node-gyp\bin\node-gyp.js" "bu
ild"
gyp ERR! cwd C:\Users\user\Desktop\node-usb-master
gyp ERR! node -v v0.8.21
gyp ERR! node-gyp -v v0.8.5
gyp ERR! not ok

C:\Users\user\Desktop\node-usb-master>

@kevinmehall
Copy link
Contributor

I've added support for building on Windows in 570e783. (Not in npm yet, but will soon be 0.2.0)

Tested with MSVC 2010 Express on WinXP, Node 0.10, and libusbx 1.0.14. All tests pass except for one checking error-handling; not sure if that's libusbx or node-usb.

In addition to the Python and MSVC required by node-gyp, you'll need to get a binary build of libusbx and extract it at C:\Program Files\libusb. Libusb requires that you register devices with the WinUSB driver with Zadig before they can be used.

@adrai
Copy link
Author

adrai commented Mar 22, 2013

Thanks seams to build now!
Just one optimization for 32-bit and 64-bit:

{
  'targets': [  
    {
      'target_name': 'usb_bindings',
      'sources': [ 
        './src/node_usb.cc',
        './src/device.cc',
        './src/transfer.cc',
      ],
      'cflags_cc': [
        '-std=c++0x'
      ],
      'defines': [
        '_FILE_OFFSET_BITS=64',
        '_LARGEFILE_SOURCE',
      ],
      'include_dirs+': [
        'src/'
      ],
      'conditions' : [
          ['OS=="linux"', {
            'include_dirs+': [
              '<!@(pkg-config libusb-1.0 --cflags-only-I | sed s/-I//g)'
            ],
            'libraries': [
              '<!@(pkg-config libusb-1.0 --libs)'
            ],
            'defines': [
              'USE_POLL',
            ]
          }],
          ['OS=="mac"', {
            'include_dirs+': [
              '<!@(pkg-config libusb-1.0 --cflags-only-I | sed s/-I//g)'
            ],
            'libraries': [
              '<!@(pkg-config libusb-1.0 --libs)'
            ],
            'defines': [
              'USE_POLL',
            ]
          }],
          ['OS=="win"', {
            'variables': {
              # Path to extracted libusbx windows binary package from http://libusbx.org/
              'libusb_path': "C:/Program Files/libusb"
            },
            'defines':[
              'WIN32_LEAN_AND_MEAN'
            ],
            'include_dirs+': [
              '<(libusb_path)/include/libusbx-1.0'
            ],
            'msvs_settings': {
              'VCCLCompilerTool': {
                'AdditionalOptions': [ '/EHsc /MD' ],
              },
            },
            "conditions" : [
              ["target_arch=='ia32'", {
                'libraries': [
                   '<(libusb_path)/MS32/static/libusb-1.0.lib'
                ]
              }],
              ["target_arch=='x64'", {
                'libraries': [
                   '<(libusb_path)/MS64/static/libusb-1.0.lib'
                ]
              }]
            ]
          }]
      ]
    }
  ]
}

@adrai adrai closed this as completed Mar 22, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants