主题:一个关于C++的问题
大家好,我想将一个linux版本的C++程序改成windows版本,用VS 2008 调试后,有一堆链接错误,我不太熟悉VS 2008,如下:
FeatureExtractor.obj : error LNK2005: "double __cdecl log2(double)" (?log2@@YANN@Z) already defined in ExtraTreeClassifier.obj
1>frimcla.obj : error LNK2005: "double __cdecl log2(double)" (?log2@@YANN@Z) already defined in ExtraTreeClassifier.obj
1>LINK : warning LNK4067: ambiguous entry point; selected 'mainCRTStartup'
1>MaskImage.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall Magick::Image::~Image(void)" (__imp_??1Image@Magick@@UAE@XZ)
1>ExtraTreeClassifier.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall Magick::Image::~Image(void)" (__imp_??1Image@Magick@@UAE@XZ) referenced in function "void __cdecl printDecisionPatterns(class std::list<class TerminalNode *,class std::allocator<class TerminalNode *> > *)" (?printDecisionPatterns@@YAXPAV?$list@PAVTerminalNode@@V?$allocator@PAVTerminalNode@@@std@@@std@@@Z)
1>FeatureExtractor.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall Magick::Image::~Image(void)" (__imp_??1Image@Magick@@UAE@XZ)
1>frimcla.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall Magick::Image::~Image(void)" (__imp_??1Image@Magick@@UAE@XZ)
我不知道这是为什么,请高手解答,谢谢。以下是我的makeefile:
MAGICKCONFIG=Magick++-config
MAGICKCPPFLAGS=-DIMAGEMAGICK `$(MAGICKCONFIG) --cppflags`
MAGICKLDFLAGS=`$(MAGICKCONFIG) --ldflags --libs` -ldl
INCLUDE=-I./SIFT -I./libsvm
#CPPFLAGS=$(MAGICKCPPFLAGS) $(INCLUDE) -o3 -Wall
CPPFLAGS=$(MAGICKCPPFLAGS) $(INCLUDE) -g -Wall -O3
LDFLAGS=$(MAGICKLDFLAGS) #-lpthread -L../progs/Duma -lduma
CFLAGS=-W -Wall -g -O3
#CFLAGS=-W -Wall -g #-pg
# uncomment the below if you have SIFT sources
# CFLAGS += -DHAVE_SIFT
# SIFT_SRC= SIFT/ParametersManager.c \
# SIFT/Matrix.c \
# SIFT/PgmIo.c \
# SIFT/Convolution.c \
# SIFT/BilinearInterpolation.c \
# SIFT/ResizeImage.c \
# SIFT/ImagePyramid.c \
# SIFT/Filter.c \
# SIFT/Detector.c \
# SIFT/InterestPoint.c \
# SIFT/Normalizer.c \
# SIFT/Sift.c
# SIFT_OBJ= $(SIFT_SRC:.c=.o)
FRIMCLA_SRC= ClassLabelHistogram.cpp \
DecisionNode.cpp \
ExtraTreeClassifier.cpp \
FeatureExtractor.cpp \
FeatureVector.cpp \
FMUtils.cpp \
frimcla.cpp \
IntegralImage.cpp \
MaskImage.cpp \
PDF.cpp \
SvmClassifier.cpp \
libsvm/svm.cpp \
TerminalNode.cpp
FRIMCLA_OBJ= $(FRIMCLA_SRC:.cpp=.o)
all:frimcla
frimcla: $(FRIMCLA_OBJ) $(SIFT_OBJ)
g++ $(LDFLAGS) $(FRIMCLA_OBJ) $(SIFT_OBJ) -lm -o frimcla
frimcla.o: frimclaUtils.cpp frimclaUtils2.cpp
test:test.o FMUtils.o FeatureVector.o SvmClassifier.o ClassLabelHistogram.o libsvm/svm.o
libsvm/svm.o:libsvm/svm.cpp
ClassLabelHistogram.o:ClassLabelHistogram.cpp
FeatureVector.o:FeatureVector.cpp
SvmClassifier.o:SvmClassifier.cpp
test.o:test.cpp
FMUtils.o:FMUtils.cpp
.SUFFIXES: .cpp .o
.cpp.o:
g++ -c $(INCLUDE) $(CPPFLAGS) -o $@ $<
.c.o:
g++ -c $(INCLUDE) $(CFLAGS) -o $@ $<
clean:
-rm -f *.o *~ frimcla
-rm -f libsvm/*.o libsvm/*~
-rm -f SIFT/*.o SIFT/*~
FeatureExtractor.obj : error LNK2005: "double __cdecl log2(double)" (?log2@@YANN@Z) already defined in ExtraTreeClassifier.obj
1>frimcla.obj : error LNK2005: "double __cdecl log2(double)" (?log2@@YANN@Z) already defined in ExtraTreeClassifier.obj
1>LINK : warning LNK4067: ambiguous entry point; selected 'mainCRTStartup'
1>MaskImage.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall Magick::Image::~Image(void)" (__imp_??1Image@Magick@@UAE@XZ)
1>ExtraTreeClassifier.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall Magick::Image::~Image(void)" (__imp_??1Image@Magick@@UAE@XZ) referenced in function "void __cdecl printDecisionPatterns(class std::list<class TerminalNode *,class std::allocator<class TerminalNode *> > *)" (?printDecisionPatterns@@YAXPAV?$list@PAVTerminalNode@@V?$allocator@PAVTerminalNode@@@std@@@std@@@Z)
1>FeatureExtractor.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall Magick::Image::~Image(void)" (__imp_??1Image@Magick@@UAE@XZ)
1>frimcla.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall Magick::Image::~Image(void)" (__imp_??1Image@Magick@@UAE@XZ)
我不知道这是为什么,请高手解答,谢谢。以下是我的makeefile:
MAGICKCONFIG=Magick++-config
MAGICKCPPFLAGS=-DIMAGEMAGICK `$(MAGICKCONFIG) --cppflags`
MAGICKLDFLAGS=`$(MAGICKCONFIG) --ldflags --libs` -ldl
INCLUDE=-I./SIFT -I./libsvm
#CPPFLAGS=$(MAGICKCPPFLAGS) $(INCLUDE) -o3 -Wall
CPPFLAGS=$(MAGICKCPPFLAGS) $(INCLUDE) -g -Wall -O3
LDFLAGS=$(MAGICKLDFLAGS) #-lpthread -L../progs/Duma -lduma
CFLAGS=-W -Wall -g -O3
#CFLAGS=-W -Wall -g #-pg
# uncomment the below if you have SIFT sources
# CFLAGS += -DHAVE_SIFT
# SIFT_SRC= SIFT/ParametersManager.c \
# SIFT/Matrix.c \
# SIFT/PgmIo.c \
# SIFT/Convolution.c \
# SIFT/BilinearInterpolation.c \
# SIFT/ResizeImage.c \
# SIFT/ImagePyramid.c \
# SIFT/Filter.c \
# SIFT/Detector.c \
# SIFT/InterestPoint.c \
# SIFT/Normalizer.c \
# SIFT/Sift.c
# SIFT_OBJ= $(SIFT_SRC:.c=.o)
FRIMCLA_SRC= ClassLabelHistogram.cpp \
DecisionNode.cpp \
ExtraTreeClassifier.cpp \
FeatureExtractor.cpp \
FeatureVector.cpp \
FMUtils.cpp \
frimcla.cpp \
IntegralImage.cpp \
MaskImage.cpp \
PDF.cpp \
SvmClassifier.cpp \
libsvm/svm.cpp \
TerminalNode.cpp
FRIMCLA_OBJ= $(FRIMCLA_SRC:.cpp=.o)
all:frimcla
frimcla: $(FRIMCLA_OBJ) $(SIFT_OBJ)
g++ $(LDFLAGS) $(FRIMCLA_OBJ) $(SIFT_OBJ) -lm -o frimcla
frimcla.o: frimclaUtils.cpp frimclaUtils2.cpp
test:test.o FMUtils.o FeatureVector.o SvmClassifier.o ClassLabelHistogram.o libsvm/svm.o
libsvm/svm.o:libsvm/svm.cpp
ClassLabelHistogram.o:ClassLabelHistogram.cpp
FeatureVector.o:FeatureVector.cpp
SvmClassifier.o:SvmClassifier.cpp
test.o:test.cpp
FMUtils.o:FMUtils.cpp
.SUFFIXES: .cpp .o
.cpp.o:
g++ -c $(INCLUDE) $(CPPFLAGS) -o $@ $<
.c.o:
g++ -c $(INCLUDE) $(CFLAGS) -o $@ $<
clean:
-rm -f *.o *~ frimcla
-rm -f libsvm/*.o libsvm/*~
-rm -f SIFT/*.o SIFT/*~