编译代码时出错,链接器命令失败
Error when compiling the code, linker command failed?
我对c++比较陌生,我正在使用CLions。我正试图按如下方式运行这段代码:
/*
* 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);
}
但是,我得到以下错误:
[50%]构建CXX对象CMakeFiles/warm .dir/src/warm . cppo[100%]链接CXX可执行预热程序:没有找到库-llib/StanfordCPPLib clang: error: link command failed with exit code 1(使用-v查看调用)make[3]: * [Warmup] error 1make[2]: [CMakeFiles/预热。错误2 make[1]: [CMakeFiles/热身。错误2:*[热身]错误2
我知道这适用于microsoft studio c++,但我不确定为什么它不能在CLions上运行。有人能给点建议吗?
任何帮助都将非常感激。
感谢编辑:这是我当前的CMakeLists.txt文件的样子:
cmake_minimum_required(VERSION 3.6)
project(0_Warmup)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(SOURCE_FILE src/Warmup.cpp)
link_libraries(lib/StanfordCPPLib)
add_executable(Warmup src/Warmup.cpp)
链接这个库时出错了吗?
我认为你在上面添加了//
#include "../lib/StanfordCPPLib/console.h"
#include "../lib/StanfordCPPLib/simpio.h"// library and u shud try once again a right path of library folder ..
相关文章:
- Netbeans 10:错误:链接器命令失败,退出代码为 1(使用 -v 查看调用)
- 链接器命令失败,macOS 上的退出代码为 1(使用 -v 查看调用)
- CMake 错误:链接器命令失败,退出代码为 1 和 cpp.o 文件
- clang:错误:链接器命令失败,退出代码为 1(使用 -v 查看调用) - 体系结构的未定义符号 x86_64:
- 如何修复 clang: 错误:链接器命令失败,退出代码为 1(使用 -v 查看调用)
- 当命令失败时,gzip 会在 C++ 中返回错误代码吗?
- Xcode:链接器命令失败,退出代码为 1(使用 -v 查看调用)[C++]
- 电报上的构建命令失败
- Android NDK.Build命令失败.未定义的引用.clang++:错误:链接器命令失败,退出代码为1
- exteranl原生构建问题,构建命令失败,android工作室
- build命令失败,外部原生问题android工作室
- 错误:链接器命令失败,退出代码为 1(使用 -v 查看调用):在 Macbook 上
- make:致命错误:目标命令失败
- C++ XCODE ld:找不到体系结构x86_64 clang 的符号:错误:链接器命令失败,退出代码为 1(使用 -
- Android opencv 3.4.1 Build 命令失败.未定义的引用
- clang:错误:链接器命令失败,C++代码中的退出代码为 1(使用 -v 查看调用)
- Xcode 10.0:链接器命令失败,退出代码为 1(使用 -v 查看调用)
- 为什么我在我的C 代码中获得链接命令失败错误
- C++编译错误:ld:找不到体系结构x86_64 clang 的符号:错误:链接器命令失败,退出代码为 1(使用 -v
- 为什么此命令失败?rm 和 g++ 命令?