当前位置: 技术问答>linux和unix
把.c改为.cpp后,编译出错,怀疑是makefile问题!!!
来源: 互联网 发布时间:2016-06-11
本文导语: 我编写的语言程序命名为:portapp.c,rtclocklib.c,wdtapp.c,dispapp.c,keyboard.c,main.c 。 我的makefile源码如下: CC = /usr/local/arm/3.3.2/bin/arm-linux-g++ LD = /usr/local/arm/3.3.2/bin/arm-linux-ld AR = /usr/local/arm/3.3.2/bin/arm-linux-ar EXEC = main OBJS = main....
我编写的语言程序命名为:portapp.c,rtclocklib.c,wdtapp.c,dispapp.c,keyboard.c,main.c 。
我的makefile源码如下:
CC = /usr/local/arm/3.3.2/bin/arm-linux-g++
LD = /usr/local/arm/3.3.2/bin/arm-linux-ld
AR = /usr/local/arm/3.3.2/bin/arm-linux-ar
EXEC = main
OBJS = main.o dispapp.o keyboard.o portapp.o rtclocklib.o
INCLUDE:=-I./ -I../include -I/home/linux-2.6.13-hzh/include
CFLAGS :=${INCLUDE}
LIBS := -lpthread
all: $(EXEC)
$(EXEC): $(OBJS)
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJS) $(LIBS)
wdt:wdtapp
$(CC) $(LDFLAGS) -o wdtapp wdtapp.c
port:portapp
$(CC) $(LDFLAGS) -o portapp portapp.c
can:cantxrx
$(CC) $(LDFLAGS) -o cantxrx cantxrx.c
rtc:rtclocklib
$(CC) $(LDFLAGS) -o rtclocklib rtclocklib.c
kbd:keyboard
$(CC) $(LDFLAGS) -o keyboard keyboard.c
lcd:dispapp
$(CC) $(LDFLAGS) -o dispapp dispapp.c
clean_so:
-rm -f *.so
clean_a:
-rm -f *.a
clean:
-rm -f $(EXEC) *.elf *.gdb *.o $(EXEC1)
使用make命令是可以编译的,但是我把所有源文件改为.cpp,就不能编译了,提示:
[root@localhost new_src]# make
g++ -c -o main.o main.cpp
make: g++: Command not found
make: *** [main.o] Error 127
是不是makefile要修改以下,请指教。初次使用makefile.多谢帮助!!!
我的makefile源码如下:
CC = /usr/local/arm/3.3.2/bin/arm-linux-g++
LD = /usr/local/arm/3.3.2/bin/arm-linux-ld
AR = /usr/local/arm/3.3.2/bin/arm-linux-ar
EXEC = main
OBJS = main.o dispapp.o keyboard.o portapp.o rtclocklib.o
INCLUDE:=-I./ -I../include -I/home/linux-2.6.13-hzh/include
CFLAGS :=${INCLUDE}
LIBS := -lpthread
all: $(EXEC)
$(EXEC): $(OBJS)
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJS) $(LIBS)
wdt:wdtapp
$(CC) $(LDFLAGS) -o wdtapp wdtapp.c
port:portapp
$(CC) $(LDFLAGS) -o portapp portapp.c
can:cantxrx
$(CC) $(LDFLAGS) -o cantxrx cantxrx.c
rtc:rtclocklib
$(CC) $(LDFLAGS) -o rtclocklib rtclocklib.c
kbd:keyboard
$(CC) $(LDFLAGS) -o keyboard keyboard.c
lcd:dispapp
$(CC) $(LDFLAGS) -o dispapp dispapp.c
clean_so:
-rm -f *.so
clean_a:
-rm -f *.a
clean:
-rm -f $(EXEC) *.elf *.gdb *.o $(EXEC1)
使用make命令是可以编译的,但是我把所有源文件改为.cpp,就不能编译了,提示:
[root@localhost new_src]# make
g++ -c -o main.o main.cpp
make: g++: Command not found
make: *** [main.o] Error 127
是不是makefile要修改以下,请指教。初次使用makefile.多谢帮助!!!
|
CC = /usr/local/arm/3.3.2/bin/arm-linux-g++
改为以下两行
CC = /usr/local/arm/3.3.2/bin/arm-linux-gcc
CXX = /usr/local/arm/3.3.2/bin/arm-linux-g++
改为以下两行
CC = /usr/local/arm/3.3.2/bin/arm-linux-gcc
CXX = /usr/local/arm/3.3.2/bin/arm-linux-g++
|
g++: Command not found
==============
你确定你的机器里有 g++ ?
==============
你确定你的机器里有 g++ ?
|
不对啊 。
CC = /usr/local/arm/3.3.2/bin/arm-linux-g++
怎么会提示:
g++: Command not found ?
CC = /usr/local/arm/3.3.2/bin/arm-linux-g++
怎么会提示:
g++: Command not found ?
|
改成.cc试试
|
export PATH=$PATH:/usr/local/arm/3.3.2/bin
再看看。
再看看。
|
解压之后,还要设置路径参数,让arm-linux-g++能被找到才可以用的