【发布时间】:2020-10-22 13:45:55
【问题描述】:
我尝试使用一些哈希 API,但它给出了编译错误。我尝试了 2 个不同的哈希 API 和 2 个不同的 IDE 和编译器,但它给出了相同的错误。它看起来像一个链接器错误。通常存在“未解决的外部外部”或“未定义到”编译错误。如何修复编译错误?
test.cpp:
#include <iostream>
#include <string>
#include "xxHash-0.7.4/xxhash.h"
int main()
{
const char test[] = "srgsdf";
XXH64_hash_t seed = 545244;
XXH64_hash_t test_xxhash = XXH64(test, strlen(test), seed);
std::cout << test_xxhash;
return 0;
}
错误列表:
LNK1120 - unresolved externals
LNK2019 - unresolved external symbol _XXH64 referenced in function _main
Visual Studio 2019 - 16.6.2 上的 XXHash64: XXHash64 on Visual Studio
XXHash64 API on Code::Blocks - 20.03: XXHash64 API on Code::Blocks
Hash Library 在 Visual Studio 2019 - 16.6.2 上:Hash Library on Visual Studio
Hash Library on Code::Blocks - 20.03: Hash Library on Code::Blocks
【问题讨论】:
-
我没有触摸链接器设置。所有这些都来自默认设置。
-
欢迎来到 SO!请分享代码 sn-p 而不是截图。您可以在这里阅读stackoverflow.com/help/minimal-reproducible-example 了解更多信息。
-
我添加了代码。
标签: c++ visual-studio compiler-errors codeblocks