2010-12-18 10 views
4

私はメイクファイルからリンクしようとしない場合、私は次のエラーを取得:C:LINK.EXEはMakefileのから失敗しても、コマンドラインから

LINK : fatal error LNK1104: cannot open file 'LIBCMT.lib'. 

Makefileの実行:

C:\Users\snmcdonald\Desktop\winMake2\winMake2>nmake "_DEBUG=" /f win2.mk build 

Microsoft (R) Program Maintenance Utility Version 10.00.30319.01 
Copyright (C) Microsoft Corporation. All rights reserved. 

     cl /c /ZI /Fo"Debug\\" /Fe"Debug\\" main.c 
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.30319.01 for 80x86 
Copyright (C) Microsoft Corporation. All rights reserved. 

main.c 
     cl /c /ZI /Fo"Debug\\" /Fe"Debug\\" lib.c 
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.30319.01 for 80x86 
Copyright (C) Microsoft Corporation. All rights reserved. 

lib.c 
     lib Debug\lib.obj /out:Debug\lib.lib 
Microsoft (R) Library Manager Version 10.00.30319.01 
Copyright (C) Microsoft Corporation. All rights reserved. 

     link Debug\main.obj Debug\lib.lib /out:Debug\main.exe 
Microsoft (R) Incremental Linker Version 10.00.30319.01 
Copyright (C) Microsoft Corporation. All rights reserved. 

main.obj : warning LNK4075: ignoring '/EDITANDCONTINUE' due to '/OPT:ICF' specif 
ication 
LINK : fatal error LNK1104: cannot open file 'LIBCMT.lib' 
NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio 10.0\VC\BI 
N\link.EXE"' : return code '0x450' 
Stop. 

をしかし、私が失敗した同じ行とコンソールからのリンクを再実行すると、ビルドが成功します。私は、私のmakeファイルから生成された全く同じlibobjを使用しています。

コンソールの実行:

C:\Users\snmcdonald\Desktop\winMake2\winMake2>link Debug\main.obj Debug\lib.lib /o 
ut:Debug\main.exe 
Microsoft (R) Incremental Linker Version 10.00.30319.01 
Copyright (C) Microsoft Corporation. All rights reserved. 

main.obj : warning LNK4075: ignoring '/EDITANDCONTINUE' due to '/OPT:ICF' specif 
ication 

C:\Users\SHANEM~1\Desktop\winMake2\winMake2>debug\main.exe 
print from lib 

私は参照のための私のメイクファイルが含まれています。

私はそれが私のメイクに失敗するが、手動時に正常に実行する理由私は混乱しています両方のVisual Cバージョン9とバージョン10でこれをテストしている

Makefileの

!ifdef _DEBUG 
CC = cl 
CFLAGS = /c /ZI 
FILES = *.c 
OUT = /Fo"Debug\\" /Fe"Debug\\" 
LINKOUT = /out:Debug 
DIR = Debug 
!else 
CC = cl 
CFLAGS = /O2 
FILES = *.c 
OUT = /Fo"Release\\" /Fe"Release\\" 
LINKOUT = /out:Release 
DIR = Release 
!endif 

LIB = lib 
LINK = link 

RM = del 
RMFLAGS = *.ojb *.exe 2>NUL 

build: main.exe 

clean: 
    $(RM) $(RMFLAGS) 

rebuild: clean build 

main.exe: main.obj lib.lib 
    $(LINK) $(DIR)\main.obj $(DIR)\lib.lib $(LINKOUT)\main.exe 

lib.lib: lib.obj 
    $(LIB) $(DIR)\lib.obj $(LINKOUT)\lib.lib 

main.obj: 
    $(CC) $(CFLAGS) $(OUT) main.c 

lib.obj: 
    $(CC) $(CFLAGS) $(OUT) lib.c 

テストコマンドラインで入力します。

ソリューション:

nmake /E /f win2.mk build 

/Eは - 環境パスを持つマクロVARSを上書きします。

答えて

4

LIB = lib

。はい、/ Eはそれを修正しますが、実際にlib.exeが必要な次のプロジェクトは失敗するでしょう。別の名前を選択すると、win32.makは "implib"を使用します。

0

ファイルが に存在する必要があります... \マイクロソフトのVisual Studio 8 \ VC \これは、環境変数の設定の違い可能性があり

LIB。環境変数を手動でコマンドラインから実行する際には、環境変数の設定を確認してください。そのネジアップLIB環境変数を

http://us.generation-nt.com/answer/lnk1104-open-file-libcmt-lib-help-21575202.html

The LIB environment variable should contain the path to your various lib directories. You can also run the VCVARS32.BAT file, which will automatically set the environment up for you. If you do a lot of command line builds, I recommend creating a shortcut that invokes the above mentioned VSVARS32.BAT

+0

良い点がいくつかありましたが、私は運がありませんでした。私はmakefileの中でVCVARS32.BATを実行し、コンソールからVCVARS32BATを実行しようとしましたが、 "/ LIBPATH:" C:\ Program Files \ Microsoft Visual Studio 10.0 \ VC \ lib "をリンカオプションとして追加しようとしました。 –

+0

そのファイル –

+0

はい: "C:¥Program Files¥Microsoft Visual Studio 10.0¥Common7¥Tools¥vsvars32.bat"また、コンソールとはVisual Studio 2010のプロンプトを意味します。 –

関連する問題