使用 IGRAPH 面向对象编程
Using IGRAPH object oriented programming
我有库igraph完美地适用于C中的代码。
但是,当我尝试在C++中编译代码时,我遇到了未定义的引用问题。有些函数有效,有些则无效。我相信缺少的是包括" igraph.hpp",基于我的研究。虽然,我不知道如何安装这些文件。
我正在尝试编译以下示例程序:
#include <iostream>
#include <igraph.h>
using namespace std;
int main() {
igraph_t g;
FILE *ifile;
int i;
igraph_sparsemat_t temp;
ifile=fopen("karate.gml", "r");
if (ifile==0) printf("erro");
igraph_read_graph_gml(&g, ifile);
fclose(ifile);
i=igraph_get_sparsemat(&g, &temp);
return 0;
}
我正在使用以下命令编译程序:
g++ teste.cc -I/usr/local/include/igraph -L/usr/local/lib -ligraph -o teste
但是,会发生此错误:
teste.cc:(.text+0x77): referência indefinida para `igraph_get_sparsemat(igraph_s const*, igraph_sparsemat_t*)'
collect2: error: ld returned 1 exit status
谁能帮我?
就这样做
extern "C" {
#include <igraph.h>
}
C++ 编译器会破坏函数名称,因此在库中搜索该函数时将找不到它,如果这样做,则在 igraph.h
中声明的每个函数都将具有 C 链接,以防止名称重整。
相关文章:
- 分段错误(内核转储) C++面向对象编程
- 面向对象编程 - 位域私有结构的公共参考
- 面向对象编程和对象组合,如何放置组合属性?
- 面向对象编程错误
- 我如何向只用Fortran 77编码的人解释面向对象编程?
- 面向对象编程:在GUI中启动ab对象
- 指针和面向对象编程
- 如何为我的蛋捕手游戏创建落蛋?面向对象编程c++的新手
- 凯撒密码面向对象编程
- Haskell中的面向对象编程
- 使用 IGRAPH 面向对象编程
- 单元测试 非面向对象编程
- C++ 面向对象编程
- 面向对象编程风格
- 如何在C++中启动面向对象编程
- 在学习C#之前,必须先学习OOP(C++上的面向对象编程)
- 异常处理需要面向对象编程吗?
- 多文件和面向对象编程
- VBA面向对象编程
- 面向对象编程意味着只使用对象吗?