UNIX下makefile编译问题
写了一个简单的测试程序,demo.cppmytime.cppmytime.h,使用g++-o可以正常运行,但是我写了一个makefile,test:demo.omytim...
写了一个简单的测试程序,demo.cpp mytime.cpp mytime.h,使用g++ -o 可以正常运行,但是我写了一个makefile,
test:demo.o mytime.o
cc -o test demo.o mytime.o
demo.o:demo.cpp mytime.h
cc -c demo.cpp
mytime.o:mytime.cpp mytime.h
cc -c mytime.cpp
clean:
rm test demo.o mytime.o
使用make编译就出现这个提示然后stop
cc -c demo.cpp
contains an incorrect file suffix
not found28 input file demo.cpp
以下有demo.cpp
#include <iostream>
#include "mytime.h"
int main()
{
Time aida(3,35);
Time tosca(2,48);
Time temp;
std::cout<<" Aida and Tosca:\n";
temp = aida + tosca;
std::cout<<" Aida + Tosca: "<<temp<<std::endl;
temp = aida*1.17;
std::cout<<" Aida*1.17: "<<temp<<std::endl;
std::cout<<"10 * Tosca: "<<10* tosca<<std::endl;
return 0;
} 展开
test:demo.o mytime.o
cc -o test demo.o mytime.o
demo.o:demo.cpp mytime.h
cc -c demo.cpp
mytime.o:mytime.cpp mytime.h
cc -c mytime.cpp
clean:
rm test demo.o mytime.o
使用make编译就出现这个提示然后stop
cc -c demo.cpp
contains an incorrect file suffix
not found28 input file demo.cpp
以下有demo.cpp
#include <iostream>
#include "mytime.h"
int main()
{
Time aida(3,35);
Time tosca(2,48);
Time temp;
std::cout<<" Aida and Tosca:\n";
temp = aida + tosca;
std::cout<<" Aida + Tosca: "<<temp<<std::endl;
temp = aida*1.17;
std::cout<<" Aida*1.17: "<<temp<<std::endl;
std::cout<<"10 * Tosca: "<<10* tosca<<std::endl;
return 0;
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询