我不能 运行 我的 "a.exe",只要我有 class 构造函数和析构函数,c++ 就用 mingw 制作?
I can't run my "a.exe", made with mingw whenever I have a class constructor and destructor, c++?
我对 C++ 比较陌生,我刚刚完成 codecademy.com
上的在线课程。所以我决定下载 MinGW 和 VScode 开始做一些练习。一切都很顺利,直到我 运行 遇到一个我无法修复的错误。
当我尝试 运行 我的可执行文件时出现此错误:
我将其输入 cmd
,未使用 makefile:
D:\>g++ main.cpp app.cpp
D:\>a.exe
我在命令行中使用 mingw (g++) 来编译我的代码,它在这里:
我的 main.cpp 文件:
#include <iostream>
#include "app.hpp"
int main (int argc, char* argv[]) {
App tomato(true);
std::cout << tomato.get_sauce();
tomato.~App();
return 0;
}
app.hpp:
// Define prototype functions here:
#ifndef APP_HPP
#define APP_HPP
class App {
public:
bool sauce;
App(bool set);
~App();
void set_sauce (bool set);
bool get_sauce ();
};
#endif
app.cpp:
#include "app.hpp"
#include <iostream>
App::App (bool set) {
sauce = set;
}
App::~App () {
std::cout << "goodbye";
}
void App::set_sauce (bool set) {
sauce = set;
}
bool App::get_sauce () {
return sauce;
}
一切都可以正常编译,但是一旦我 运行 可执行文件,我就会得到 The procedure entry point __gxx_personality_v0 could not be located in the dynamic link library
.
将 libstdc++-6.dll
从 mingw
文件夹复制到您的可执行文件目录中。或者,您可以将 libstdc++-6.dll
的路径添加到环境 PATH。
我对 C++ 比较陌生,我刚刚完成 codecademy.com
上的在线课程。所以我决定下载 MinGW 和 VScode 开始做一些练习。一切都很顺利,直到我 运行 遇到一个我无法修复的错误。
当我尝试 运行 我的可执行文件时出现此错误:
我将其输入 cmd
,未使用 makefile:
D:\>g++ main.cpp app.cpp
D:\>a.exe
我在命令行中使用 mingw (g++) 来编译我的代码,它在这里:
我的 main.cpp 文件:
#include <iostream>
#include "app.hpp"
int main (int argc, char* argv[]) {
App tomato(true);
std::cout << tomato.get_sauce();
tomato.~App();
return 0;
}
app.hpp:
// Define prototype functions here:
#ifndef APP_HPP
#define APP_HPP
class App {
public:
bool sauce;
App(bool set);
~App();
void set_sauce (bool set);
bool get_sauce ();
};
#endif
app.cpp:
#include "app.hpp"
#include <iostream>
App::App (bool set) {
sauce = set;
}
App::~App () {
std::cout << "goodbye";
}
void App::set_sauce (bool set) {
sauce = set;
}
bool App::get_sauce () {
return sauce;
}
一切都可以正常编译,但是一旦我 运行 可执行文件,我就会得到 The procedure entry point __gxx_personality_v0 could not be located in the dynamic link library
.
将 libstdc++-6.dll
从 mingw
文件夹复制到您的可执行文件目录中。或者,您可以将 libstdc++-6.dll
的路径添加到环境 PATH。