Cl编译器生成带有obj标志的exe

时间:2015-05-13 17:05:34

标签: c++ makefile

我在使用CL编译器编译目标文件时遇到问题。我有一个Makefile,其规则如下:

TRANSITION_H = include\lists\transition.h
TRANSITION_CPP = include\lists\transition.cpp
TRANSITION_O = include\lists\transition.obj
TRANSITION_OP = '.\include\lists\'

CPPCOMPILER = cl
TO_OBJ = /Fo

$(TRANSITION_O) : $(TRANSITION_CPP) $(TRANSITION_H)
    $(CPPCOMPILER) $(TO_OBJ)$(TRANSITION_OP) $(TRANSITION_CPP)

statistics: $(STATS)

$(STATS): $(TRANSITION_O)

当我运行make statistics时,我得到了

/out:transitionList.exe
.\include\lists\transitionList.obj
LINK : fatal error LNK1561: entry point must be defined
make: *** [include\lists\transitionList.obj] Error 2

所以,它以某种方式生成exe文件......但是它再次不是。因为它在正确的目录中生成.obj文件,但是说/ out:.exe

有人可以向我解释这里出了什么问题吗?

修改

整个makefile:

########################################################################
# variables
########################################################################

LIST_H = include\lists\list.h
LIST_CPP = include\lists\list.cpp
LIST_O = include\lists\list.obj
LIST_OP = '.\include\lists\'

TRANSITION_H = include\lists\transition.h
TRANSITION_CPP = include\lists\transition.cpp
TRANSITION_O = include\lists\transition.obj
TRANSITION_OP = '.\include\lists\'

TRANSITION_LIST_H = include\lists\transitionList.h
TRANSITION_LIST_CPP = include\lists\transitionList.cpp
TRANSITION_LIST_O = include\lists\transitionList.obj
TRANSITION_LIST_OP = '.\include\lists\'

STRING_LIST_H = include\lists\stringList.h
STRING_LIST_CPP = include\lists\stringList.cpp
STRING_LIST_O = 'include\lists\stringList.obj
STRING_LIST_OP = '.\include\lists\'

ELEMENT_H = include\lists\element.h
ELEMENT_CPP = include\lists\element.cpp
ELEMENT_O = include\lists\element.obj
ELEMENT_OP = '.\include\lists\'

TEST_CPP = include\lists\test.cpp
TEST_BIN = test.exe

AUXILS_H = include\auxils.h
AUXILS_CPP = include\auxils.cpp
AUXILS_O = include\auxils.obj
AUXILS_P = '.\include\'

TRIE_H = include\trie\trie.h
TRIE_CPP = include\trie\trie.cpp
TRIE_O = include\trie\trie.obj
TRIE_OP = '.\include\trie\'

HMM_H = include\hmm\hmm.h
HMM_O = include\hmm\hmm.obj
HMM_OP = '.\include\hmm\'

TRELLIS_H = include\hmm\trellis.h
TRELLIS_O = include\hmm\trellis.obj
TRELLIS_OP = '.\include\hmm\'

TRAINER_H = include\trainer\trainer.h
TRAINER_O = include\trainer\trainer.obj
TRAINER_OP = '.\include\trainer\'

CPPCOMPILER = cl
TO_OBJ = /Fo

# doxygen-file
DOC_INDEX = doc\html'.\index.html

# corpus file
corpus = '.'.\data\tiger.txt'
# comment tag
tag = \#
in = 'data\testfile.txt'

STATS = data\HMM\all_trans.dat


########################################################################
# targets
########################################################################


$(TRANSITION_O) : $(TRANSITION_CPP) $(TRANSITION_H)
    $(CPPCOMPILER) $(TO_OBJ)$(TRANSITION_OP) $(TRANSITION_CPP)

$(TRANSITION_LIST_O) : $(TRANSITION_LIST_CPP) $(TRANSITION_LIST_H)
    $(CPPCOMPILER) $(TO_OBJ)$(TRANSITION_LIST_OP) $(TRANSITION_LIST_CPP)

$(STRING_LIST_O) : $(STRING_LIST_CPP) $(STRING_LIST_H) $(LIST_O) \
    $(ELEMENT_O)
    $(CPPCOMPILER) $(TO_OBJ)$(STRING_LIST_OP) $(STRING_LIST_CPP)

$(AUXILS_O) : $(AUXILS_CPP) $(AUXILS_H)
    $(CPPCOMPILER) $(TO_OBJ)$(AUXILS_OP) $(AUXILS_CPP)

$(ELEMENT_O) : $(ELEMENT_CPP) $(ELEMENT_H)
    $(CPPCOMPILER) $(TO_OBJ)$(ELEMENT_OP) $(ELEMENT_CPP)

$(LIST_O) : $(LIST_CPP) $(LIST_H)
    $(CPPCOMPILER) $(TO_OBJ)$(LIST_OP) $(LIST_CPP)

$(TRIE_O) : $(TRIE_CPP) $(TRIE_H)
    $(CPPCOMPILER) $(TO_OBJ)$(TRIE_OP) $(TRIE_CPP)

$(HMM_O) : $(HMM_H) $(TRELLIS_H)
    $(CPPCOMPILER) $(TO_OBJ)$(HMM_OP) $(HMM_H)

# make documentation
documentation: $(DOC_INDEX)

$(DOC_INDEX):
    doxygen doc\hmm.doxygen
    mv html doc

clean:
    rm -rf doc\html
    rm -rf doc\latex
    find . -name '*.obj' -delete
    find . -name '*.exe' -delete
    find . -name '*.gch' -delete
    find . -name '*.out' -delete
    find . -name '*.png' -delete
    find . -name '*.dat' -delete

# gathers statistics from corpus file to train HMM on. Requires
# one token-tag-tuple per line. call format:
# 'make statistics corpus=<corpus file> tag=<comment tag char>'
statistics: $(STATS)

$(STATS): $(TRANSITION_O) $(TRANSITION_LIST_O) $(AUXILS_O) $(LIST_O) \
    $(ELEMENT_O) $(TRIE_O) $(STRING_LIST_O)

    $(CPPCOMPILER) \src\train.cpp $(TRANSITION_O) \
    $(TRANSITION_LIST_O) $(AUXILS_O) $(LIST_O) $(ELEMENT_O) $(TRIE_O) \
    $(STRING_LIST_O)
    mv train.exe \bin\train.exe
    cd bin; train.exe $(corpus) '$(tag)'

# taggs sentences in input file. Requires a sentence to occupy a line
# all by itself; call format: 'make test in=<file>'
test: $(TRANSITION_O) $(TRANSITION_LIST_O) $(AUXILS_O) $(LIST_O) \
    $(ELEMENT_O) $(TRIE_O) $(STRING_LIST_O) $(STATS) $(HMM_O)

    $(CPPCOMPILER) \src\hmm_test.cpp $(TRANSITION_O) \
    $(TRANSITION_LIST_O) $(AUXILS_O) $(LIST_O) $(ELEMENT_O) $(TRIE_O) \
    $(STRING_LIST_O)
    mv hmm_test.exe \bin\hmm_test.exe
    cd bin; hmm_test.exe .'.\$(in)

整个错误:

C:\<path>>make test
cl /Fo'.\include\lists\' include\lists\transition.cpp
Microsoft (R) C/C++ Optimizing Compiler Version 18.00.31101 for x86
Copyright (C) Microsoft Corporation.  All rights reserved.

transition.cpp
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE\xlocale(337) : warning C4530: C++ exception handler used, but unwind semantics are not
enabled. Specify /EHsc
Microsoft (R) Incremental Linker Version 12.00.31101.0
Copyright (C) Microsoft Corporation.  All rights reserved.

/out:transition.exe
.\include\lists\transition.obj
LINK : fatal error LNK1561: entry point must be defined
make: *** [include\lists\transition.obj] Error 2

0 个答案:

没有答案