我正在尝试为我正在做的项目创建一个共享对象(myLib.so)。我创建了一个单独的eclipse'项目'来尝试使用/测试共享对象 - 它们位于同一个工作区中。
当我为共享对象(使用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: $@'
@echo 'Invoking: GCC C++ Linker'
g++ -shared -o "libmyLIB.so" $(OBJS) $(USER_OBJS) $(LIBS)
@echo 'Finished building target: $@'
@echo ' '
# Other Targets
clean:
-$(RM) $(OBJS)$(C++_DEPS)$(C_DEPS)$(CC_DEPS)$(LIBRARIES)$(CPP_DEPS)$(CXX_DEPS)$(C_UPPER_DEPS) libPS.so
-@echo ' '
.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: $@'
@echo 'Invoking: Cross G++ Linker'
g++ -L"/PATH" -o TestingLIB$(OBJS) $(USER_OBJS) $(LIBS)
@echo 'Finished building target: $@'
@echo ' '
# Other Targets
clean:
-$(RM) $(C++_DEPS)$(OBJS)$(C_DEPS)$(CC_DEPS)$(CPP_DEPS)$(EXECUTABLES)$(CXX_DEPS)$(C_UPPER_DEPS) TestingLIB
-@echo ' '
.PHONY: all clean dependents
.SECONDARY:
-include ../makefile.targets
另外一个mk文件,测试设置引用的makefile(objects.mk)包含LIBS:= -lmyLIB
答案 0 :(得分:0)