用make编译多个C文件 [英] Compile multiple C files with make

查看:284
本文介绍了用make编译多个C文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

(我运行Linux Ubuntu 9.10,所以可执行文件的扩展名是executablefile.out)我正在进入模块化编程(编程多个文件)在C,我想知道如何编译多个文件在一个makefile。例如,编译这些文件的makefile是什么:main.c,dbAdapter.c,dbAdapter.h? (顺便说一下,如果你还没有想到它,主要的功能是在main.c)也可以有人链接到一个makefile的文档。

(I am running Linux Ubuntu 9.10, so the extension for an executable is executablefile.out) I am just getting into modular programming (programming with multiple files) in C and I want to know how to compile multiple files in a single makefile. For example, what would be the makefile to compile these files: main.c, dbAdapter.c, dbAdapter.h? (By the way, If you haven't figured it out yet, the main function is in main.c) Also could someone post a link to the documentation of a makefile?

推荐答案

查看我的 Makefile教程:如何编写Makefile 。它提供了一个精心制作的Makefile,它将构建这样一个项目(具有多个C和C ++源文件),解释它是如何工作的,并警告常见的陷阱以及糟糕的makefile实践,这是常见的,在野外遇到。

See my Makefile Tutorial: How To Write A Makefile. It provides a well-crafted Makefile that will build such a project (with multiple C and C++ source files), explains how it works, and warns against common pitfalls as well as poor makefile practices that are all too common to encounter out in the wild.

这篇关于用make编译多个C文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆