没有规则使目标'/usr/lib/x86_64-linux-gnu/libboost_filesystem.so`
No rule to make target '/usr/lib/x86_64-linux-gnu/libboost_filesystem.so`
我有 a project 我正在处理,但在尝试添加一些增强功能后我无法让 cmake 工作。我输入
cd build/manual/
cmake ../..
make && make install
我收到以下错误:
taylor@taylor-XPS-13-9365:~/markets/build/manual$ make && make install
Scanning dependencies of target markets
[ 3%] Building CXX object src/markets/CMakeFiles/markets.dir/data_handlers.cpp.o
[ 7%] Building CXX object src/markets/CMakeFiles/markets.dir/data_readers.cpp.o
[ 11%] Building CXX object src/markets/CMakeFiles/markets.dir/execution_handler.cpp.o
[ 14%] Building CXX object src/markets/CMakeFiles/markets.dir/fill.cpp.o
[ 18%] Building CXX object src/markets/CMakeFiles/markets.dir/instrument.cpp.o
[ 22%] Building CXX object src/markets/CMakeFiles/markets.dir/market_bar.cpp.o
[ 25%] Building CXX object src/markets/CMakeFiles/markets.dir/market_snapshot.cpp.o
[ 29%] Building CXX object src/markets/CMakeFiles/markets.dir/order.cpp.o
[ 33%] Building CXX object src/markets/CMakeFiles/markets.dir/pnl_calculator.cpp.o
[ 37%] Building CXX object src/markets/CMakeFiles/markets.dir/portfolio.cpp.o
[ 40%] Building CXX object src/markets/CMakeFiles/markets.dir/position_summary.cpp.o
[ 44%] Linking CXX static library libmarkets.a
[ 44%] Built target markets
Scanning dependencies of target run_backtest
[ 48%] Building CXX object src/CMakeFiles/run_backtest.dir/main.cpp.o
make[2]: *** No rule to make target '/usr/lib/x86_64-linux-gnu/libboost_filesystem.so,', needed by 'src/run_backtest'. Stop.
CMakeFiles/Makefile2:87: recipe for target 'src/CMakeFiles/run_backtest.dir/all' failed
make[1]: *** [src/CMakeFiles/run_backtest.dir/all] Error 2
Makefile:129: recipe for target 'all' failed
make: *** [all] Error 2
这个项目有几个 CMakeLists.txt
文件,因为有 1.) 一个主要的可执行文件 markets/src/main.cpp
,2.) 一个静态库,以及 3.) markets/test/
中的一些单元测试.
首先是 markets/CMakeLists.txt
:
cmake_minimum_required(VERSION 3.10)
set(CMAKE_CXX_STANDARD 11 ) # used to be 17
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3")
#set(CMAKE_CXX_COMPILER /usr/bin/g++-8) # this is now set externally!
set(CMAKE_INSTALL_PREFIX ${PROJECT_SOURCE_DIR})
set(MARKETS_INSTALL_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/include)
set(MARKETS_INSTALL_BIN_DIR ${PROJECT_SOURCE_DIR}/bin)
set(MARKETS_INSTALL_LIB_DIR ${PROJECT_SOURCE_DIR}/lib)
set(MARKETS_HEADERS_DIR ${PROJECT_SOURCE_DIR}/src/markets)
include_directories(${MARKETS_INSTALL_INCLUDE_DIR})
include_directories(${MARKETS_HEADERS_DIR})
add_subdirectory(src)
add_subdirectory(test)
然后是markets/src/CMakeLists.txt
(我认为这是有问题的那个)
cmake_minimum_required(VERSION 3.10)
project(run_backtest)
add_subdirectory(markets)
set(SOURCE_FILES main.cpp)
find_package (Eigen3 3.3 REQUIRED NO_MODULE)
find_library(mysqlcppconn 1.1.12 REQUIRED)
find_package(Boost 1.65.1 REQUIRED COMPONENTS system filesystem)
include_directories(${Boost_INCLUDE_DIRS})
add_executable(run_backtest ${SOURCE_FILES})
target_link_libraries(run_backtest markets Eigen3::Eigen mysqlcppconn ${Boost_LIBRARIES})
install(TARGETS run_backtest DESTINATION ${MARKETS_INSTALL_BIN_DIR})
然后是markets/src/markets/CMakeLists.txt
cmake_minimum_required(VERSION 3.10)
project(markets)### C CXX)
set(SOURCE_FILES
data_handlers.h
data_handlers.cpp
data_readers.h
data_readers.cpp
execution_handler.h
execution_handler.cpp
fill.h
fill.cpp
instrument.h
instrument.cpp
market_bar.h
market_bar.cpp
market_snapshot.h
market_snapshot.cpp
order.h
order.cpp
pnl_calculator.h
pnl_calculator.cpp
portfolio.h
portfolio.cpp
position_summary.h
position_summary.cpp
)
#set(Boost_USE_STATIC_LIBS OFF)
#set(Boost_USE_MULTITHREADED ON) # maybe off?
#set(Boost_USE_STATIC_RUNTIME OFF)
find_package(Boost 1.65.1 REQUIRED COMPONENTS system filesystem)
find_package (Eigen3 3.3 REQUIRED NO_MODULE)
find_library(mysqlcppconn 1.1.12 REQUIRED)
include_directories(${Boost_INCLUDE_DIRS})
link_directories( ${Boost_LIBRARY_DIRS})
add_library(markets SHARED STATIC ${SOURCE_FILES})
target_link_libraries(markets Eigen3::Eigen mysqlcppconn, ${Boost_LIBRARIES})
# not sure if i need this
target_link_libraries( markets ${Boost_FILESYSTEM_LIBRARY}, ${Boost_SYSTEM_LIBRARY})
install(TARGETS markets DESTINATION ${MARKETS_INSTALL_LIB_DIR})
我很确定它抱怨的这个文件存在,所以我不确定该怎么做:
taylor@taylor-XPS-13-9365:~$ stat /usr/lib/x86_64-linux-gnu/libboost_filesystem.so
File: /usr/lib/x86_64-linux-gnu/libboost_filesystem.so -> libboost_filesystem.so.1.65.1
Size: 29 Blocks: 0 IO Block: 4096 symbolic link
Device: 10302h/66306d Inode: 17184887 Links: 1
Access: (0777/lrwxrwxrwx) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2019-09-24 11:11:06.384111528 -0400
Modify: 2018-03-06 05:21:23.000000000 -0500
Change: 2019-09-24 11:10:45.160636771 -0400
Birth: -
您的问题是由文件名后面的逗号 ('/usr/lib/x86_64-linux-gnu/libboost_filesystem.so,'
) 引起的。
您应该删除 CMake 函数调用中的逗号分隔参数(只需在它们之间留一些空格)。
我有 a project 我正在处理,但在尝试添加一些增强功能后我无法让 cmake 工作。我输入
cd build/manual/
cmake ../..
make && make install
我收到以下错误:
taylor@taylor-XPS-13-9365:~/markets/build/manual$ make && make install
Scanning dependencies of target markets
[ 3%] Building CXX object src/markets/CMakeFiles/markets.dir/data_handlers.cpp.o
[ 7%] Building CXX object src/markets/CMakeFiles/markets.dir/data_readers.cpp.o
[ 11%] Building CXX object src/markets/CMakeFiles/markets.dir/execution_handler.cpp.o
[ 14%] Building CXX object src/markets/CMakeFiles/markets.dir/fill.cpp.o
[ 18%] Building CXX object src/markets/CMakeFiles/markets.dir/instrument.cpp.o
[ 22%] Building CXX object src/markets/CMakeFiles/markets.dir/market_bar.cpp.o
[ 25%] Building CXX object src/markets/CMakeFiles/markets.dir/market_snapshot.cpp.o
[ 29%] Building CXX object src/markets/CMakeFiles/markets.dir/order.cpp.o
[ 33%] Building CXX object src/markets/CMakeFiles/markets.dir/pnl_calculator.cpp.o
[ 37%] Building CXX object src/markets/CMakeFiles/markets.dir/portfolio.cpp.o
[ 40%] Building CXX object src/markets/CMakeFiles/markets.dir/position_summary.cpp.o
[ 44%] Linking CXX static library libmarkets.a
[ 44%] Built target markets
Scanning dependencies of target run_backtest
[ 48%] Building CXX object src/CMakeFiles/run_backtest.dir/main.cpp.o
make[2]: *** No rule to make target '/usr/lib/x86_64-linux-gnu/libboost_filesystem.so,', needed by 'src/run_backtest'. Stop.
CMakeFiles/Makefile2:87: recipe for target 'src/CMakeFiles/run_backtest.dir/all' failed
make[1]: *** [src/CMakeFiles/run_backtest.dir/all] Error 2
Makefile:129: recipe for target 'all' failed
make: *** [all] Error 2
这个项目有几个 CMakeLists.txt
文件,因为有 1.) 一个主要的可执行文件 markets/src/main.cpp
,2.) 一个静态库,以及 3.) markets/test/
中的一些单元测试.
首先是 markets/CMakeLists.txt
:
cmake_minimum_required(VERSION 3.10)
set(CMAKE_CXX_STANDARD 11 ) # used to be 17
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3")
#set(CMAKE_CXX_COMPILER /usr/bin/g++-8) # this is now set externally!
set(CMAKE_INSTALL_PREFIX ${PROJECT_SOURCE_DIR})
set(MARKETS_INSTALL_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/include)
set(MARKETS_INSTALL_BIN_DIR ${PROJECT_SOURCE_DIR}/bin)
set(MARKETS_INSTALL_LIB_DIR ${PROJECT_SOURCE_DIR}/lib)
set(MARKETS_HEADERS_DIR ${PROJECT_SOURCE_DIR}/src/markets)
include_directories(${MARKETS_INSTALL_INCLUDE_DIR})
include_directories(${MARKETS_HEADERS_DIR})
add_subdirectory(src)
add_subdirectory(test)
然后是markets/src/CMakeLists.txt
(我认为这是有问题的那个)
cmake_minimum_required(VERSION 3.10)
project(run_backtest)
add_subdirectory(markets)
set(SOURCE_FILES main.cpp)
find_package (Eigen3 3.3 REQUIRED NO_MODULE)
find_library(mysqlcppconn 1.1.12 REQUIRED)
find_package(Boost 1.65.1 REQUIRED COMPONENTS system filesystem)
include_directories(${Boost_INCLUDE_DIRS})
add_executable(run_backtest ${SOURCE_FILES})
target_link_libraries(run_backtest markets Eigen3::Eigen mysqlcppconn ${Boost_LIBRARIES})
install(TARGETS run_backtest DESTINATION ${MARKETS_INSTALL_BIN_DIR})
然后是markets/src/markets/CMakeLists.txt
cmake_minimum_required(VERSION 3.10)
project(markets)### C CXX)
set(SOURCE_FILES
data_handlers.h
data_handlers.cpp
data_readers.h
data_readers.cpp
execution_handler.h
execution_handler.cpp
fill.h
fill.cpp
instrument.h
instrument.cpp
market_bar.h
market_bar.cpp
market_snapshot.h
market_snapshot.cpp
order.h
order.cpp
pnl_calculator.h
pnl_calculator.cpp
portfolio.h
portfolio.cpp
position_summary.h
position_summary.cpp
)
#set(Boost_USE_STATIC_LIBS OFF)
#set(Boost_USE_MULTITHREADED ON) # maybe off?
#set(Boost_USE_STATIC_RUNTIME OFF)
find_package(Boost 1.65.1 REQUIRED COMPONENTS system filesystem)
find_package (Eigen3 3.3 REQUIRED NO_MODULE)
find_library(mysqlcppconn 1.1.12 REQUIRED)
include_directories(${Boost_INCLUDE_DIRS})
link_directories( ${Boost_LIBRARY_DIRS})
add_library(markets SHARED STATIC ${SOURCE_FILES})
target_link_libraries(markets Eigen3::Eigen mysqlcppconn, ${Boost_LIBRARIES})
# not sure if i need this
target_link_libraries( markets ${Boost_FILESYSTEM_LIBRARY}, ${Boost_SYSTEM_LIBRARY})
install(TARGETS markets DESTINATION ${MARKETS_INSTALL_LIB_DIR})
我很确定它抱怨的这个文件存在,所以我不确定该怎么做:
taylor@taylor-XPS-13-9365:~$ stat /usr/lib/x86_64-linux-gnu/libboost_filesystem.so
File: /usr/lib/x86_64-linux-gnu/libboost_filesystem.so -> libboost_filesystem.so.1.65.1
Size: 29 Blocks: 0 IO Block: 4096 symbolic link
Device: 10302h/66306d Inode: 17184887 Links: 1
Access: (0777/lrwxrwxrwx) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2019-09-24 11:11:06.384111528 -0400
Modify: 2018-03-06 05:21:23.000000000 -0500
Change: 2019-09-24 11:10:45.160636771 -0400
Birth: -
您的问题是由文件名后面的逗号 ('/usr/lib/x86_64-linux-gnu/libboost_filesystem.so,'
) 引起的。
您应该删除 CMake 函数调用中的逗号分隔参数(只需在它们之间留一些空格)。