在 Ubuntu 12.04 上运行,一个在 Windows 上的 MS Visual Studio 中用 c++11
Running on Ubuntu 12.04 a project written in c++11 in MS Visual Studio on Windows
我在Windows上的MS Visual Studio 2015中编写了一个项目(由几个cpp和h文件组成(,但我需要在Ubuntu上运行它。有什么办法可以做到这一点吗?我通过简单的智慧尝试 $ g++ -std=c++0x *.cpp
但我得到很多错误:
In file included from DataTable.cpp:1:0:
DataTable.h:9:14: sorry, unimplemented: non-static data member initializers
DataTable.h:9:14: error: in-class initialization of static data member ‘data’ of non-literal type
DataTable.cpp: In member function ‘void DataTable::printTable(std::ostream&)’:
DataTable.cpp:12:22: error: ‘data’ was not declared in this scope
DataTable.cpp: In member function ‘void DataTable::addData(std::string)’:
DataTable.cpp:22:8: error: ‘class DataTable’ has no member named ‘data’
In file included from ElfSymbol.h:7:0,
from ElfSymbol.cpp:1:
DataTable.h:9:14: sorry, unimplemented: non-static data member initializers
DataTable.h:9:14: error: in-class initialization of static data member ‘data’ of non-literal type
In file included from ElfSymbol.h:7:0,
from SymbolTable.h:6,
from LineParser.h:11,
from Instruction.h:5,
from Instruction.cpp:1:
DataTable.h:9:14: sorry, unimplemented: non-static data member initializers
DataTable.h:9:14: error: in-class initialization of static data member ‘data’ of non-literal type
In file included from Instruction.h:5:0,
from Instruction.cpp:1:
LineParser.h:27:7: error: use of enum ‘instructionStrings’ without previous declaration
LineParser.h:31:21: error: ‘instructionStrings’ was not declared in this scope
LineParser.h:31:39: error: template argument 2 is invalid
LineParser.h:31:39: error: template argument 4 is invalid
In file included from Instruction.cpp:1:0:
Instruction.h:18:14: sorry, unimplemented: non-static data member initializers
Instruction.h:18:14: error: in-class initialization of static data member ‘addr’ of non-literal type
Instruction.cpp: In member function ‘void Instruction::setAddr(std::string)’:
Instruction.cpp:59:2: error: ‘addr’ was not declared in this scope
Instruction.cpp: In member function ‘std::string Instruction::getAddr()’:
Instruction.cpp:64:9: error: ‘addr’ was not declared in this scope
Instruction.cpp: In member function ‘std::string Instruction::getDataString()’:
Instruction.cpp:130:15: error: ‘addr’ was not declared in this scope
Instruction.cpp:141:15: error: ‘addr’ was not declared in this scope
In file included from ElfSymbol.h:7:0,
from SymbolTable.h:6,
from LineParser.h:11,
from LineParser.cpp:1:
DataTable.h:9:14: sorry, unimplemented: non-static data member initializers
DataTable.h:9:14: error: in-class initialization of static data member ‘data’ of non-literal type
In file included from LineParser.h:12:0,
from LineParser.cpp:1:
Instruction.h:18:14: sorry, unimplemented: non-static data member initializers
Instruction.h:18:14: error: in-class initialization of static data member ‘addr’ of non-literal type
In file included from LineParser.cpp:1:0:
LineParser.h:27:7: error: use of enum ‘instructionStrings’ without previous declaration
LineParser.h:31:21: error: ‘instructionStrings’ was not declared in this scope
LineParser.h:31:39: error: template argument 2 is invalid
LineParser.h:31:39: error: template argument 4 is invalid
LineParser.cpp:7:13: error: ‘instructionStrings’ is not a member of ‘LineParser’
LineParser.cpp:7:13: error: ‘instructionStrings’ is not a member of ‘LineParser’
LineParser.cpp:7:43: error: template argument 2 is invalid
LineParser.cpp:7:43: error: template argument 4 is invalid
LineParser.cpp:7:71: error: invalid type in declaration before ‘;’ token
LineParser.cpp: In static member function ‘static bool LineParser::isInstruction(std::string, SymbolTable)’:
LineParser.cpp:412:14: error: ‘instructionStrings’ was not declared in this scope
LineParser.cpp:412:32: error: template argument 2 is invalid
LineParser.cpp:412:32: error: template argument 4 is invalid
LineParser.cpp:412:44: error: expected initializer before ‘it’
LineParser.cpp:413:6: error: ‘it’ was not declared in this scope
LineParser.cpp:413:27: error: request for member ‘end’ in ‘LineParser::instructionMap’, which is of non-class type ‘int’
LineParser.cpp: In static member function ‘static void LineParser::initializeInsMap()’:
LineParser.cpp:1622:26: error: ‘INT’ was not declared in this scope
LineParser.cpp:1623:26: error: ‘JMP’ was not declared in this scope
LineParser.cpp:1624:27: error: ‘CALL’ was not declared in this scope
LineParser.cpp:1625:26: error: ‘RET’ was not declared in this scope
LineParser.cpp:1626:25: error: ‘JZ’ was not declared in this scope
LineParser.cpp:1627:26: error: ‘JNZ’ was not declared in this scope
LineParser.cpp:1628:26: error: ‘JGZ’ was not declared in this scope
LineParser.cpp:1629:27: error: ‘JGEZ’ was not declared in this scope
LineParser.cpp:1630:26: error: ‘JLZ’ was not declared in this scope
LineParser.cpp:1631:27: error: ‘JLEZ’ was not declared in this scope
LineParser.cpp:1633:27: error: ‘LOAD’ was not declared in this scope
LineParser.cpp:1634:29: error: ‘LOADUB’ was not declared in this scope
LineParser.cpp:1635:29: error: ‘LOADSB’ was not declared in this scope
LineParser.cpp:1636:29: error: ‘LOADUW’ was not declared in this scope
LineParser.cpp:1637:29: error: ‘LOADSW’ was not declared in this scope
LineParser.cpp:1639:28: error: ‘STORE’ was not declared in this scope
LineParser.cpp:1640:29: error: ‘STOREB’ was not declared in this scope
LineParser.cpp:1641:29: error: ‘STOREW’ was not declared in this scope
LineParser.cpp:1643:27: error: ‘PUSH’ was not declared in this scope
LineParser.cpp:1644:26: error: ‘POP’ was not declared in this scope
LineParser.cpp:1646:26: error: ‘ADD’ was not declared in this scope
LineParser.cpp:1647:26: error: ‘SUB’ was not declared in this scope
LineParser.cpp:1648:26: error: ‘MUL’ was not declared in this scope
LineParser.cpp:1649:26: error: ‘DIV’ was not declared in this scope
LineParser.cpp:1650:26: error: ‘MOD’ was not declared in this scope
LineParser.cpp:1651:26: error: ‘AND’ was not declared in this scope
LineParser.cpp:1652:25: error: ‘OR’ was not declared in this scope
LineParser.cpp:1653:26: error: ‘XOR’ was not declared in this scope
LineParser.cpp:1654:26: error: ‘NOT’ was not declared in this scope
LineParser.cpp:1655:26: error: ‘ASL’ was not declared in this scope
LineParser.cpp:1656:26: error: ‘ASR’ was not declared in this scope
In file included from ElfSymbol.h:7:0,
from SymbolTable.h:6,
from main.cpp:9:
DataTable.h:9:14: sorry, unimplemented: non-static data member initializers
DataTable.h:9:14: error: in-class initialization of static data member ‘data’ of non-literal type
In file included from LineParser.h:12:0,
from SymbolTable.h:7,
from main.cpp:9:
Instruction.h:18:14: sorry, unimplemented: non-static data member initializers
Instruction.h:18:14: error: in-class initialization of static data member ‘addr’ of non-literal type
In file included from SymbolTable.h:7:0,
from main.cpp:9:
LineParser.h:27:7: error: use of enum ‘instructionStrings’ without previous declaration
LineParser.h:31:21: error: ‘instructionStrings’ was not declared in this scope
LineParser.h:31:39: error: template argument 2 is invalid
LineParser.h:31:39: error: template argument 4 is invalid
In file included from ElfSymbol.h:7:0,
from SymbolTable.h:6,
from SymbolTable.cpp:1:
DataTable.h:9:14: sorry, unimplemented: non-static data member initializers
DataTable.h:9:14: error: in-class initialization of static data member ‘data’ of non-literal type
In file included from LineParser.h:12:0,
from SymbolTable.h:7,
from SymbolTable.cpp:1:
Instruction.h:18:14: sorry, unimplemented: non-static data member initializers
Instruction.h:18:14: error: in-class initialization of static data member ‘addr’ of non-literal type
In file included from SymbolTable.h:7:0,
from SymbolTable.cpp:1:
LineParser.h:27:7: error: use of enum ‘instructionStrings’ without previous declaration
LineParser.h:31:21: error: ‘instructionStrings’ was not declared in this scope
LineParser.h:31:39: error: template argument 2 is invalid
LineParser.h:31:39: error: template argument 4 is invalid
但是这一切都在VS上没有出错。
Ubuntu 12.04 附带 GCC 4.6.3。 这个非常旧的版本没有实现某些 C++11 功能。 您可以在 GCC 4.6 中了解 C++0x 支持中可用的功能。 从这个列表中可以看到,»非静态数据成员初始值设定项«根本没有实现,这正是编译器告诉您的。
最好使用更新的编译器(GCC ≥ 4.8.1(,或者更好的是,更新您的操作系统! 否则,此问题应迁移到 https://retrocomputing.stackexchange.com/
相关文章:
- 在VS代码中交叉编译Windows与Linux上的MinGW的SDL程序
- 如何加载(或映射)文件部分的最大大小,但适合在Windows上的RAM
- 为什么在Windows上的VS 2019和Clang 9中"size_t"在没有标题的情况下工作
- 在Linux和C++中的Windows上,散列字符串值会产生不同的输出
- 如何在"SUBSYSTEM:WINDOWS"下显示并输出到Windows(C++ WinApi)上的
- CMake 在 Windows 上的自定义位置上找不到 Boost
- 命名空间 pqxx 无法识别 - 将 libpqxx 添加到 Windows 上的 Visual Studio Post
- 在 Julia 中使用 boost 库和 Windows 上的 Cxx.jl
- 如何链接 DLL 以供 LoadLibrary() 使用(在 Windows 上的 C++ 中)并从调用 exe 导入变
- 清理"QSettings"注册表项的最佳方法(Windows上的Qt 5)
- Visual Studio 2019上的Windows过滤平台API
- Linux 上的 Windows 交叉编译
- Nvidia TX2上的Windows应用程序
- 使用MSVC 2015上的Windows上使用Google测试
- 如何从Windows上的Windows API上的另一个应用程序获得应用程序宽度和高度
- 不会进入控制台应用程序上的 Windows GetMessage 循环
- 从 Linux 上的 Windows 编译 OpenGL 应用程序
- 在 C++ 文件上的 Windows 环境中运行 Unix 类似命令"./a.out <data.txt"
- 在KeyDow上的Windows商店应用程序OEM密钥
- Qt GUI应用程序与控制台输出-隐藏控制台正常启动上的Windows