У меня есть Проект Я работаю над, и я не могу получить 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: -
0
Taylor 25 Сен 2019 в 01:51

1 ответ

Лучший ответ

Ваша проблема вызвана запятой после имени файла ('/usr/lib/x86_64-linux-gnu/libboost_filesystem.so,'). Вы должны удалить аргументы, отделяющие запятыми в ваших вызовах функции CMake (просто оставьте некоторые пробелы между ними).

1
Thomas Bécavin 24 Сен 2019 в 23:23