9

I've got a standard C library that compiles just fine on Mac OS X using gcc.

I've examined the C compilers available for Windows, and choose MinGW for a couple reasons:

  • MS's tools don't support C99
  • Cygwin et. al. adds an extra level of complexity with the posix emulation that I don't want
  • Can't get lcc-win32 to work

But, when I try to build my library, I'm getting this:

enter image description here

This stuff all seems very archaic, and there are practically no decent resources online that I can find.

Any help would be greatly appreciated.

Thanks.

EDIT:

It doesn't matter what I'm trying to build. Even if I just make a single file with a function that adds two numbers. It crashes. Doesn't seem to have anything to do with the source code or the options passed to gcc at all. I think this is a problem with my MinGW setup and not with my project.

Steve
  • 31,144
  • 19
  • 99
  • 122
  • This error is produced when you are building a DLL? – David Heffernan Aug 31 '11 at 19:36
  • It doesn't matter what I'm trying to build. Even if I just make a single file with a function that adds two numbers. It crashes. Doesn't seem to have anything to do with the source code or the options passed to gcc at all. – Steve Aug 31 '11 at 19:47
  • 1
    Clearly your mingw installation is borked. How did you install? – David Heffernan Aug 31 '11 at 19:48
  • I installed using the Automated (GUI) Installer. I followed the directions to a 'T'. Located here: http://www.mingw.org/wiki/Getting_Started – Steve Aug 31 '11 at 19:49
  • The last time I tried to use the official MinGW installer - which I'll admit was quite a while ago - I was left thoroughly confused. Unless it's progressed a lot since then (and maybe even if it has), I'd suggest using someone else's distribution. Nuwen's distribution is a simple unzip operation - http://nuwen.net/mingw.html And I've never used it, but I've heard good things about the TDM distribution: http://tdm-gcc.tdragon.net/start – Michael Burr Aug 31 '11 at 22:48
  • By the way, the `as.exe` I have in my MinGW installation is not dependent on libiconv-2.dll (or any other libiconv.dll). – Michael Burr Aug 31 '11 at 22:50
  • I gave up, and worked through my issues with LCC... which, despite a few things I'm wary about, seems to be doing what I need. – Steve Aug 31 '11 at 23:11

2 Answers2

27

Make sure you have C:\MinGW\bin in your path before any other directory that contains libiconv-2.dll. Apparently the as.exe in some MinGW distributions are dependent on that DLL, and having an older version of it in the path somewhere (for example GnuWin32 tools) will cause as.exe to pick up the older version that doesn't have the entry point it's looking for.

See: http://sourceforge.net/tracker/index.php?func=detail&aid=3375870&group_id=200665&atid=974439

Note - you should be able to replace the older libiconv-2.dll with the newer one in \MinGW\bin - the naming of the DLL should mean that it's backward compatible with the older one (ie., older software that isn't dependent ont he newer exports should continue to work). However, I haven't tested that so be sure to backup if you do decide to try replacing the conflicting DLL with the one from your MinGW installation.

Michael Burr
  • 333,147
  • 50
  • 533
  • 760
  • 2
    Interesting. I DO have GnuWin32 installed. Let me try this and get back to you. I also do have `C:\MinGW\bin` in my `PATH`, but it's *after* GnuWin32 I believe... so if there is a conflict with GnuWin32, I believe the system would be finding the GnuWin32 version *first*. This definitely seems like a plausible explanation of what's going wrong here. – Steve Aug 31 '11 at 23:15
  • Bingo. I wish I could give you more up votes. This was exactly the problem (conflict with GnuWin32). – Steve Sep 01 '11 at 18:58
  • Cheers chap. While investigating what was going on, I found that I could compile things if I called gcc while my current directory _was_ \mingw\bin. In that instance, as.exe was happy. But any other pwd and it was not. Thanks for this. I was looking at some sort of mismatched dll issue while building, not just that as.exe wasn't starting properly. Cheers. – RichColours Oct 24 '11 at 13:01
  • I just did a fresh install of MinGW on a machine that has never had a compiler on it before, and the file `libiconv-2.dll` is not anywhere on my system. I am completely incapable of using my installation. Does anyone else have this issue? I never had this issue before using the new installer+manager thing. – LB-- Oct 10 '13 at 05:53
  • OUTSTANDING ANSWER !! – thonnor Jan 21 '17 at 20:14
2

In addition to making sure C:\MinGW\bin is in your PATH before anything else, you should also restart your machine (or possibly log out/log in), to ensure your PATH is actually updated.

Dusten
  • 21
  • 1