4

I have written a long program in C, so I am not writing the whole code. These are the libraries I a using (in case it matters)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <windows.h>
#include <time.h>
#include <sys/types.h>
#include <dirent.h>
#include "xlsxwriter.h"

The program runs perfectly on my Windows computer, and in my work computer as well where I have the same programs.

But when I am running in on a colleagues computer this error appears:

System error:
The program can't start because msys-2.0.dll is missing from your computer.
Try reinstalling the program to fix this problem.

Is there some way to make it work without installing the whole visual studio?

Rookie C programmer here!:)

Edit: I am compiling like this:

gcc Example.c -o Example -static-libgcc -std=c99 -lxlsxwriter -lz
CameFromSpace
  • 55
  • 2
  • 8
  • How exactly are you compiling your program? The `mingw` tag suggests that you are using MinGW, but you should give the compiling command in the question. So please **edit your question** to improve it. – Basile Starynkevitch Jul 17 '17 at 12:47
  • 1
    You're building your program using msys, not MinGW. If you want the executables to run, you will need to copy the missing DLL (which will be available in an msys distribution you are using to build) along with your executable. You would be better off building using the MinGW toolchain (without msys), but note that any usage of unix API functions - which msys emulates - will probably not compile. – Peter Jul 17 '17 at 12:52
  • I thought of that. I found the dll in my computer in:"C:\Windows\System32" and in "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\Git\usr\bin" as well, which implicates also visual studio, but I am thinking to make this destination and put the dll there, but I am not very sure if that is gonna be sufficient and I do not have a computer without any C developing tool to test it right now. The libxlsxwriter library requires MSYS2 so cannot skip it – CameFromSpace Jul 17 '17 at 13:17
  • @Peter I tried copying the msys-2.0.dll but it still doesn't work. Is there some other way that you are suggesting? Is it some other dll and where can I find it? – CameFromSpace Jul 18 '17 at 11:07
  • Either copy the DLL to the same directory as your executable, or to \Windows\System32 (assuming 32 bit windows) or \Windows\SysWOW64 (assuming 64-bit windows). Those are the default places windows will search for the DLL. A Visual Studio directory will not be searched, unless you have installed Visual Studio (simply creating the directory is not enough, since windows won't search there by default). – Peter Jul 18 '17 at 13:29
  • I have tried copying the dll in the same directory as the executable, as well as at system32. Nothing worked, except installing MSYS2. It seems that MSYS2 is only a requirement because of xlsxwriter. I changed my code to export in CSV format so I didn't have to use the library and install MSYS2 – CameFromSpace Jul 28 '17 at 01:20

2 Answers2

3

MSYS is probably a MinGW related runtime library (perhaps its C standard library).

You need to install it on any Windows computer executing a binary compiled with MinGW.

See also this question.

You may want to ask your colleagues to install MSYS2.

Perhaps consider also building a statically linked executable (so compile and link with -static passed to GCC).

(this is only an educated guess; I never used Windows)

Basile Starynkevitch
  • 1
  • 16
  • 251
  • 479
  • 1
    As we are gonna release that program in the company's procedures, we want to make it as "little installation" as possible and MSYS2 will open another circle of requirements :( – CameFromSpace Jul 17 '17 at 13:20
  • This is not true at all, Why are you posting an educated guessm the entire point of msys is that you dont need to install it on the user – Ray Wu Apr 17 '21 at 18:02
3

You need to build your program with the MinGW compiler, not the MSYS compiler.

See this answer for details.

ulatekh
  • 929
  • 9
  • 16