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 part B right as well. Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
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]".