[c++]coding on Linux(1)compile through makefile with g++

本文记录了使用g++在Linux环境下编译C++文件的过程,并通过编写Makefile成功编译了一组简单的C++编码文件。文章详细介绍了包含的文件、Makefile的内容及其注意事项。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

[c++]OOP — compile on Linux with g++

This paper records the process of compiling c++ files on Linux with g++. Through write the makefile, successfully compiling a group of simple coding files in c++.

Files Included

h filesc filesmakefile
FE_stdafx.hFE_main.cmakefile
FEM_BaseClass.hFEM_BaseClass.c
FEM_UDefined.hFEM_UDefined.c
FEM_Topology.hFEM_Topology.c
FEM_base.h
vim makefile
exe=main
obj=FE_main.o FEM_UDefined.o FEM_BaseClass.o FEM_Topology.o \
#       FEM_base.o

$(exe):$(obj)
    @g++ -o $(exe) $(obj)

FE_main.o : FE_main.c
    @g++ -c FE_main.c

FEM_UDefined.o : FEM_UDefined.c
    @g++ -c FEM_UDefined.c

FEM_BaseClass.o : FEM_BaseClass.c
    @g++ -c FEM_BaseClass.c

FEM_Topology.o : FEM_Topology.c
    @g++ -c FEM_Topology.c

#FEM_base.o : FEM_base.h
#   @g++ -c FEM_base.h


tar :   
    @tar -cf FEM3.0.tar  FE_main.c  FEM_base.h  FEM_UDefined.c \
                     FEM_BaseClass.c  FEM_Topology.c  FEM_UDefined.h \
                     FEM_BaseClass.h  FEM_Topology.h  FE_stdafx.h  makefile
clean:
    rm -rf *.o main

NOTE

The including order of h files is vital. Otherwise, errors occur while compiling. A solution of this problem is to add #pragram once to each of the h files.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值