Ubuntu1804源码安装Metis以及作为库调用

本文介绍了如何在Linux环境下安装开源图划分软件Metis,包括Windows安装后的迁移指南。重点讨论了在C/C++混合编程中遇到的undefinedreferenceerror,特别是在使用metisbin.h时,通过externC解决函数名称修饰问题的方法。
摘要由CSDN通过智能技术生成

Metis 安装

Metis是一款开源的图划分、分割软件,在众多网络划分中有应用,其名字取自希腊智慧女神。其windows 安装已有很方便的教程,去知乎搜索就能搜到。为了在Linux环境中使用,可以通过 apt install 方式,也可以用源码安装,总的来说不复杂。
下载tar.gz 解压后

cd metis-5.1.0
make config --prefix=/home/metis #指定用户目录,避免权限问题
make
make install #安装到指定目录,头文件和lib文件

问题

C/CPP混合使用metis出现 undefined reference error

混用了c和cpp的代码经常出现undefined reference function error,就是CPP对函数名称做修饰,导致再使用原来C函数名调用就找不到,在C源文件使用extern C就可以避免CPP对函数名称做修饰。

举个例子 gcc 编译了 func.c 源文件,里面函数名就是func(),func.h头文件声明也是 func()名称,但是此时有个 cpp文件 include func.h 并且使用c++编译,链接了func.o,就会出现 undefined reference func() error,即使用 strings 和 nm 查看 func.o里面确实有func()函数,但是c++就是不认识,因为#include头文件里面对函数声明那里就以及重新修饰了该函数。

  • 解决方法
    在引用 metisbin.h时使用extern C关键字,注意 metis.h不会出现这个问题,因为其已经使用了extern C关键字。修改方式如下
#ifdef __cplusplus
extern "C" {
#endif
   #include "metisbin.h"
#ifdef __cplusplus
}
#endif
metis-5.1.0安装包和manual手册 2 What is new in version 5.0 4 2.1 Changes in the command-line programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 2.1.1 Migration issues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 2.2 Changes in the API routines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 2.2.1 Migration issues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 3 Overview of METIS 6 3.1 Partitioning a graph . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 3.2 Alternate partitioning objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 3.3 Support for multi-phase and multi-physics computations . . . . . . . . . . . . . . . . . . . . . . . . 8 3.4 Partitioning a mesh . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 3.5 Partitioning for heterogeneous parallel computing architectures . . . . . . . . . . . . . . . . . . . . . 8 3.6 Computing a fill-reducing ordering of a sparse matrix . . . . . . . . . . . . . . . . . . . . . . . . . . 9 3.7 Converting a mesh into a graph . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 4 METIS’ stand-alone programs 9 4.1 Input file formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 4.1.1 Graph file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 4.1.2 Mesh file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 4.1.3 Target partition weights file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 4.2 Output file formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 4.2.1 Partition file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值