2016-10-11 4 views
0

Eclipse에서 자동으로 생성 한 makefile에서 수동 makefile로 마이그레이션 중이며 Eclipse에서는 작동하지만 광산에서는 작동하지 않습니다. 컴파일러 출력은'testing :: UnitTest :: GetInstance()'에 대한 정의되지 않은 참조

입니다.
13:54:30 **** Incremental Build of configuration Debug for project MY_PROJECT **** 
make -f ../build/makefile all 
Building file: ../src/TestLauncher.cpp 
g++ -std=c++11 -I"../src" -I"../src/Common" -I"../src/Common/COMPUTATION" -I"../src/Common/DATA_ACQUISITION" -I"/usr/include/mysql" -I"/usr/include/gtest" -O0 -g3 -pg -Wall -Wextra -fmessage-length=0 --coverage -fPIC -MMD -MP -MF"../bin/objs/TestLauncher.d" -MT"../bin/objs/TestLauncher.o" -o "../bin/objs/TestLauncher.o" "../src/TestLauncher.cpp" 
/tmp/ccrDQ0Bm.o: In function `main': 
/home/user/workspace/MY_PROJECT/build/../src/TestLauncher.cpp:13: undefined reference to `testing::InitGoogleTest(int*, char**)' 
../build/makefile:165: recipe for target '../bin/objs/TestLauncher.o' failed 
/tmp/ccrDQ0Bm.o: In function `RUN_ALL_TESTS()': 
/usr/include/gtest/gtest.h:2288: undefined reference to `testing::UnitTest::GetInstance()' 
/usr/include/gtest/gtest.h:2288: undefined reference to `testing::UnitTest::Run()' 
collect2: error: ld returned 1 exit status 
make: *** [../bin/objs/TestLauncher.o] Error 1 

13:54:31 Build Finished (took 989ms) 

는이 오류에 대해보고하고 항상 링커 플래그 중 -lgtest를 사용되지 않는 관련이있을 것 같다. 내가하지만, 어쨌든이 오류는 링커에서하지만 컴파일 단계에서 발생되지 않는다. 따라서, 이 문제가 발생하는 이유를 이해할 수 없습니다.

라이브러리도 있습니다.이 파일은 /usr/lib/입니다. : 내가 말했듯이, 이클립스의 makefile에서 작동한다.

-include ../makefile.init 

RM := rm -rf 

EXECUTABLE_NAME := MY_PROJECT 

FLAGS := -O0 -g3 -pg -Wall -Wextra -fmessage-length=0 --coverage -fPIC#-v 

C++_DEPS := 
C_DEPS := 
CC_DEPS := 
CPP_DEPS := 
CXX_DEPS := 
C_UPPER_DEPS := 

EXECUTABLES := ../bin/$(EXECUTABLE_NAME) 

LIBS_SERVER := -ldl -lpthread -lgtest -lboost_date_time -lmysqlclient -lboost_filesystem -lboost_system 
INCLUDES_LIB_SERVER := -L /usr/lib/mysql -L /usr/lib/boost 


CPP_SRCS += \ 
../src/TestLauncher.cpp \ 
../src/Common/DATA_ACQUISITION/DATA_ACQUISITION_test.cpp 

OBJS += \ 
../bin/objs/TestLauncher.o \ 
../bin/objs/DATA_ACQUISITION_test.o 

CPP_DEPS += \ 
../bin/objs/TestLauncher.d \ 
../bin/objs/DATA_ACQUISITION_test.d 


INCLUDES_SERVER += \ 
-I"../src" \ 
-I"../src/Common" \ 
-I"../src/Common/COMPUTATION" \ 
-I"../src/Common/DATA_ACQUISITION" \ 
-I"/usr/include/mysql" \ 
-I"/usr/include/gtest" 


ifneq ($(MAKECMDGOALS),clean) 
ifneq ($(strip $(C++_DEPS)),) 
-include $(C++_DEPS) 
endif 
ifneq ($(strip $(CC_DEPS)),) 
-include $(CC_DEPS) 
endif 
ifneq ($(strip $(C_DEPS)),) 
-include $(C_DEPS) 
endif 
ifneq ($(strip $(CPP_DEPS)),) 
-include $(CPP_DEPS) 
endif 
ifneq ($(strip $(CXX_DEPS)),) 
-include $(CXX_DEPS) 
endif 
ifneq ($(strip $(C_UPPER_DEPS)),) 
-include $(C_UPPER_DEPS) 
endif 
endif 

-include ../makefile.defs 


############################################################################### 
# TARGETS 
############################################################################### 


# All Target 
all: $(EXECUTABLES) 

test: FLAG=-DTEST 
test: all 

../bin/$(EXECUTABLE_NAME): $(OBJS) 
    @echo 'Building target: [email protected]' 
    @echo 'Invoking: Cygwin C++ Linker' 
    g++ $(FLAGS) -o"../bin/$(EXECUTABLE_NAME)" $(OBJS) $(INCLUDES_LIB_SERVER) $(LIBS_SERVER) 
    @echo 'Finished building target: [email protected]' 
    @echo ' ' 


# Other Targets 
clean: 
    -$(RM) $(OBJS) $(OBJS_RT) $(C++_DEPS) $(EXECUTABLES)$(CC_DEPS)$(C_DEPS)$(CPP_DEPS)$(CXX_DEPS)$(C_UPPER_DEPS) ../bin/MY_PROJECT 
    [email protected] ' ' 

.PHONY: all clean dependents 
.SECONDARY: 

############################################################################### 
# COMPILE --> OBJS 
############################################################################### 

../bin/objs/%.o: ../src/%.cpp 
    @echo 'Building file: $<' 
    g++ -std=c++11 $(INCLUDES_SERVER) $(FLAGS) -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@)" -o "[email protected]" "$<" 
    @echo 'Finished building: $<' 
    @echo ' ' 


../bin/objs/%.o: ../src/Common/%.cpp 
    @echo 'Building file: $<' 
    g++ -std=c++11 $(INCLUDES_SERVER) $(FLAGS) -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@)" -o "[email protected]" "$<" 
    @echo 'Finished building: $<' 
    @echo ' ' 


../bin/objs/%.o: ../src/Common/COMPUTATION/%.cpp 
    @echo 'Building file: $<' 
    g++ -std=c++11 $(INCLUDES_SERVER) $(FLAGS) -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@)" -o "[email protected]" "$<" 
    @echo 'Finished building: $<' 
    @echo ' ' 


../bin/objs/%.o: ../src/Common/DATA_ACQUISITION/%.cpp 
    @echo 'Building file: $<' 
    g++ -std=c++11 $(INCLUDES_SERVER) $(FLAGS) -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@)" -o "[email protected]" "$<" 
    @echo 'Finished building: $<' 
    @echo ' ' 

무엇이 잘못 어떤 생각 :

이 내 메이크입니까?

답변

0

-l 플래그의 순서는 매우 중요합니다. -lgtest가 올바른 위치에 있는지 확인합니까?

또한 링커에서는 gtest뿐 아니라 -lgtest에 대한 libgtest.so 파일이 필요합니다.

희망이있었습니다.

+0

물론 잘못된 것일 수도 있지만, IMO는 링커가 실행되지 않아 적용되지 않습니다. 컴파일 단계에서 오류가 발생하고 -l 플래그가 사용되지 않습니다. –