compiler error c++ msys-1.0.dll windows

发布于 2022-09-06 12:35:59 字数 1839 浏览 11 评论 0

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 part B right as well. Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

李白 2022-09-13 12:35:59

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.

高跟鞋的旋律 2022-09-13 12:35:59

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]".

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文