8
首先,我看了一下this的帖子,找不到解決我的問題的方法。我試圖用兩個頭文件和鏈接與我的主要程序建立一個庫文件夾中,我的文件夾中容器它包括:CMake無法確定目標的鏈接器語言
linkedStack.h
linkedQueue.h
中的CMakeLists.txt在我的容器文件夾是
add_library(container linkedQueue.h linkedStack.h)
install (TARGETS container DESTINATION bin)
install (FILES linkedQueue.h linkedStack.h DESTINATION include)
,而我在源目錄中的CMakeLists.txt是:
cmake_minimum_required(VERSION 2.6)
project(wordLadder)
# set version number
set (MAJOR 1)
set (MINOR 0)
# configure header file to be placed in binary
configure_file(
"${PROJECT_SOURCE_DIR}/ladderConfig.h.in"
"${PROJECT_BINARY_DIR}/ladderConfig.h"
)
# add binary tree to search path for include files
# so we can find config
include_directories("${PROJECT_BINARY_DIR}")
#add container library
include_directories ("${PROJECT_SOURCE_DIR}/container")
add_subdirectory(container)
#add executable
add_executable(wordLadder ladderMain.cpp)
target_link_libraries (wordLadder container)
install (TARGETS wordLadder DESTINATION bin)
install (FILES "${PROJECT_BINARY_DIR}/ladderConfig.h"
DESTINATION include)
和錯誤,我得到:
CMake Error: Cannot determine link language for target "container".
CMake Error: CMake can not determine linker language for target:container
-- Generating done
-- Build files have been written to: /home/gmercer/Linux_dev/wordLadder/build
我不知道我在做什麼錯在這裏,但我認爲這是與我的圖書館CMake的文件。
我應該如何去鏈接頭文件?他們都是模板類,所以不包含.cpp文件 –
@ Need4Sleep你已經添加了'include_directories(「$ {PROJECT_SOURCE_DIR}/container」)'這樣編譯器即使沒有特殊的'容器'libarry也能找到你的頭文件。你不需要'容器'。 –
我明白了,謝謝! –