ubuntu - 当我包含 cs50 库时使用 make 编译时出现问题?
问题描述
我已经 在Ubuntu 20.04中安装了CS50 库 此代码只是为了查看它是否可以正常工作 它可以正常使用 clang 但是使用 make 它不会自动链接库所以我收到此错误 - 我正在使用 Visual Studio 代码
#include <stdio.h>
#include <cs50.h>
int main(void)
{
string d = get_string("what is your name: ");
printf("Hello, %s\n ",d);
}
输出
mohamed@mohamed-Latitude-E5470:~/Downloads/projects$ clang hello.c -o hello -lcs50
mohamed@mohamed-Latitude-E5470:~/Downloads/projects$ make hello
cc hello.c -o hello
/usr/bin/ld: /tmp/ccJDbREo.o: in function `main':
hello.c:(.text+0x1e): undefined reference to `get_string'
collect2: error: ld returned 1 exit status
make: *** [<builtin>: hello] Error 1
使用make时如何使其自动链接库
解决方案
推荐阅读
- c# - 如何访问 ItemsPanelTemplate 中的 ItemsWrapGrid 面板?
- jenkins-pipeline - 出现错误:脚本在测试时返回退出代码 1
- php - 我应该在系统更新后重新编译 PHP 吗?
- javascript - 如何通过结合JavaScript中的两个函数来确定给定的数字是否是汉明数?
- c++ - 如何创建智能指针映射,当指针超出范围时删除其元素
- android - 将分页库从 3.0.0-alpha10 更新到 3.0.0-alpha12 时出现运行时错误
- pyspark - 将两个 pyspark 数据框与仅保留唯一值的列组合在一起
- c# - 使用 Visual Studio 2019 设置 OpenCvSharp
- c# - 我将如何编写一个定时器,它可以作为协程正常工作,作为无效?
- r - 在 R 中的分组数据框中为每组分配增加的索引