連結器工具錯誤 LNK1181Linker Tools Error LNK1181

無法開啟輸入檔 ' filename 'cannot open input file 'filename'

找不到連結器,因此找不到連結器, filename 或找不到路徑。The linker could not find filename because it does not exist or the path was not found.

錯誤 LNK1181 的一些常見原因包括:Some common causes for error LNK1181 include:

  • filename 參考為連結器行上的其他相依性,但該檔案不存在。filename is referenced as an additional dependency on the linker line, but the file does not exist.

  • /LIBPATH 語句,指定遺漏包含的目錄 filenameA /LIBPATH statement that specifies the directory containing filename is missing.

若要解決上述問題,請確定連結器行所參考的任何檔案都存在於系統上。To resolve the above issues, ensure any files referenced on the linker line are present on the system. 此外,請確定每個目錄都有一個 /LIBPATH 語句,內含連結器相依的檔案。Also ensure there is a /LIBPATH statement for each directory containing a linker-dependent file.

如需詳細資訊,請參閱 .lib 檔作為連結器輸入For more information, see .lib Files as Linker Input.

LNK1181 的另一個可能原因是,含有內嵌空格的長檔名未以引號括住。Another possible cause for LNK1181 is that a long file name with embedded spaces was not enclosed in quotation marks. 在這種情況下,連結器只會辨識最多一個空格的檔案名,然後假設副檔名為 .obj。 這種情況的解決方法是用引號括住長檔名 (路徑加上檔案名) 。In that case, the linker will only recognize a file name up to the first space, and then assume a file extension of .obj. The solution to this situation is to enclose the long file name (path plus file name) in quotation marks.

使用 /p ( 前置處理至檔案) 選項,可能會導致 LNK1181,因為該選項會隱藏 .obj 檔案的建立。Compiling with the /P (Preprocess to a File) option can result in LNK1181 because that option suppresses the creation of .obj files.

請參閱See also

/LIBPATH (其他 Libpath) /LIBPATH (Additional Libpath)