在使用mingw g ++编译后运行c ++ .exe文件时找不到入口点错误 [英] Entry Point Not Found Error on running c++ .exe file after compiling with mingw g++

查看:345
本文介绍了在使用mingw g ++编译后运行c ++ .exe文件时找不到入口点错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用最新的MinGW在Windows 10上通过g ++编译器编译我的c ++代码.代码编译没有错误,但是当我运行执行文件时,它给出了错误消息:The procedure entry point _ZNSt6chrono3_V212system_clock3nowEv could not be located in the dynamic link library A:\Code\DAA Assignments\2\outputunsorted1.exe令人困惑的部分是,同一代码可以运行使用cygwin编译时完全可以,但仅在MinGW中会出现此错误.我还尝试了多次重新安装MinGW.我检查了MinGW文件夹,它确实具有chrono库,所以为什么它找不到入口点.另一个奇怪的是,错误的结尾显示在动态链接库A:\ Code \ DAA Assignments \ 2 \ outputunsorted1.exe中",这是我的执行文件的地址,那么为什么程序将其称为库? 我的cpp代码:

I am using the latest MinGW to compile my c++ code with g++ compiler on Windows 10. The code compiles without errors but when I run the execution file it gives the error: The procedure entry point _ZNSt6chrono3_V212system_clock3nowEv could not be located in the dynamic link library A:\Code\DAA Assignments\2\outputunsorted1.exe The confusing part is that the same code runs totally fine when compiled with cygwin but gives this error only in MinGW. I also tried reinstalling MinGW multiple times. I checked the MinGW folder, it does have the chrono library, so why is it not finding the entry point. Another weird thing is that the end of the error says "in dynamic link library A:\Code\DAA Assignments\2\outputunsorted1.exe" which is the address of my execution file, so why is the program referring to it as library? My cpp code:

#include<iostream>
#include<fstream>
#include<chrono>
#include"quicksort.cpp"

using namespace std;



int main()
{
    ifstream inp_file;
    ofstream out_file;
    ofstream time_file;

    //First file
    int *arr1 = new int[100000];
    int *arr2 = new int[100000];
    //Iterative quick sort
    inp_file.open("file1.txt");

    for(int i=0;i<100000 ;i++)
    {
        inp_file>>arr1[i];
        inp_file>>arr2[i];

    }
    inp_file.close();
    out_file.open("iterative_quick_sorted_file1.txt");
    auto start = chrono::high_resolution_clock::now();
    iterQuicksort(arr1,0,99999);
    auto elapsed = chrono::high_resolution_clock::now() - start;
    double microseconds = (double)chrono::duration_cast<chrono::microseconds>(elapsed).count()/1000;
    time_file.open("unsorted_iterative_quick_sort_time1.txt");
    time_file<<microseconds;
    time_file.close();
    for(int i=0;i<100000;i++)
    {
        out_file<<arr1[i]<<"\r\n";
    }
    out_file.close();

    //Recursive quick sort
    out_file.open("recursive_quick_sorted_file1.txt");
    start = chrono::high_resolution_clock::now();
    recQuicksort(arr2,0,99999);
    elapsed = chrono::high_resolution_clock::now() - start;
    microseconds = (double)chrono::duration_cast<chrono::microseconds>(elapsed).count()/1000;
    time_file.open("unsorted_recursive_sort_time1.txt");
    time_file<<microseconds;
    time_file.close();
    for(int i=0;i<100000;i++)
    {
        out_file<<arr2[i]<<"\r\n";
    }
    out_file.close();

    return 0;
}  

quicksort.cpp:

quicksort.cpp :

void swap(int *a,int *b)
{
    int temp = *a;
    *a = *b;
    *b = temp;
}

int partition (int *arr, int low, int high) 
{ 
    int pivot = arr[high];    // pivot 
    int i = (low - 1);  // Index of smaller element 

    for (int j = low; j <= high- 1; j++) 
    { 
        // If current element is smaller than or 
        // equal to pivot 
        if (arr[j] <= pivot) 
        { 
            i++;    // increment index of smaller element 
            swap(&arr[i], &arr[j]); 
        } 
    } 
    swap(&arr[i + 1], &arr[high]); 
    return (i + 1); 
} 

void iterQuicksort(int *arr,int l, int h)
{ 

    int *stack = new int[h - l + 1]; 


    int top = -1; 


    stack[++top] = l; 
    stack[++top] = h; 


    while (top >= 0) { 

        h = stack[top--]; 
        l = stack[top--]; 


        int p = partition(arr, l, h); 


        if (p - 1 > l) { 
            stack[++top] = l; 
            stack[++top] = p - 1; 
        } 


        if (p + 1 < h) { 
            stack[++top] = p + 1; 
            stack[++top] = h; 
        } 
    } 
} 

void recQuicksort(int *arr,int l,int h)
{
    if(l<h)
    {
        int pivot =  partition(arr,l,h);
        recQuicksort(arr,l,pivot-1);
        recQuicksort(arr,pivot+1,h);
    }
}

用于编译的命令:

g++ outputunsorted1.cpp -o outputunsorted1

推荐答案

问题出在libstd ++ 6.dll.它是通过在g ++中使用参数-static-libstdc++来解决的. MinGW正在从Windows中获取libstd ++ 6.dll,而不是MinGW中的libstd ++ 6.dll.

The problem was with libstd++6.dll. It was solved by using the argument -static-libstdc++ in g++. MinGW was taking libstd++6.dll from Windows instead of the one in MinGW.

这篇关于在使用mingw g ++编译后运行c ++ .exe文件时找不到入口点错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆