Why does my program run fine on Windows but not linux?

I've tried compiling the following program in a Linux Mint Cinnamon VM and get many errors, yet it runs perfectly fine on Windows.The command I'm using is gcc Main.cpp -o Main #include "Main.h" #include <fstream> #include <iostream> #include <string> #include <vector> using namespace std; int Main::count = 0; string festival = ""; std::vector<string> v; M

为什么我的程序在Windows上运行正常,但不是Linux?

我试过在Linux Mint Cinnamon虚拟机中编译下面的程序,并得到很多错误,但它在Windows上运行得非常好。我使用的命令是gcc Main.cpp -o Main #include "Main.h" #include <fstream> #include <iostream> #include <string> #include <vector> using namespace std; int Main::count = 0; string festival = ""; std::vector<string> v; Main::Main() { } Main::~Main() { } int main() { Ma

Platform Independence with C++. Detection and Compilation

So i'd like to build my application to be Platform Independent such that it can run on Windows, OSX, Linux etc. For example one of the main "parts" that is different across the platforms is a Window. On Windows it would use the Win32 API and on OSX, Linux I guess it would use something else. I have an IWindow.h class which is an interface for interacting with a Window and a MSW

平台独立与C ++。 检测和编译

所以我想建立我的应用程序,使其成为独立平台,以便它可以在Windows,OSX,Linux等上运行。 例如,跨平台不同的主要“部分”之一是窗口。 在Windows上它将使用Win32 API,并且在OSX上,Linux我想它会使用别的东西。 我有一个IWindow.h类,它是一个与Window交互的接口和一个封装所有Win32函数并扩展IWindow接口的MSWindow类。 将来我会创建一个OSXWindow类等等 所以我的两个问题是: 在某些时候,我需要检测我正在运行的

Ogre3D shows segfault error

I'm writing a game using Ogre3D and I have a problem. When I starting program, it shows an segfault error: *-*-* OGRE Initialising *-*-* Version

Ogre3D显示段错误

我正在使用Ogre3D编写游戏,并且遇到问题。 当我启动程序时,它显示一个段错误: *-*-* OGRE Initialising *-*-* Version 1.7.2 (Cthugha)

Circular inclusion issue with extended class c++

Can you figure out how to solve this circular inclusion problem? C extends B and B includes A. A includes C. Every forward declaration I tried hasn't worked. Errors Error 1 error C2504: 'B' : base class undefined Error 2 error C3668: 'C::c' : method with override specifier 'override' did not override any base class methods File Ah: #pragma once #include "C.h"

循环包含问题与扩展类c ++

你能想出如何解决这个循环包含问题吗? C延伸B和B包括A. A包括C.我试过的每个前向声明都没有奏效。 错误 错误1错误C2504:'B':基类未定义错误2错误C3668:'C :: c':带覆盖说明符'override'的方法未覆盖任何基类方法 档案啊: #pragma once #include "C.h" struct A { A(); C c; }; 文件Bh: #pragma once #include "A.h" struct A; struct B { virtual void c() = 0;

C++ error Undefined reference to Class::Function()

I am farily new to C++ and I have been stuck with this problem for a few hours now. I am trying to setup the foundations for a video game related experience calculator, but I can't get past this problem. main.cpp #include <iostream> #include "Log.h" using namespace std; int main() { Log Logs; enter code here struct ChoppableLog Yew; Logs.initialiseLog(Yew, 60, 175

C ++错误对Class :: Function()的未定义引用

我对C ++很陌生,现在我一直坚持这个问题几个小时。 我正在设置一个视频游戏相关体验计算器的基础,但我无法解决这个问题。 main.cpp中 #include <iostream> #include "Log.h" using namespace std; int main() { Log Logs; enter code here struct ChoppableLog Yew; Logs.initialiseLog(Yew, 60, 175); return 0; } Log.h #ifndef LOG_H #define LOG_H struct ChoppableLog { int leve

c++ Compile error

Possible Duplicate: Undefined symbols for architecture i386: using namespace std; #include <iostream> #include <fstream> #include <string> #include "CorpusExp.h" int main(int argc, char* argv[]){ ifstream infile("../DATA.txt"); string train_dir; // The training data directory infile>>train_dir; train_dir=train_dir.substr(6,train_dir.length()); if (argc>1){ if

编译错误

可能重复: 架构i386的未定义符号: using namespace std; #include <iostream> #include <fstream> #include <string> #include "CorpusExp.h" int main(int argc, char* argv[]){ ifstream infile("../DATA.txt"); string train_dir; // The training data directory infile>>train_dir; train_dir=train_dir.substr(6,train_dir.length()); if (argc>1){ if (strcmp(argv[1],"-s")){ //

"Base class undefined."

I've got an error: error C2504: 'employee' : base class undefined. I'm using Visual Studio 2010. This is my first time working with inheritance in C++ and I can't figure out what I'm doing wrong. When I try to make a class that derives another, it says that the parent class is undefined, even though I have the header file of the parent class included. What could be

“基类未定义。”

我有一个错误: 错误C2504:'employee':基类未定义。 我正在使用Visual Studio 2010。 这是我第一次使用C ++继承,我无法弄清楚我做错了什么。 当我尝试创建一个派生另一个类的类时,它说父类是未定义的,即使我已经包含父类的头文件。 可能是什么问题呢? Main.cpp的: #include <string> #include <iostream> using namespace std; #include "manager.h" int main() { manager ian; ian.getd

Visual C++: 'streambuf' base class undefined

C:Program Files (x86)Microsoft Visual Studio 9.0VCincludestrstream(19) : error C2504: 'streambuf' : base class undefined I'm getting the above error and a 100 other compile errors. Why would this happen? In the editor if I right click the symbol streambuf and go to declaration it leads to the header file c:Program Files (x86)Microsoft Visual Studio 9.0VCincludeiosfwd and shows the

Visual C ++:'streambuf'基类未定义

C: Program Files(x86) Microsoft Visual Studio 9.0 VC include strstream(19):error C2504:'streambuf':base class undefined 我收到上述错误和其他100个编译错误。 为什么会发生? 在编辑器中,如果我右键单击符号streambuf并转到声明,它会导致头文件c:Program Files (x86)Microsoft Visual Studio 9.0VCincludeiosfwd并显示声明 typedef basic_streambuf <char, char_traits<char> > st

How do I forward declare an inner class?

Possible Duplicate: Forward declaration of nested types/classes in C++ I have a class like so... class Container { public: class Iterator { ... }; ... }; Elsewhere, I want to pass a Container::Iterator by reference, but I don't want to include the header file. If I try to forward declare the class, I get compile errors. class Container::Iterator; class Foo {

我如何转发声明一个内部类?

可能重复: C ++中嵌套类型/类的前向声明 我有这样的班级... class Container { public: class Iterator { ... }; ... }; 在其他地方,我想通过引用传递一个Container :: Iterator,但我不想包含头文件。 如果我尝试转发声明该类,则会出现编译错误。 class Container::Iterator; class Foo { void Read(Container::Iterator& it); }; 编译上面的代码给出... test.h:3: error: ‘Iterator

Access violation in winhttp.dll

I'm trying to perform an HTTP GET using WinHTTP in C++, but it's crashing at some point after resolving the name (after getting the WINHTTP_CALLBACK_STATUS_NAME_RESOLVED in the status callback function). I'm getting an access violation in winhttp.dll. The callstack is: winhttp.dll!HTTP_USER_REQUEST::_IndicateSocketAddress() + 0x221ed bytes winhttp.dll!HTTP_USER_REQUEST::OnDnsNam

在winhttp.dll中访问冲突

我试图在C ++中使用WinHTTP执行HTTP GET,但是在解析名称(在状态回调函数中获得WINHTTP_CALLBACK_STATUS_NAME_RESOLVED之后)的某个时刻它会崩溃。 我在winhttp.dll中遇到访问冲突。 这个callstack是: winhttp.dll!HTTP_USER_REQUEST :: _ IndicateSocketAddress()+ 0x221ed字节 winhttp.dll!HTTP_USER_REQUEST :: OnDnsNameResolved()+ 0x24字节 winio.dll!WEBIO_REQUEST :: _ OnInformation()+ 0x1c0c byte