mardi 10 octobre 2017

g++ compiles c++ script with #include-statements to .exe-file which fails to run

I have the following script in C++:

#include <iostream>
#include <vector>

using namespace std;

int main() {
    vector <string> markus = { "M", "A", "R", "K", "U", "S" };
    for (int i = 0; i < markus.size();i++) {
        cout << markus[i];
     }

     return 0;
}

I have successfully installed g++. When I try compiling this code with the command g++ -o test test.cpp, I get no errors. However, when I try running the created test.exe-file, with the command test, I get an error saying "could not find starting point". First, there is a long sequence, then the following message; "The starting point for the procedure could not be found in the library for dynamical links", and the the absolute path for test.exe.

If I remove #include <vector>, and try the following code;

#include <iostream>

using namespace std;

int main() {
    cout  << "Hello world";
    return 0;
}

, it works perfect.

I would be glad for the help.

Aucun commentaire:

Enregistrer un commentaire