0

I have written a project (consisting of several cpp and h files) in MS Visual Studio 2015 on Windows but I need to run it on Ubuntu. Is there any way I can do this? I tried by simply witting $ g++ -std=c++0x *.cpp but I get a lot of errors:

    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

But it all worked without an error on VS.

tokyo
  • 328
  • 4
  • 12
  • We can't help you with errors alone; we'd need to see some code where you're getting the errors. It seems many of your errors are similar though – kmdreko May 27 '17 at 05:08
  • what version of g++? – kmdreko May 27 '17 at 05:09
  • 1
    Ubuntu 12.04 sounds like model 2012, so its default compiler might not implement what other compilers had in 2015. – Bo Persson May 27 '17 at 05:10
  • 1
    You may want to check https://stackoverflow.com/questions/31215971/non-trivial-designated-initializers-not-supported – xvan May 27 '17 at 05:15
  • 1
    `sorry, unimplemented` means you need a newer version of `g++` – Ben Voigt May 27 '17 at 05:21
  • Thanks a lot for your help! I am very new to Ubuntu and this is the version that my project has to work on. What version of g++ should I install? I tried with 4.7 and it has some improvements but it still has errors. – tokyo May 27 '17 at 05:30

1 Answers1

1

Ubuntu 12.04 ships with GCC 4.6.3. This very old version does not implement some C++11 features. You can find out which features are available on C++0x Support in GCC 4.6. As you can see from this list »Non-static data member initializers« is simply not implemented, which is exactly what the compiler is telling you.

Better use a more recent compiler (GCC ≥ 4.8.1), or even better, update your OS! Otherwise this question should be migrated to https://retrocomputing.stackexchange.com/

Henri Menke
  • 10,705
  • 1
  • 24
  • 42
  • I do not have an option of updating OS but i could update g++. What version do you suggest? – tokyo May 27 '17 at 05:31
  • @tokyo It is in my answer. At least version 4.8.1, but if you can, take the latest which is 7.1. – Henri Menke May 27 '17 at 05:37
  • @tokyo There is also a [PPA for GCC](https://launchpad.net/~ubuntu-toolchain-r/+archive/ubuntu/test) if you do not want to compile from source. – Henri Menke May 27 '17 at 05:38
  • Ok! I just updated to 5.4.1.. Now I only get some enum errors which I will try to solve.. If I fail I will try the newest version of g++! Thank you! – tokyo May 27 '17 at 05:38
  • Ermm, don't know what that is but I will look into it! Thanks! – tokyo May 27 '17 at 05:39