1)src下删除helloword.c添加自己的程序
#ifndef STUDENT_H_
#define STUDENT_H_
typedef struct student{
int age;
char name[20];
struct student *next;
}STUDENT;
#endif /* STUDENT_H_ */#include<stdio.h>
#include<stdlib.h>
#include"student.h"
STUDENT *head = NULL;
void createList(){
STUDENT *tmp = head;
int i;
for(i = 0; i < 10; i++){
STUDENT *s = (STUDENT*)malloc(sizeof(STUDENT));
s->age = i;
sprintf(s->name, "%d", 10000+i);
s->next = NULL;
tmp->next = s;
tmp = s;
}
}
void tranvseList(){
STUDENT* tmp = head->next;
while(tmp != NULL){
printf("Name = %s, and Age = %d\n", tmp->name, tmp->age);
tmp = tmp->next;
}
}
int main(){
head = (STUDENT*)malloc(sizeof(STUDENT));
head->next = NULL;
createList();
tranvseList();
return 0;
}2. 修改src下的Makefile.am
bin_PROGRAMS=exe1
exe1_SOURCES=student.h student.c
3.project下的configure.ac
AC_PREREQ(2.59)
AC_INIT(MyTest, 1.0)
AC_CANONICAL_SYSTEM
AM_INIT_AUTOMAKE()
AC_PROG_CC
AC_CONFIG_FILES(Makefile src/Makefile)
AC_OUTPUT
4. project下的Makefile.am
SUBDIRS=src
若增加其他的代码包,修改以上几个文件就可以了。
C语言编程与Makefile配置详解
本文详细介绍了如何在C语言项目中使用Makefile进行自动化编译与链接,包括创建、修改源文件、编译规则及配置。通过实例演示了如何在src目录下创建、编辑、编译和链接C语言程序,并对Makefile.am和configure.ac进行了说明。
1115

被折叠的 条评论
为什么被折叠?



