0

私が行っているプロジェクトの共有オブジェクト (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 の Make ファイル

-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

また、テスト セットアップの makefile が参照する mk ファイルの 1 つ (objects.mk) には、LIBS := -lmyLIB が含まれています。

4

1 に答える 1

0

この種のエラー メッセージ (vtable に関連) は、仮想メソッドが実装されていない状態で projecr をコンパイルするときによく発生します。

すべての仮想メソッドを探して、すべてのサブクラスにその実装があるかどうかを確認してください。

このリンクは、解決済みの同様の質問です。

于 2013-05-06T12:52:25.820 に答える