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

LINK : fatal error LNK1181: cannot open input file 'gdi32.lib' #897

Closed
nickzuber opened this issue Mar 31, 2016 · 5 comments
Closed

LINK : fatal error LNK1181: cannot open input file 'gdi32.lib' #897

nickzuber opened this issue Mar 31, 2016 · 5 comments
Labels

Comments

@nickzuber
Copy link

  • My machine is running on Windows 10
  • Using node v4.1.2
  • Using npm v3.8.3
  • Using node-gyp v3.3.1

Following the very basic set up tutorial to get a Node Addon working, which you can find here (my set up and configuration is exactly the same as this directory):

https://github.com/kkaefer/node-cpp-modules/tree/master/01_bare_minimum

When I node-gyp configure everything seems to configure fine and no errors are thrown, however when I try to node-gyp build I always end up with this fatal linking error to some input file named gdi32.lib. Here is the response I get when I perform both of these commands:

C:\~projects\needle\scripts\testing>node-gyp configure
gyp info it worked if it ends with ok
gyp info using node-gyp@3.3.1
gyp info using node@4.1.2 | win32 | x64
gyp info spawn C:\Python27\python.EXE
gyp info spawn args [ 'C:\\Users\\Nicholas\\AppData\\Roaming\\npm\\node_modules\\node-gyp\\gyp\\gyp_main.py',
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:\\~projects\\needle\\scripts\\testing\\build\\config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   'C:\\Users\\Nicholas\\AppData\\Roaming\\npm\\node_modules\\node-gyp\\addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   'C:\\Users\\Nicholas\\.node-gyp\\4.1.2\\include\\node\\common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=C:\\Users\\Nicholas\\.node-gyp\\4.1.2',
gyp info spawn args   '-Dnode_gyp_dir=C:\\Users\\Nicholas\\AppData\\Roaming\\npm\\node_modules\\node-gyp',
gyp info spawn args   '-Dnode_lib_file=node.lib',
gyp info spawn args   '-Dmodule_root_dir=C:\\~projects\\needle\\scripts\\testing',
gyp info spawn args   '--depth=.',
gyp info spawn args   '--no-parallel',
gyp info spawn args   '--generator-output',
gyp info spawn args   'C:\\~projects\\needle\\scripts\\testing\\build',
gyp info spawn args   '-Goutput_dir=.' ]
gyp info ok

C:\~projects\needle\scripts\testing>node-gyp build
gyp info it worked if it ends with ok
gyp info using node-gyp@3.3.1
gyp info using node@4.1.2 | win32 | x64
gyp info spawn C:\Program Files (x86)\MSBuild\12.0\bin\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=x64' ]
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
  win_delay_load_hook.c
LINK : fatal error LNK1181: cannot open input file 'gdi32.lib' [C:\~projects\needle\scripts\testing\build\modulename.vcxproj]
gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\MSBuild\12.0\bin\msbuild.exe` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (C:\Users\Nicholas\AppData\Roaming\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 (x86)\\nodejs\\node.exe" "C:\\Users\\Nicholas\\AppData\\Roaming\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "build"
gyp ERR! cwd C:\~projects\needle\scripts\testing
gyp ERR! node -v v4.1.2
gyp ERR! node-gyp -v v3.3.1
gyp ERR! not ok

Any help would be greatly appreciated - I'm still relatively new with Node Addons and I'm a bit lost here as to what could be going wrong.

@bnoordhuis
Copy link
Member

Can you post the exact contents of your binding.gyp?

@nickzuber
Copy link
Author

@bnoordhuis

{
  "targets": [
    {
      "target_name": "modulename",
      "sources": [ "modulename.cpp" ]
    }
  ]
}

And my modulename.cpp is in the same directory as my binding.gyp

@bnoordhuis
Copy link
Member

I can't tell you exactly what goes wrong but gdi32 is a system library; the .lib for it is normally shipped with the Windows SDK or Visual Studio. Is it anywhere on your hard drive?

@nickzuber
Copy link
Author

@bnoordhuis Thanks for the tip; so I redownloaded Microsoft Visual Studio 2015 and made sure to do a custom that included the Microsoft Visual SDK. That resolved my LINK error, but now I have a new error:

TRACKER : error TRK0005: Failed to locate: "CL.exe". The system cannot find the file specified.

I tried googling this error and people were saying to try the command npm config set msvs_version 2013 --global but that had no effect.

Any ideas?

EDIT:

I found a cl.exe file in the path C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin. How can I configure node-gyp to find this file?

@nickzuber
Copy link
Author

So I booted up VS15 and downloaded some C++ SDK and now everything works perfectly! Thank you @bnoordhuis for all your help. I'm going to close this issue as it is resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants