dub
dub

Reputation: 21

c++ Getting error after compile

This is my main.cpp

#include <iostream>
#include <string>
#include "Tokenizer.h"
using namespace std;

int input;

int main(int argc, char const *argv[]){
    Tokenizer obj("yeet");
    cout << obj.getString();
    cin >> input;
return 0;
}

This is my Tokenizer.h

#ifndef TOKENIZER_H
#define TOKENIZER_H
#include <string>

class Tokenizer{
    public:
        Tokenizer(std::string m);
        std::string getString();
    protected:
    private:
        std::string token;
};

#endif // TOKENIZER_H

This is my Tokenizer.cpp

#include "Tokenizer.h"
#include <string>

Tokenizer::Tokenizer(std::string m){
    token=m;
   //code 
}

std::string Tokenizer::getString(){
    return token;
}

when i compile with g++ it works fine and when i open a.exe i get this error.

The procedure entry point _ZNSt7_cxx1112basic_stringlcSt11char_traitslcESalcEEC1EPKcRKS^_ could not be located in the dynamic link libary c:\"My project path"

(All files are in same folder.)

and i compiled with int without strings it worked fine i guess it is a error with #include <string>

Upvotes: 0

Views: 60

Answers (1)

yadhu
yadhu

Reputation: 1333

In Mingw You have to explicitly specify libgcc libstdc++ the libraries. Use the following command

g++ Tokenizer.cpp main.cpp -o main -static-libgcc -static-libstdc++

Upvotes: 2

Related Questions