How to build gnu `libiconv` on & for windows?

19,809

Solution 1

I'm the OP. MSYS is the exact thing what I was looking for.

Just install MinGW & MSYS which contains shell sh.exe & make.exewith which you can configure and generate a Makefile after that you can use make.exe to run it.

Its as simple as that.

Solution 2

I found PARK Youngho's How to Build libiconv with Microsoft Visual Studio over at The Code Project to be complete and clean (for VS2010 and GNU libiconv 1.14).

Solution 3

A little addition to your answer. I had the same issue and found that the MinGW + MSYS solution was perfect.

Though, I needed to go a little further and generate also the .lib file in order to be able to link with the resulting dll.

This is what I found:

  • generate a .def file from the dll with dumpbin (a Visual Studio tool).

  • generate the .lib file from the .def with the lib program (Visual Studio tool too)

This allows you to specify some link flags if appropriate. Everything detailed here (I'm not the author of this method): http://wiki.videolan.org/GenerateLibFromDll

I also realized that this lib/dll couple can be linked with both MD and MDd libraries.

Hope that can help people that find this post, like it helped me.

-David

Solution 4

compile them using MinGW using Msys for the environment if needed. MinGW's .a files are apparently, according to the mailing list, the same format as .lib files (just do a rename). You might want to check first to see if the iconv static library is included already in the MinGW download / filesystem.

Edit: it's in msys (C:\msys\1.0\lib), along with:

  • libiconv.a
  • libiconv.dll.a
  • libiconv.la

and additionally

  • libiconv-2.dll (in C:\msys\1.0\local\bin)

Edit: is it in here, the libiconv you need? these versions seem to have MSVC makefiles :) http://www.opensource.apple.com/source/libiconv/

Share:
19,809

Related videos on Youtube

claws
Author by

claws

Updated on April 20, 2022

Comments

  • claws
    claws about 2 years

    I want to build a static library (*.LIB file) GNU libiconv on windows to be used with other libraries in Visual C++. Other libraries I'm using are built with "MultiThreaded DLL" (/MD) Runtime option. So, I need to build libiconv with the same option.

    Problem is the libiconv uses GNU build system and I want to compile with /MD option. You can see the source structure of libiconv here:
    http://cvs.savannah.gnu.org/viewvc/libiconv/?root=libiconv

    Mr. Zlatkovic maintains the windows port of GNU libiconv for libxml2

    you can see them here:

    ftp://xmlsoft.org/libxml2/win32/iconv-1.9.2.win32.zip

    I cannot use his port. I need to build from the latest version of libiconv-1.13. I wonder how this guy has ported it? Can some one please tell me how to build *.lib from this and compile it using MSVC?

    EDIT:

    Actually, I need to build few more gnu libraries with same settings. So, if I get solution for one library. I can do the same for all others.

  • claws
    claws about 14 years
    but how would I run ./configure which is a shell script? More over, how would I give "MultiThreaded DLL" Runtime option to g++ compiler of MinGW.
  • Chris Dennett
    Chris Dennett about 14 years
    You might not face the same issue with the MinGW toolchain, which the developer is trying to avoid. Basically, the multithreaded option for the MSVC compiler / linker allows the DLL to use multiple heaps rather than a single heap, from a quick glance, and prevents problems from occuring.
  • claws
    claws about 14 years
    Well, I cannot use GNU tool chain for entire project. Because 1. I'm not that familiar with MinGW 2. I'm using MFC and 3. all other libraries are fine with MSVC & I got them compiled in MSVC. I just need a way to compile the gnu libs for windows. important question is how would ./configure execute to create makefile? Also I cannot use precompiled lib file for libiconv because If compile this myself. I'll use the same method to compile other required gnu libs.
  • claws
    claws about 14 years
    Thank you for providing alternate ways. But I need to know the way to do this because I need to build other GNU libs on MSVC with /MD
  • Chris Dennett
    Chris Dennett about 14 years
    Did you check out opensource.apple.com/source/libiconv to see if it had the version you need? The numbering seems a bit strange though.
  • Chris Dennett
    Chris Dennett about 14 years
    Also, try copying Makefile.msvc from an older version of libiconv to the newer version, and see if that works. I'll try and guide you through any problems. Use the last version that has Makefile.msvc in it before it was removed.
  • Chris Dennett
    Chris Dennett about 14 years
    Grab the MSVC files from here -- these are the dead files that were removed from CVS when msvc support was deprecated. Anything with thew tag "Remove MSVC/nmake build support.", I guess. cvs.savannah.gnu.org/viewvc/libiconv/…
  • claws
    claws about 14 years
    I don't think you understood what I'm trying to say. I don't want to take the method you are suggesting. Because I need to compile few more gnu libraries for which there are no Makefile.msvc. So please try to suggest me some other way.