Linker 由g+产生的未定义引用+;连接

Linker 由g+产生的未定义引用+;连接,linker,g++,Linker,G++,我不熟悉g++和Makefile。我正在尝试链接这个BeBOP SMC库,它在我的lib目录中。在lib目录下是bebop_util和sparse_matrix_converter,它们都已经构建好,没有错误。我在bebop_util和libsparse_matrix_converter.a下看到libbebop_util.a,libbebop_util.so,在sparse_matrix_converter.a下看到libsparse_matrix_converter.so。资料来源如下: 生

我不熟悉g++和Makefile。我正在尝试链接这个BeBOP SMC库,它在我的lib目录中。在lib目录下是bebop_util和sparse_matrix_converter,它们都已经构建好,没有错误。我在bebop_util和libsparse_matrix_converter.a下看到libbebop_util.a,libbebop_util.so,在sparse_matrix_converter.a下看到libsparse_matrix_converter.so。资料来源如下:

生成文件

CC=g++
CFLAGS=-c -Wall

test.out: test.o
    $(CC) -o test.out -Ilib/sparse_matrix_converter/include -Llib/bebop_util \
-Llib/sparse_matrix_converter -lbebop_util -lsparse_matrix_converter test.o

test.o: test.cpp
    $(CC) $(CFLAGS) -Ilib/sparse_matrix_converter/include test.cpp

clean:
    rm -f test.o test.out

test.cpp

#include <bebop/smc/sparse_matrix.h>
#include <bebop/smc/sparse_matrix_ops.h>

int main(int argc, const char* argv[])
{
    struct sparse_matrix_t* A = load_sparse_matrix (MATRIX_MARKET, "sample_input");
    destroy_sparse_matrix(A);
    return 0;
}

请注意test.cpp依赖于稀疏矩阵转换器,稀疏矩阵转换器依赖于bebop\u util。你能告诉我我可能犯了什么错误吗?谢谢


汤姆

< P> BeBoP代码看起来是C代码,但没有添加正确的C++守护程序。用
extern“C”
环绕您的内含物,以解决以下问题:

extern "C" {
#include <bebop/smc/sparse_matrix.h>
#include <bebop/smc/sparse_matrix_ops.h>
}
extern“C”{
#包括
#包括
}

您正在链接-lbebop\u util-lsparse\u matrix\u converter,这两个名称看起来不像是主库。你确定你链接了所有内容吗?谢谢你的评论。我想我与一切都有联系。稀疏矩阵转换器是主要的库。该库称为BeBOP SMC。SMC代表稀疏矩阵转换器。谢谢。编译错误随着extern C的添加而消失。但是,我收到一个新错误:./test.out:加载共享库时出错:libbebop_util.so:无法打开共享对象文件:没有这样的文件或目录我通过libbebop_util.so的chmod 777确保权限不是问题。我将接受答案,因为新问题似乎是另一个问题。我将发布新问题。
extern "C" {
#include <bebop/smc/sparse_matrix.h>
#include <bebop/smc/sparse_matrix_ops.h>
}