dev makefile.win 在 dev c++ 上编译 C++ 时出错

dev makefile.win error while compiling c++ on dev c++

本文关键字:dev C++ 出错 编译 c++ makefile win      更新时间:2023-10-16

我试图在dev c ++中使用我自己的自定义头文件运行我的代码。

但是当我编译它时得到这个错误:

25      C:UsersaliDesktophw2Makefile.win   recipe for target 'tar.exe' failed

它指向makefile.win中的这一行:

    $(CPP) $(LINKOBJ) -o $(BIN) $(LIBS)

并且我还将我的文件添加到我的项目中:main.cpp&post.cpp&post.h

这是我的代码(仅限邮箱类):

在头文件中:

#include <iostream>
#include <string>
using namespace std;
#ifndef P
#define P
class PostBox{
friend void Send(PostBox);
public:
    int getcount();
    void Count();
    PostBox(string,float,int,Person,Person);
    PostBox();
    void setID(string);
    void setweight(float);
    void setsender(Person);
    void setreceiver(Person);
    void cost();
    string getid();
    Person getsender();
    Person getreceiver();
protected:
    static int count;
    string id;
    float weight;
    int price;
    Person sender;
    Person receiver;
};
 #endif

在我的 CPP 文件中:

#include <iostream>
#include "post.h"
using namespace std;
PostBox::PostBox(string id,float weight,int price,Person sender,Person      receiver)
{
this->count=0;
this->id=id;
this->weight=weight;
this->price=price;
this->sender=sender;
this->receiver=receiver;
} 

您缺少static int ::count声明。

将这样的东西放入您的 cpp 文件int PostBox::count = 0 .