函数“未定义的符号”错误[重复]

问题描述 投票:1回答:1

我正试图让https://github.com/Duthomhas/CSPRNG的图书馆工作。

这是我的代码:

#include <iostream>
#include <duthomhas/csprng.hpp>

int main(int argc, const char * argv[]) {
    duthomhas::csprng rng;

    return 0;
}

当我编译它时,我得到两个错误:“Undefined symbol:_csprng_create”和“Undefined symbol:_csprng_destroy”。这对我来说没有意义,因为包含在csprng.hpp中的csprng.h文件定义了函数csprng_create()和csprng_destroy()。那么为什么编译器不承认这些函数的存在呢?我该如何解决这个问题?

c++ definition
1个回答
2
投票

头文件不包括函数的实现,只包括定义。包中有一个cpp文件,其中包含了我现在包含的这些实现,现在程序编译得很好。

© www.soinside.com 2019 - 2024. All rights reserved.