Search code examples
cgcccompilationmingw

Use MinGW gcc command to link and compile the executable file, but there is no output when executing


I use the third-party library shapelib downloaded by vcpkg to write a program that reads shp files. The file is stored in the following location:

│  main.c
│  main.exe
│  shapefil.h
│
└─shapelib
    ├─include
    │      shapefil.h     
    │
    └─lib
            shp.lib

And then I use the command line to compile:

gcc main.c -I shapelib/include shapelib/lib/shp.lib -o main.exe

But when I run the excutable file, there is no output. I don't know the reason of this case.

enter image description here


Solution

  • There are some errors, which are not shown, when executing an application on the command line in windows. E.g. when an application could not find a DLL file, which is requried for running an application.

    Please try to execute your application using the windows explorer via double-click. In case DLL files are missing, multiple messages boxes will appear.

    If no errors are shown, try to open a new command line in windows (not within VS code) and try running your application in this window. (In case enviroment variables have change recently, these changes may not have been propagated to all applications. Reboot your PC to guarantee that all applications know the most recent set of enviroment variables).