我正在尝试设置CMake,这样就可以正确地链接升压图。但是我在做的时候遇到了一个错误
find_package(Boost REQUIRED COMPONENTS graph mpi) # finding mpi is a problem-- Found boost_mpi 1.77.0 at ~/miniconda3/envs/xyz/lib/cmake/boost_mpi-1.77.0
-- Library has no variants and is considered not found
CMake Error at /home/tom/miniconda3/envs/pokeai/lib/cmake/Boost-1.77.0/BoostConfig.cmake:141 (find_package):
Found package configuration file:
~/miniconda3/envs/xyz/lib/cmake/boost_mpi-1.77.0/boost_mpi-config.cmake
but it set boost_mpi_FOUND to FALSE so package "boost_mpi" is considered to
be NOT FOUND. Reason given by package:
No suitable build variant has been found.我已经尝试从Boost图中找到一个文档,但是似乎cmake部分不适合安装。来自boost_mpi-config.cmake的一条线在我看来是可疑的,这与错误有关。
要在本地产生问题,您可能会发现下面的文件很有用。
CMakeLists.txt使用:
cmake_minimum_required(VERSION 3.23)
set(Boost_VERBOSE ON)
message(CHECK_START "Looking for MPI")
find_package(MPI REQUIRED COMPONENTS CXX C)
#find_package(Boost REQUIRED COMPONENTS graph)
find_package(Boost REQUIRED COMPONENTS graph mpi) # finding mpi is a problem
add_executable(parallel_boost_graph parallel_boost_graph.cpp)
target_link_libraries(parallel_boost_graph
PUBLIC
MPI::MPI_CXX
${Boost_LIBRARIES}
Boost::graph
# Boost::mpi
)重现问题的一个小示例代码:
// Enable PBGL interfaces to BGL algorithms
#include <boost/graph/use_mpi.hpp>
// Communication via MPI
#include <boost/graph/distributed/mpi_process_group.hpp>
// Dijkstra's single-source shortest paths algorithm
#include <boost/graph/dijkstra_shortest_paths.hpp>
// Distributed adjacency list
#include <boost/graph/distributed/adjacency_list.hpp>
// METIS Input
#include <boost/graph/metis.hpp>
// Graphviz Output
#include <boost/graph/distributed/graphviz.hpp>
// Standard Library includes
#include <fstream>
#include <string>
#ifdef BOOST_NO_EXCEPTIONS
void boost::throw_exception(std::exception const& ex) {
std::cout << ex.what() << std::endl;
abort();
}
#endif
using namespace boost;
using boost::graph::distributed::mpi_process_group;
/* An undirected, weighted graph with distance values stored on the
vertices. */
typedef adjacency_list<vecS, distributedS<mpi_process_group, vecS>, undirectedS,
/*Vertex properties=*/property<vertex_distance_t, float>,
/*Edge properties=*/property<edge_weight_t, float> >
Graph;
using namespace boost;
using boost::graph::distributed::mpi_process_group;
int main(int argc, char* argv[]) {
boost::mpi::environment env(argc, argv);
typedef adjacency_list<listS, distributedS<mpi_process_group, vecS>,
directedS,
no_property, // Vertex properties
property<edge_weight_t, int> // Edge properties
>
graph_t;
typedef graph_traits<graph_t>::vertex_descriptor vertex_descriptor;
typedef graph_traits<graph_t>::edge_descriptor edge_descriptor;
typedef std::pair<int, int> Edge;
const int num_nodes = 5;
enum nodes { A, B, C, D, E };
char name[] = "ABCDE";
Edge edge_array[] = {Edge(A, C), Edge(B, B), Edge(B, D),
Edge(B, E), Edge(C, B), Edge(C, D),
Edge(D, E), Edge(E, A), Edge(E, B)};
int weights[] = {1, 2, 1, 2, 7, 3, 1, 1, 1};
int num_arcs = sizeof(edge_array) / sizeof(Edge);
graph_t g(edge_array, edge_array + num_arcs, weights, num_nodes);
// Keeps track of the predecessor of each vertex
std::vector<vertex_descriptor> p(num_vertices(g));
// Keeps track of the distance to each vertex
std::vector<int> d(num_vertices(g));
vertex_descriptor s = vertex(A, g);
dijkstra_shortest_paths(g, s,
predecessor_map(make_iterator_property_map(
p.begin(), get(vertex_index, g)))
.distance_map(make_iterator_property_map(
d.begin(), get(vertex_index, g))));
std::cout << std::endl;
return EXIT_SUCCESS;
}为了您的方便,您还可以查看这个回购程序来重现问题:https://bitbucket.org/cpchung/debugging-only
发布于 2022-10-25 07:07:22
并行Boost.Graph库需要Boost.MPI。
没有找到合适的构建变体。
当在libboost_mpi-variant-*.cmake旁边没有boost_mpi-config.cmake文件时就会发生这种情况,在打包过程中出现错误时(例如,将文件复制到最终目标时忽略了这些文件),或者Boost.MPI库根本没有构建。我怀疑后者。
因此,您需要做的是通过您使用的任何包管理器获得包含Boost.MPI的Boost安装,如果Boost库被拆分成单独的包,它可以简单地安装一个额外的包。或者您可以自己构建和安装Boost,确保b2命令能够找到MPI头,从而生成Boost.MPI。
注意:使用CMake变量Boost_DEBUG和Boost_VERBOSE (通过cmake -DBoost_DEBUG=ON设置它们)可以帮助查找没有找到或拒绝库的原因。
https://stackoverflow.com/questions/74186960
复制相似问题