Jordan
Jordan

Reputation: 715

link.exe returns error LNK1181: cannot open input file 'C:\Program.obj'

I'm compiling with a Batch file containing

@echo off

set link=C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin\link

"%link%" external_input.obj periodic_dinger.obj flagger.obj monitor.obj main.obj libGui.lib libCore.lib libCint.lib libRIO.lib libNet.lib libHist.lib libGraf.lib libGraf3D.lib libGpad.lib libTree.lib libRint.lib libPostscript.lib libMatrix.lib libPhysics.lib libMathCore.lib libThread.lib

All the objects and libraries are in the same directory, which is the directory I'm executing the Batch file from, and also where the Batch file is located. I've tried adding the current directory to /LIBPATH:, but no luck. My LIB environment variable is

C:\Users\jroth\Data\online_monitor_v.0.5>echo %LIB%
"C:\Program Files\ (x86)\Microsoft Visual Studio 11.0\VC\LIB";"C:\Program Files
(x86)\Microsoft Visual Studio 11.0\VC\ATLMFC\LIB";"C:\Program Files (x86)\Window
s Kits\8.0\lib\win8\um\x86";

I made sure that everything was quoted. The same error came up when everything was unquoted. The error verbatim is

C:\Users\jroth\Data\online_monitor_v.0.5>make
Microsoft (R) Incremental Linker Version 11.00.50727.1
Copyright (C) Microsoft Corporation.  All rights reserved.

C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin\link
LINK : fatal error LNK1181: cannot open input file 'C:\Program.obj'

make.bat is the name of the batch file I'm using to link this, not a makefile.

I'm running vcvarsall.bat before doing any of this.

Upvotes: 1

Views: 4646

Answers (1)

Mr Lister
Mr Lister

Reputation: 46599

The problem was with the environment variable link that you used. The MS linker also uses this variable for flags.

From https://msdn.microsoft.com/en-us/library/6y6t9esh.aspx:

The LINK tool uses the following environment variables:

  • LINK, if defined. The LINK tool processes options and arguments defined in the LINK environment variable before processing the command line.

So you can't use set link=..., you'll have to use another name. _link will do fine.

Upvotes: 3

Related Questions