次のディレクトリ構造があります。
├── build (empty dir)
├── CMakeLists.txt
├── easylogging++.h
├── help.h
├── operation.h
├── operation_list.h
├── operations
│ ├── CMakeLists.txt
│ ├── matchcount.cc
│ └── matchcount.h
└── ops_toolkit.cc
そして、私はCMakeが初めてで、CMakeLists.txtを書き込もうとしています。私の matchcount.h には、実装が matchcount.cc にある署名があります (典型的な C/C++ 構造として)。以下は、ベースディレクトリにある私の CMakeLists.txt です
cmake_minimum_required(VERSION 2.6)
project(ops_toolkit)
add_subdirectory(operations)
add_executable(ops_toolkit ops_toolkit.cc)
set(CMAKE_CXX_FLAGS "-std=c++0x")
以下は、操作ディレクトリのものです
include_directories(${ops_toolkit_SOURCE_DIR}/operations)
link_directories(${ops_toolkit_BINARY_DIR}/operations)
set(all_operations_HEADER operations/matchcount.h)
set(all_operations_SOURCES operations/matchcount.cc)
呼び出された関数シグネチャの未定義の参照を取得してint matchcount(int, const char**)
おり、次のように文句を言います
dev:~/work/ops_toolkit/build$ make
Scanning dependencies of target ops_toolkit
[100%] Building CXX object CMakeFiles/ops_toolkit.dir/ops_toolkit.cc.o
Linking CXX executable ops_toolkit
CMakeFiles/ops_toolkit.dir/ops_toolkit.cc.o: In function `__static_initialization_and_destruction_0(int, int)':
ops_toolkit.cc:(.text+0x249): undefined reference to `operations::matchcount(int, char const**)'
collect2: ld returned 1 exit status
make[2]: *** [ops_toolkit] Error 1
make[1]: *** [CMakeFiles/ops_toolkit.dir/all] Error 2
make: *** [all] Error 2
誰かがこれで私を助けることができますか? ありがとう