我正在嘗試爲我正在執行的項目創建一個共享對象(myLib.so)。並且我創建了一個單獨的eclipse「項目」來嘗試使用/測試共享對象 - 它們位於同一個工作區中。在Eclipse中的共享對象內使用boost lib - 未定義的參考
當我編譯共享對象(它使用boost庫線程等)的項目時,所有編譯文件,我沒有得到任何錯誤。
當我編譯測試程序,並嘗試鏈接它是指mylib.so我得到以下錯誤:
/path/lib.so: undefined reference to `boost::thread::interrupt()'
/path/lib.so: undefined reference to `vtable for boost::detail::thread_data_base'
/path/lib.so: undefined reference to `boost::detail::thread_data_base::~thread _data_base()'
/path/lib.so: undefined reference to `typeinfo for boost::detail::thread_data_base'
/path/lib.so: undefined reference to `boost::thread::start_thread()'
/path/lib.so: undefined reference to `boost::this_thread::sleep(boost::posix_time::ptime const&)'
我不確定我是否編譯myLib.so錯了,或者如果我有不正確的設置爲測試項目。正如我所說,當我分別編譯myLib.so時,一切看起來都很順利,但是當我編譯測試程序(出於某種原因重新編譯myLib.so)時,它似乎出錯了。
我在測試項目的編譯器中包含了myLib.so的源代碼,並且我在測試項目的鏈接庫中包含了myLib.so。
如果有人可以提供一些援助,將不勝感激。需要更多信息請詢問。
感謝,
額外的信息:爲lib.so
-include ../makefile.init
RM := rm -rf
# All of the sources participating in the build are defined here
-include *several-different-files*.mk mostly blank, LIB is blank
ifneq ($(MAKECMDGOALS),clean)
ifneq ($(strip $(C++_DEPS)),)
-include $(C++_DEPS)
endif
ifneq ($(strip $(C_DEPS)),)
-include $(C_DEPS)
endif
ifneq ($(strip $(CC_DEPS)),)
-include $(CC_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
# Add inputs and outputs from these tool invocations to the build variables
# All Target
all: libmyLIB.so
# Tool invocations
libmyLIB.so: $(OBJS) $(USER_OBJS)
@echo 'Building target: [email protected]'
@echo 'Invoking: GCC C++ Linker'
g++ -shared -o "libmyLIB.so" $(OBJS) $(USER_OBJS) $(LIBS)
@echo 'Finished building target: [email protected]'
@echo ' '
# Other Targets
clean:
-$(RM) $(OBJS)$(C++_DEPS)$(C_DEPS)$(CC_DEPS)$(LIBRARIES)$(CPP_DEPS)$(CXX_DEPS)$(C_UPPER_DEPS) libPS.so
[email protected] ' '
.PHONY: all clean dependents
.SECONDARY:
-include ../makefile.targets
的Makefile測試設置
-include ../makefile.init
RM := rm -rf
# All of the sources participating in the build are defined here
-include sources.mk
-include src/subdir.mk
-include subdir.mk
-include objects.mk
ifneq ($(MAKECMDGOALS),clean)
ifneq ($(strip $(C++_DEPS)),)
-include $(C++_DEPS)
endif
ifneq ($(strip $(C_DEPS)),)
-include $(C_DEPS)
endif
ifneq ($(strip $(CC_DEPS)),)
-include $(CC_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
# Add inputs and outputs from these tool invocations to the build variables
# All Target
all: TestingmyLIB
# Tool invocations
TestingmyLIB: $(OBJS) $(USER_OBJS)
@echo 'Building target: [email protected]'
@echo 'Invoking: Cross G++ Linker'
g++ -L"/PATH" -o TestingLIB$(OBJS) $(USER_OBJS) $(LIBS)
@echo 'Finished building target: [email protected]'
@echo ' '
# Other Targets
clean:
-$(RM) $(C++_DEPS)$(OBJS)$(C_DEPS)$(CC_DEPS)$(CPP_DEPS)$(EXECUTABLES)$(CXX_DEPS)$(C_UPPER_DEPS) TestingLIB
[email protected] ' '
.PHONY: all clean dependents
.SECONDARY:
-include ../makefile.targets
另外,MK的一個
Make文件的文件用於測試設置引用(objects.mk)的makefile包含LIBS:= -lmyLIB
你能告訴我們'$(LIBS)'的定義嗎?聽起來就像你在鏈接時忘了'-lboost_thread'。 – 2013-05-06 15:35:18
應該在編譯後的.so項目的LIBS列表中嗎? Atm列表是空白的,但它沒有它分開編譯?如果它需要在測試中會更有意義,但我似乎無法通過eclipse添加它 – Blue42 2013-05-06 15:58:54