0

A possible duplicate of Entry point not found when running exe

Recently, I installed MinGW and I was following some examples shown in "C++ in Easy Steps". I was working through it, and I got on to the section about classes.

It told me to enter this code so here it is:

#include <string>
#include <iostream>
using namespace std;

class Dog
{
  int age, weight ;
  string color ;

  public:
    void bark() { cout << "WOOF!" << endl ; }

    void setAge( int yrs ) { age = yrs ; }
    void setWeight( int lbs ) { weight = lbs ; }
    void setColor( string hue ) { color = hue ; }
    
    int getAge() { return age; }
    int getWeight() { return weight; }
    string getColor() { return color; }
} ;

int main()
{
  Dog fido ;

  fido.setAge( 3 ) ;
  fido.setWeight( 15 ) ;
  fido.setColor( "brown" ) ;

  cout << "Fido is a " << fido.getColor() << " dog" << endl ;
  cout << "Fido is " << fido.getAge() << " years old" << endl ;
  cout << "Fido weighs " << fido.getWeight() << " pounds" << endl ;

  fido.bark() ;

  return 0 ;
}

I compiled it successfully (cmd: c++ object.cpp -o object.exe)

And I executed (cmd: object) it and came up with this error message:

The Error Message

What did I do wrong?

I've noticed that it is just programs with classes that have this problem, because I can run programs without classes, just with them is the issue.

Edit:

It is different from the above question, because I already have my PATH Environmental Variable set to C:\MinGW\bin:

The accepted answer says:

Locate the directory containing libstdc++-6.dll and add it to your PATH variable.

  • Open command prompt
  • Run set PATH=%PATH%;YOUR_PATH_HERE

So am I doing it right?

Community
  • 1
  • 1
  • Possible duplicate of [Entry point not found when running exe - C++](https://stackoverflow.com/questions/42451175/entry-point-not-found-when-running-exe-c) – Vishaal Shankar Feb 07 '18 at 16:59
  • @VishaalShankar , no, it is not, please see my edit. – user189636 Feb 07 '18 at 17:12
  • The issue is the same and there is an accepted solution in that post. Did you try to add -static-libstdc++ to your linking options as asked to in the accepted answer ? – Vishaal Shankar Feb 07 '18 at 17:20
  • @VishaalShankar , I am assuming that giving a path variable as a folder directory links it to all `.exe.s in the directory. – user189636 Feb 08 '18 at 16:31
  • You may have an older, incompatible library called libstdc++-6.dll somewhere in your system, which happens to be in the PATH and thus preempt loading the right one. Search and remove all of those, only leave the one from your MinGW install. – n. m. could be an AI Feb 09 '18 at 07:50
  • @n.m. Since (according to your comment) I obviously don't understand.anything and should keep my comments unpublished I suggest you either publish yours as an answer or delete my account. Technically you are supposed to answer the OP's questions and not post condescending comments like that one. – Jerry Jeremiah Feb 10 '18 at 21:12
  • @n.m. But being rude to me is acceptable somehow. Good on you. – Jerry Jeremiah Feb 10 '18 at 21:59

0 Answers0