开发者

compiler error c++ msys-1.0.dll windows

I am trying to run simple program but get the following compiler error: $./lab2 /directory here/lab2.exe: error while loading shared libraries: msys-1.0.dll: cannot open shared object file: No such file or directory

here is my makefile and code:


# CS240 Lab2 Makefile 

all: lab2

lab2: main.o tenstrings.o g++ main.o tenstrings.o -o lab2

main.o: main.cpp g++ -Wall -c main.cpp -o main.o

tenstrings.o: tenstrings.cpp g++ -Wall -c tenstrings.cpp -o tenstrings.o

tenstrings.h 

------------------------------------------------------------------------*/

#ifndef TENSTRNGS
#define TENSTRNGS

class TenStrings
{
public: 
    // Default Constructor
    TenStrings(); 
    TenStrings str[10];
};

#endif

    tenstrings.cpp 
--------------------------*/
#include "TenStrings.h"

using namespace std;

//Default Constructor
TenStrings::TenStrings()
{
private:

    str[0] = "String 1";
    str[1] = "String 2";
    str[2] = "String 3";
    str[3] = "String 4";
    str[4] = "String 5";
    str[5] = "String 6";
    str[6] = "String 7";
    str[7] = "String 8";
    str[8] = "String 9";
    str[9] = "String 10";

    std::cout << str[2] << std::endl;
}
;

    main.cpp 
--------------------------*/
#include "TenStrings.h"
#include <iostream>

int main()
{
    TenStrings varTen;


    return 0; 
}

I am trying to do part B of this lab: http://cs.binghamton.edu/~sgreene/cs240-2010f/labs/lab2.html so if you can not only give me advice on the running exe error but also tell me if I am getting开发者_JS百科 part B right as well. Thanks.


That's not a compiler error actually. You're getting an error from your OS when you run the program saying that it can't find all the libraries it is linked to, namely the mingw runtime.

Mingw doesn't install those dll's in the system32 like some others. You can solve the problem by making sure that the dll you're getting the error about is in your PATH. One good place is to copy it (don't move it of course) into the directory containing your exe.


The code as written doesn't compile. The problem is that your TenStrings class contains an array TenStrings objects. Since each TenStrings requires that the compiler provide storage for ten TenStrings objects, it can't compile.

Try replacing the "TenStrings str[10]" with "std::string str[10]" and see how that works.

Edit: If you have to use pointers to characters, then try "const char *str[10]".

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜