报错

(.text+0x15): undefined reference to `get_names'
(.text+0x2d): undefined reference to `show_names'

names_st.h

#include <string.h>
#define SLEN 32struct names_st
{char first[SLEN];char last[SLEN];
};typedef struct names_st names;void get_names(names *);
void show_names(const names *);
char * s_gets(char *st, int n);

names_st.c

#include "names_st.h"#include <stdio.h>void get_names(names* pn)
{printf("Please enter your first name: ");s_gets(pn->first, SLEN);printf("Please enter your last name: ");s_gets(pn->last, SLEN);
}void show_names(const names* pn)
{ printf("%s %s", pn->first, pn->last);
}char* s_gets(char* st, int n)
{char* ret_val;char* find;ret_val = fgets(st, n, stdin);if (ret_val) {find = strchr(st, '\n');if (find)*find = '\0';elsewhile (getchar() != '\n') {continue;}return ret_val;}
}

userheader.c

#include <stdio.h>#include "names_st.h"int main(void)
{names candidate;get_names(&candidate);printf("Let's welcome ");show_names(&candidate);printf(" to this program!\n");return 0;
}

解决方法:

gcc -o main userheader.c namest.c

C语言 undefined reference问题相关推荐

  1. 解决C语言编译undefined reference to ‘pow’问题

    在编译C语言源码的时候遇到如下问题: undefined reference to 'pow' 该函数定义在C的#include <math.h>头文件内,明明应用了缺报错了,原因是要在编 ...

  2. matlab使用mex编译c语言报错undefined reference to `__imp_WSAStartup‘

    matlab中使用mex编译c语言文件报错提示: undefined reference to __imp_WSAStartup' 最近我在做一个simulink和其他仿真软件的联合仿真,需要用到ud ...

  3. c语言Winmain 错误,C语言编译错误 undefined reference to `WinMain@16'

    1.把主函数 main() 写成了mian() 2.没写主函数main() 3.建的不是控制台应用程序 console application 4.[code] #include int main() ...

  4. c语言 linker error,[Linker error] undefined reference to `prinf'的问题!

    [Linker error] undefined reference to `prinf'的问题! 环境为dev-cpp 日志如下: 编译器: Default compiler 执行 gcc.exe. ...

  5. 关于用C语言操作mysql时候的编译问题; undefined reference to `mysql_init‘等

    首先是问题: 代码如下 [root@petrichor test]# more test2.c #include <stdio.h> #include <mysql/mysql.h& ...

  6. undefined reference to...

    Linux 下编程出现undefined reference to... 原因分析: 1.链接时缺失了相关目标文件(.o) 2.链接时缺少相关的库文件(.a/.so) 3.    链接的库文件中又使用 ...

  7. undefined reference to 问题解决方法

    最近在Linux下编程发现一个诡异的现象,就是在链接一个静态库的时候总是报错,类似下面这样的错误: (.text+0x13): undefined reference to `func' 关于unde ...

  8. gcc undefined reference to 问题解决方法(使用库)

    最近在Linux下编程发现一个诡异的现象,就是在链接一个静态库的时候总是报错,类似下面这样的错误: (.text+0x13): undefined reference to `func' 关于unde ...

  9. android error: undefined reference to 的错误分析

    今天,简单讲讲android  error: undefined reference to 的错误分析. 昨天,做jni,连接so库时,android studio出现了这个问题.当时不知道是什么 ...

最新文章

  1. centos下mysql常用的三种备份方法_centos下mysql自动备份(全量)
  2. R语言ggplot2可视化自定义图例标签间距实战:自定义图例标签间距、自定义图例与图像之间的间距
  3. 云爆发架构是否难以实施?
  4. Oracle 10.2.0.4和10.2.0.5 中 OEM bug 8350262
  5. 前牙正常覆盖是多少_个性化舌侧矫治器的前牙转矩控制技巧——赵志河教授
  6. Java——String类中的compareTo方法总结
  7. javascript DOM基础(一)
  8. python web自动化测试实验报告_Python:web自动化测试
  9. 一、css清除浮动方法学习笔记总结(超详细,简单易懂)
  10. php闭包 回调函数,PHP|PHP实践-闭包
  11. Windows Terminal Preview 1.3 发布
  12. 使用 sroll-snap-type 优化滚动
  13. 操作系统—多生产者多消费者问题
  14. 持续集成实践二之Jenkins与Sonar Qube集成
  15. JSON怎么转成Excel
  16. cad修改快捷键_CAD大神总结:100个CAD快捷键+20个CAD制图技巧
  17. 场外模拟 省选联考(B卷) 2020 游记
  18. python 实现表情迁移
  19. 【大咖说Ⅰ】北邮博导石川教授:图机器学习及其应用
  20. MTK笔试面试题集锦

热门文章

  1. 蓝牙耳机什么品牌好?五款性价比高的无线蓝牙耳机品牌推荐
  2. JQuery和Ajax在ASP.NET MVC中的基本应用
  3. 抖音 Android 基础技术大揭秘!
  4. window7设置无线WIFI,手机用笔记本上网(解决流量不够用问题)
  5. linux wget解压包的问题
  6. DAVINCI DM365-DM368开发攻略——linux-2.6.32的移植
  7. ASP.NET Core中数据绑定的Attribute
  8. 计算机组成原理知识点汇总(考研用)——第五章:中央处理器
  9. securecrt乱码
  10. linux用于暂时锁定用户帐号的命令是,linux用于暂时锁定用户帐号的命令是()