c++windowsdllmingw32

Mingw32 compilation not running C++ program but Mingw64 works fine


I work on Windows 10 x64, I have install mingw64 and mingw32. I wrote a C++ program:

#include <stdio.h>
#include <stdlib.h>

extern "C" {
#include <windows.h>

#include <libavcodec/avcodec.h>
#include <libavdevice/avdevice.h>
#include <libavformat/avformat.h>
#include <libavformat/avio.h>
#include <libavutil/audio_fifo.h>
#include <libavutil/imgutils.h>
#include <libavutil/opt.h>
#include <libavutil/frame.h>
#include <libavutil/time.h>
#include <libavutil/timestamp.h>
#include <libavutil/macros.h>
#include <libavfilter/avfilter.h>
#include <libavfilter/buffersink.h>
#include <libavfilter/buffersrc.h>
#include <libswresample/swresample.h>
#include <libswscale/swscale.h>

}

int main(int argc, char** argv) 
{

    printf("hello world\n");

    avformat_network_init();
    avdevice_register_all();

    return 0;
}

When I in mingw64 use G++ compile these code, it runs fine. but in mingw32, I use same command to compile, it cannot run, cannot even print hello world. I use the command:

g++ -g t.cpp -lavformt -lavdevice

Solution

  • Thank you for all the answers regarding the issue I raised earlier. I have figured out the cause of the problem. The 32-bit ffmpeg library I am using was installed as a package under the mingw32 environment. However, these libraries did not include all the dependencies they rely on in the dll file. As a result, the program crashes when it cannot find the necessary dependencies. These libraries depend on more than forty other dll files, and finding all of them will take considerable time.I used the Process Monitor tool provided by Microsoft to see which DLL files were called when running the EXE file.