我对C ++比较陌生,我正在使用CLions。我试图按如下方式运行此代码:
_token
但是,我收到以下错误:
[50%]构建CXX对象CMakeFiles / Warmup.dir / src / Warmup.cpp.o [100%]链接CXX可执行文件预热ld:找不到库 -llib / StanfordCPPLib clang:错误:链接器命令失败,退出代码为1(使用-v查看调用)make [3]: * [Warmup]错误1 make [2]: [CMakeFiles / Warmup.dir / all]错误2 make [1]: [CMakeFiles / Warmup.dir / rule]错误2使:* [预热]错误2
我知道这适用于微软工作室C ++,但我不确定为什么它不适用于CLions。有人会介意给点建议吗?
非常感谢任何帮助。
由于
编辑:这是我当前的CMakeLists.txt文件:
/*
* File: Warmup.cpp
* ----------------
#include <iostream>
#include <string>
#include "../lib/StanfordCPPLib/console.h"
#include "../lib/StanfordCPPLib/simpio.h"
using namespace std;
/* Constants */
const int HASH_SEED = 5381; /* Starting point for first cycle */
const int HASH_MULTIPLIER = 33; /* Multiplier for each cycle */
const int HASH_MASK = unsigned(-1) >> 1; /* All 1 bits except the sign */
/* Function prototypes */
int hashCode(string key);
/* Main program to test the hash function */
int main() {
string name = getLine("Please enter your name: John");
int code = hashCode(name);
cout << "The hash code for your name is " << code << "." << endl;
return 0;
}
/*
* Function: hash
* Usage: int code = hashCode(key);
* --------------------------------
int hashCode(string str) {
unsigned hash = HASH_SEED;
int nchars = str.length();
for (int i = 0; i < nchars; i++) {
hash = HASH_MULTIPLIER * hash + str[i];
}
return (hash & HASH_MASK);
}
我在某个地方链接此库时出错了吗?
答案 0 :(得分:-3)
我想你在上面加了//
#include "../lib/StanfordCPPLib/console.h"
#include "../lib/StanfordCPPLib/simpio.h"// library and u shud try once again a right path of library folder ..