You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用get_string函数出现arm64架构未定义符号错误求助

问题分析与解决

你的错误是链接阶段找不到CS50库的get_string函数实现——你只在代码里包含了<cs50.h>头文件(它只声明函数接口),但编译时没告诉编译器要链接CS50的库文件,导致链接器找不到函数的具体实现代码。

解决步骤

  • 用clang或gcc编译时,必须在命令末尾加上-lcs50参数来链接CS50库:
    clang hello.c -o hello -lcs50
    # 或者用gcc
    gcc hello.c -o hello -lcs50
    
  • 如果用make工具编译,要确保命令里带上链接参数:
    make hello -lcs50
    

额外提示

你代码里printf的字符串可以改成"hello, %s\n",这样输出会自动换行,格式更规范。

内容的提问来源于stack exchange,提问作者toasted

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.11 20:45:34