LinkShare rotating banner
Showing posts with label mingw. Show all posts
Showing posts with label mingw. Show all posts

Thursday, September 20, 2012

Compile Aria2 1.15.2 with MinGW

Aria2 is a command-line download utility. It can be used to download files quickly from http(s), ftp, bittorrent, magnet and metalink locations. I prefer this handy tool over other programs, such as Free Download Manager and Frostwire because it's lean, fast and full of features. It took me a couple of days to compile Aria2 with all the features available. The following step-by-step guide will help you build your own aria2 program (aria2c.exe) the way I did.







  1. Install MinGW

    Follow one of the following guides to install MingW:




  2. POSIX Threads

    Download the source for Pthreads library (pthreads-w32-2-9-1-release.tar.gz) and compile it like this:


    make clean GC-static
    cp pthread.h semaphore.h sched.h /mingw/include/
    cp libpthreadGC2.a /mingw/lib/libpthread.a


  3. zlib

    Zlib is needed by the OpenSSL library below. Download the zlib source and compile it like this:


    make -f win32/Makefile.gcc
    make -f win32/Makefile.gcc install BINARY_PATH=/mingw/bin INCLUDE_PATH=/mingw/include LIBRARY_PATH=/mingw/lib


  4. OpenSSL

    Aria2 requires either GnuTLS or OpenSSL for secure transfers. In this guide, OpenSSL is chosen over GnuTLS. Use 7-zip to unpack the tarball because it contains symbolic links.


    ./Configure -DHAVE_STRUCT_TIMESPEC -DPTW32_STATIC_LIB -L/mingw/lib -lz -lpthread -lws2_32 --prefix=/mingw threads zlib mingw
    make
    make install


  5. Expat


    Aria2 can use either LibXML2 or Expat for XML parsing. In this guide, Expat will be used. Download the expat source and compile expat like this:


    ./configure --build=i686-w64-mingw32 --prefix=/mingw --disable-shared --enable-static
    make
    make install


  6. C-Ares


    C-Ares is a C library that performs DNS requests and resolves DNS names asynchronously. Download the C-ares source from c-ares.haxx.se and unpack it. Then, compile C-Ares as follows:


    ./configure --build=i686-w64-mingw32 --prefix=/mingw --disable-shared CPPFLAGS='-I/mingw/include -DCARES_STATICLIB'
    make
    make install


  7. SQLite 3


    Download the SQLite source (sqlite-amalgamation-3071300.zip) and build SQLite 3:


    gcc -O2 -DNDEBUG=1 -DTHREADSAFE=1 -c *.c
    ar ru /mingw/lib/libsqlite3.a sqlite3.o
    cp -iv *.h /mingw/include

    Create sqlite3.pc and put it in /mingw/lib/pkgconfig.


    prefix=/mingw
    exec_prefix=${prefix}
    libdir=${exec_prefix}/lib
    includedir=${prefix}/include

    Name: SQLite
    Description: SQL database engine
    Version: 3.5

    Libs: -L${libdir} -lsqlite3
    Cflags: -I${includedir}


  8. aria2c


    Finally, we are ready to compile Aria2. Download the Aria2 source from aria2.sf.net and unpack the source. Then, configure aria2 as follows:


    ./configure --build=i686-w64-mingw32 --prefix=/mingw --enable-threads=posix --with-ca-bundle=ca-bundle.crt --disable-nls LIBS='-lpthread -lws2_32 -lcares -lz' CPPFLAGS='-DPTW32_STATIC_LIB -DCARES_STATICLIB'


    aria2_config

    Then, issue the following commands to compile Aria2:


    make
    make install


  9. Optionally, strip and compress the executable aria2c.exe.

    strip aria2c.exe
    upx --best --strip-relocs=0 aria2c.exe



To download my Windows builds of aria2, go here.



Aria2c Usage


aria2c --file-allocation=prealloc ftp://192.168.1.64/pardus.iso

If aria2 aborts a download due to a connection error, you can resume the download any time using aria2c like this:


aria2c -c ftp://192.168.1.64/pardus.iso

To download files from URL's written in a file urls.txt to a folder Downloads, run aria2 as follows. The urls.txt should contain one download per line with URL's seperated by a tab:


aria2c -i urls.txt -d Downloads

Thursday, September 13, 2012

Compile xz for Windows using MinGW

xz is the new popular compression format. To build xz tools and libraries, I issued the following commands.



./configure --prefix=/mingw --disable-shared --disable-nls --disable-lzma-links --disable-scripts
make
make install


I got the following files:



lzmadec.exe
lzmainfo.exe
unxz.exe
xz.exe
xzcat.exe
xzdec.exe


Note that xz can be used to create and decompress lzma files also.

Saturday, September 8, 2012

Building MPlayer and Mencoder for Windows

MPlayer logo

MPlayer is one of my favorite media players. It is used with a frontend like smplayer, gnome-mplayer and MPlayerGUI to provide a good alternative to Windows Media Player. Although there are already several Win32 builds of MPlayer on the net, I like to build MPlayer on my own using MinGW compiler because I want to optimize my build for my CPU. So I installed MinGW and compiled MPlayer as follows.





  1. Build ffmpeg statically or dynamically as shown in this post.



  2. (Optional) Compile the lzo library:

    ./configure --prefix=/mingw && make && make install


  3. (Optional) Fribidi is a rendering library for right-to-left scripts, such as Arabic and Hebrew. If you are a speaker of such right-to-left languages, compile fribidi statically as shown below:


    ./configure --prefix=/mingw --disable-shared --disable-debug
    make
    make install

    More information can be found here.



  4. Download JPEG source from ijg.org and complie JPEG:

    ./configure --prefix=/mingw --enable-static
    make
    make install


  5. Compile libPNG:

    ./configure --prefix=/mingw --disable-shared
    make
    make install


  6. Compile libiconv, Freetype, expat and fontconfig statically in that order:

    ./configure --prefix=/mingw --disable-shared
    make install


  7. Compile libdca:

    ./configure --prefix=/mingw
    make
    make install


  8. (Optional) Download DirectX headers from any of the following locations and unpack them in /mingw/include:



  9. Download the latest mplayer source (mplayer-export-snapshot.tar.bz2) and unpack it. (patch 1 and patch 2)

    tar xjvf mplayer-export-snapshot.tar.bz2
    cd mplayer-export-2010-02-07/

    Then, run ./configure:


    CPPFLAGS='-DFRIBIDI_ENTRY="" ' ./configure --prefix=/mingw --enable-runtime-cpudetection --enable-static --enable-theora --enable-fribidi --disable-ffmpeg_a --disable-gl --disable-vidix --yasm=/mingw/bin/yasm --extra-libs='-lfribidi'

    The CPPFLAGS value allows fribidi to be linked statically.



  10. Build Mplayer:

    make


    After successful build, strip the executables:


    strip m*.exe


    Optionally, compress the executables with upx:


    upx --best --strip-relocs=0 mplayer.exe
    upx --best --strip-relocs=0 mencoder.exe


  11. Download MPlayer codecs from here. The MPlayer codecs for Windows platform has a filename like windows-essential-20071007.zip. Extract the codecs package and you'll get a folder "windows-essential-20071007". Rename it as "codecs" and move the "codecs" folder inside where mplayer.exe file is located.



  12. Make sure that HOME environment variable is set to your personal folder(for example, C:\Users\Jocelyn). Upon the first run of mplayer, a new folder named mplayer will be created in your HOME folder. Copy codecs.conf to the mplayer folder. The "config" file stores default options for playing movie files. Open the "config" file and make changes as follows:


    # Write your default config options here!
    cdrom-device=D:
    dvd-device=D:
    ao=dsound
    vo=direct3d
    font=C:\WINDOWS\FONTS\MALGUN.TTF
    framedrop=yes
    subcp=cp949



My win32 build of mplayer can be downloaded from here. It is recommended that the zip archive should be extracted in C:\Program Files.



Running MPlayer


Now, let's try mplayer. First, get a movie file ready. In the Command Prompt, type a command in the following form:



mplayer mymoviefile.avi


Alternatively,



mplayer -vo direct3d -ao win32 -font C:\WINDOWS\FONTS\Tahoma.ttf -framedrop mymoviefile.avi


A new window will pop up with the movie playing inside it.



The next step is to get and set up SMPlayer.

Wednesday, September 5, 2012

To Compile ffmpeg with MinGW

ffmpeg is an important component of many open-source projects, such as MPlayer and VLC. I am compiling ffmpeg so that I can use it to transcode multimedia files. This guide shows how to use MinGW to compile ffmpeg either statically or dynamically. Installation of MinGW is explained in this post. The example commands below are meant to be entered into an MSYS window (not Command Prompt). I downloaded the FFmpeg source and unpacked it.



Preparing External Libraries for FFMpeg


FFMpeg can be linked with external libraries to add features to FFmpeg. I am adding most features to FFMpeg by compiling additional libraries. Most of these libraries are also covered in my posts on compiling MPlayer and Mencoder.




  1. Compression Libraries: Zlib and bzLib

    Get the zlib source (zlib127.zip), unzip and compile it:

    unzip zlib127.zip
    cd zlib-1.2.7/
    make -f win32/Makefile.gcc
    cp -iv zlib1.dll /mingw/bin
    cp -iv zconf.h zlib.h /mingw/include
    cp -iv libz.a /mingw/lib
    cp -iv libz.dll.a /mingw/lib


    Optionally, get bzip2 source from bzip.org and compile it like this:


    tar xzvf bzip2-1.0.6.tar.gz
    cd bzip2-1.0.6
    make
    cp bzlib.h /mingw/include/
    cp libbz2.a /mingw/lib


  2. libgsm

    Download gsm-1.0.13.tar.bz2, unpack and compile it as follows:

    tar xzvf gsm-1.0.13.tar.bz2
    cd gsm-1.0-pl13/
    make

    Just ignore the compile errors with fchmod and fchown when trying to build applications. Copy the header and static library to /mingw:


    mkdir /mingw/include/gsm
    cp inc/gsm.h /mingw/include/gsm
    cp lib/libgsm.a /mingw/lib


  3. LAME is an excellent MP3 encoder. LAME makes use of the nasm assembler if available. So download yasm and save it as /mingw/bin/nasm.exe. Then, download the LAME source from lame.sf.net and compile it like this.

    ./configure --prefix=/mingw --enable-expopt=full

    make

    make install


  4. OGG, Vorbis, Speex and Theora

    The source code for these libraries can be obtained from xiph.org. Compile them each like this:


    ./configure --prefix=/mingw
    make
    make install

    As for speex, use the version 1.2rc1 or later.



  5. FAAC

    FAAC is an MPEG-4 AAC audio encoder. Get the source (faac-1.28.tar.gz) and unpack the package. Then, edit Makefile.am:

    SUBDIRS = include libfaac

    Also, edit the line beginning with AC_OUTPUT in the file configure.in:

    AC_OUTPUT(libfaac/Makefile include/Makefile Makefile)

    Then, compile FAAC like this

    sh bootstrap
    ./configure --prefix=/mingw
    make
    make install


  6. XviD is a popular video encoder used to create movie files distributed in p2p networks. Xvid can use yasm assembler to build optimized binaries if found (/mingw/bin/yasm.exe). Get the XviD source from xvid.org and compile as follows:

    tar xzvf xvidcore-1.3.2.tar.gz
    cd xvidcore/build/generic
    ./configure --prefix=/mingw
    make
    make install


    If you encounter "unrecognized command-line option -mno-cygwin" errors, open the file platform.inc in a text editor and delete "-mno-cygwin". Then, run make and make install again.



    Copy the import library for xvidcore.dll:


    cp -iv \=build/xvidcore.dll.a /mingw/lib/libxvidcore.a


  7. x264 is yet another good video encoder. x264 requires YASM to build an optimized executable. So get yasm and save it as /mingw/bin/yasm.exe. Then, compile x264 like this:

    configure --prefix=/mingw --enable-win32thread --extra-cflags="-DX264_VERSION=20100422"

    make

    make install

    cp -iv x264.h x264_config.h /mingw/include

    cp -iv libx264.a /mingw/lib

    cp -iv x264.pc /mingw/lib/pkgconfig


  8. Compile librtmp as shown in this post.



Building FFMpeg Statically


You need pr.exe from MYS coreutils package (coreutils-5.97-3-msys-1.0.13-ext.tar.lzma). I configured ffmpeg with the following command:


CPPFLAGS='-DHAVE_INT32_T' ./configure --prefix=/mingw --enable-gpl --enable-nonfree --enable-postproc --enable-avfilter --enable-w32threads --enable-runtime-cpudetect --enable-memalign-hack --enable-bzlib --enable-libfaac --enable-libgsm --enable-libmp3lame --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-zlib --disable-debug

-DHAVE_INT32_T is used to allow static FAAC to be linked. Then, I began compilation and installation:


make
make install


Compiling FFmpeg Dynamically


Some Windows applications, such as Audacity, uses FFmpeg libraries when available. If you want to compile FFmpeg dynamically, append --enable-shared --disable-static to the ./configure command for FFmpeg.


./configure --prefix=/mingw --enable-gpl --enable-nonfree --enable-postproc --enable-avfilter --enable-w32threads --enable-runtime-cpudetect --enable-memalign-hack --enable-bzlib --enable-libfaac --enable-libgsm --enable-libmp3lame --enable-librtmp --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-zlib --enable-shared --disable-static --disable-debug


If you get "int32_t" error when compiling libfaac.o, open /mingw/include/faac.h and insert the following line:


#include <stdint.h>


When I built mplayer with --enable-static and --disable-ffmpeg_a options to force linking with shared ffmpeg libraries, I had to rename ffmpeg libraries so their names end in *.a.


cd /mingw/lib
cp -iv libavcodec.dll.a libavcodec.a
cp -iv libavformat.dll.a libavformat.a
cp -iv libavutil.dll.a libavutil.a
cp -iv libpostproc.dll.a libpostproc.a
cp -iv libswscale.dll.a libswscale.a

Sunday, September 2, 2012

Setting Up Cygwin For C/C++ Software Development on Windows

Cygwin provides a Unix-like environment for Windows users. Cygwin is useful for people who want to learn Unix or popular Linux without having to install Unix or Linux. Cygwin can also be used to port Linux applications to Windows or develop genuine Windows applications. To install Cygwin, download setup.exe from the Cygwin website and run it.



Cygwin Packages for Software Development


In addition to the default packages, select the following packages for common development environment:


  • bison
  • gettext-devel
  • libtool
  • make
  • patch
  • pkg-config


To select a package for installation, type the name of the package in the Search box, expand the categories by clicking a plus, and clicking on the package until its version number shows up.



cygwin_setup_mingw64

If you want to develop software applications that depend on cygwin1.dll (which emulates Unix on Windows), install one of the following packages. This is when you want to port Linux applications to Windows with little modification.


  • gcc-g++

    outdated version 3.4.4
  • gcc4-g++

    GCC 4.x that links applications with cygwin1.dll


If you want to develop pure Windows applications, install one of the following packages.


  • mingw-gcc-g++

    The original MinGW compiler from mingw.org can't build 64-bit applications.
  • mingw64-i686-gcc-g++

    New MinGW compiler from mingw-w64.sourceforge.net.
  • mingw64-x86_64-gcc-g++

    Install these to develop 64-bit Windows applications.


When you see the Resolving Dependencies window, just accept and click Next.


cygwin_setup_dependencies

Setting HOME Variable


Setting the environment variable %HOME% is useful for various reasons. First of all, it allows regular users to compile freely in their user folder without requiring access to C:\Cygwin. Secondly, it allows users to save user-specific configuration in their user folder. For example, user configuration files such as .profile, .gtkrc-2.0, .fonts.conf and .pango-aliases can be saved in the folder specified by %HOME%.


Set HOME environment variable for MinGW and Cygwin

Setting Up mingw* compiler for Cygwin


The file C:\Cygwin\etc\fstab is used to set up mount points in Cygwin. If you installed mingw64 packages, open the file C:\Cygwin\etc\fstab in a text editor and append the following line.


/usr/i686-w64-mingw32/sys-root/mingw /mingw none bind

Start the Cygwin terminal and type the following commands to set up Cygwin for Windows compilation.


ln -s /usr/bin/i686-w64-mingw32-g++.exe /usr/i686-w64-mingw32/bin/g++.exe
ln -s /usr/bin/i686-w64-mingw32-gcc.exe /usr/i686-w64-mingw32/bin/gcc.exe

Also, set up some environment variables.


export CFLAGS="-march=pentium2 -mtune=i586 -mthreads -mms-bitfields -O2"
export CXXFLAGS="-march=pentium2 -mtune=i586 -mthreads -mms-bitfields -O2"
export CPPFLAGS="-I/mingw/include"
export LDFLAGS="-L/mingw/lib -Wl,--enable-auto-image-base -Wl,--enable-auto-import -Wl,--enable-runtime-pseudo-reloc"
export PATH=/mingw/bin:/usr/i686-w64-mingw32/bin:/usr/local/bin:/usr/bin
export PKG_CONFIG_PATH=/mingw/lib/pkgconfig


Setting Up gcc* Compiler for Cygwin


If you installed the gcc4 compiler (as opposed to mingw*), set up some environment variables to customize your build environment. I usually type the following commands:


CC="/usr/bin/gcc.exe"
CFLAGS="-march=pentium2 -mtune=i586 -mthreads -mms-bitfields -O2"
CPPFLAGS="-I/usr/include"
CXXFLAGS="-march=pentium2 -mtune=i586 -mthreads -mms-bitfields -O2"
LDFLAGS="-L/usr/lib -Wl,--enable-auto-image-base -Wl,--enable-auto-import -Wl,--enable-runtime-pseudo-reloc"
export CC CFLAGS CPPFLAGS CXXFLAGS LDFLAGS

Thursday, August 23, 2012

MinGW: Compiling LZO Compression Library

LZO, short for Lempel-Ziv-Oberhumer, is compression software that is designed for decompression speed. I compiled the LZO library like this.


tar xzvf lzo-2.03.tar.gz

cd lzo-2.03/

./configure --prefix=/mingw

make

make install

I only got a static library liblzo2.a. So I had to convert it to a DLL.



gcc -shared -o liblzo2-2.dll -Wl,--out-implib,liblzo2.dll.a -Wl,--whole-archive /mingw/lib/liblzo2.a -Wl,--no-whole-archive -L/mingw/lib -lwinmm

Friday, August 17, 2012

Building GraphicsMagick

GraphicsMagick is a powerful tool for processing image files. I'm using MinGW to build GraphicsMagick for Windows.




  1. zlib 1.2.7


    Download the zlib source (zlib-1.2.7.tar.gz) and unpack it.


    tar xzvf zlib-1.2.7.tar.gz
    cd zlib-1.2.7

    Compile and install zlib.


    make -f win32/Makefile.gcc
    cp -iv zlib1.dll /mingw/bin
    cp -iv zconf.h zlib.h /mingw/include
    cp -iv libz.a /mingw/lib
    cp -iv libz.dll.a /mingw/lib


  2. bzip2


    Now download bzip2 source from bzip.org and unpack it.


    tar xzvf bzip2-1.0.6.tar.gz
    cd bzip2-1.0.6

    Change line 78 of bzlib.h to read:


    #if defined(_WIN32) && !defined(__MINGW32__)

    Compile and install bzip2.


    make
    cp bzlib.h /mingw/include/
    cp libbz2.a /mingw/lib


  3. liblzma


    Get the XZ Utils source code and unpack it. Go to the src/liblzma folder and compile liblzma like this:


    tar xzvf xz-5.0.4.tar.gz
    cd xz-5.0.4
    ./configure --prefix=/mingw
    cd src/liblzma
    make
    make install


  4. libpng 1.5.12 and libjpeg 8d


    Compile libpng and libjpeg as follows:


    ./configure --prefix=/mingw
    make
    make install


  5. libjasper


    Compile Jasper:


    ./configure --prefix=/mingw
    make
    make install

    If you encounter an error "undefined reference to _sleep", replace sleep() with _sleep with a factor of 1000 in the code:


    _sleep(1000)


  6. JBig


    Get jbigkit from here.


    make
    cp libjbig/*.h /mingw/include
    cp libjbig/*.a /mingw/lib


  7. libtiff 4.0.2


    Compile libtiff like this:


    ./configure --prefix=/mingw
    make
    make install

    If the shared library libtiff-5.dll is not generated and you want to create it manually, use such a command as the following and update libtiff.la accordingly:


    gcc -shared -o libtiff-5.dll -Wl,--out-implib,libtiff.dll.a -Wl,--whole-archive /mingw/lib/libtiff.a -Wl,--no-whole-archive -L/mingw/lib -ljpeg -ljbig -llzma -lz


  8. freetype


    Compile freetype:


    ./configure --prefix=/mingw
    make
    make install


  9. libxml2


    Compile libxml2:


    ./configure --prefix=/mingw
    make
    make install


  10. libwmf 0.2.8.4


    Compile libwmf:


    ./configure --prefix=/mingw
    make
    make install


  11. Little CMS


    Compile liblcms:


    ./configure --prefix=/mingw
    make
    make install


  12. Build GraphicsMagick


    Get GraphicsMagick code and build it like this:


    ./configure --prefix=/mingw --with-gs-font-dir='C:/Windows/Fonts' --with-windows-font-dir='C:/Windows/Fonts' LIBS='-ljbig'
    make
    make install



Creating a PDF document from JPEG files


GraphicsMagick comes in handy when you want to convert scanned JPEG images to a PDF document:


gm convert *.jpg doc.pdf

Tuesday, December 20, 2011

To build wget.exe with MinGW

wget is a useful command-line downloader. To build wget for the Windows platform, first install MinGW. Then, compile zlib, openssl and wget in that order. To compile zlib:



make -f win32/Makefile.gcc
cp -iv zlib1.dll /mingw/bin
cp -iv zconf.h zlib.h /mingw/include
cp -iv libz.a /mingw/lib
cp -iv libz.dll.a /mingw/lib


To compile openssl:



./Configure -DHAVE_STRUCT_TIMESPEC -DPTW32_STATIC_LIB -L/mingw/lib -lz -lpthreadGC2 -lws2_32 --prefix=/mingw threads zlib mingw
make
make test
make install


Now, build wget



./configure --prefix=/mingw --enable-threads=win32 --disable-nls --with-ssl=openssl
make
make install

Wednesday, June 2, 2010

Compiling GTK+ Theme Engines

The GTK+ widget library supports diverse customization of look and feel for GTK+ applications. This is achieved by installing a shared library (*.so or *.dll) that provides a particular GTK+ theme style. The default GTK+ theme engine (Raleigh) is too generic and old-fashioned to suit my style. The pixmap engine is too much of a resource hog, and the Wimp engine doesn't seem to work for GTK+ 2.18 and later releases.


My favorite GTK+ theme engines are thus:



  • Aurora engine
  • Candido engine
  • CleanIce engine
  • Clearlooks engine
  • Lighthouseblue engine
  • MagicChicken engine
  • Murrine engine
  • Nodoka engine
  • Rezlooks engine
  • Smooth engine
  • Wonderland engine


Compiling GTK+ Theme Engines 2.20.1


After building GTK+ 2 library, I can compile GTK+ theme engines, including Clearlooks and Lighthouseblue. I couldn't find the upstream release of gtk2-engines, so I downloaded the source from Debian Sid's page.


gtk2-engines requires intltool, so I compiled intltool first.


tar xzvf intltool-0.41.1.tar.gz
cd intltool-0.41.1
./configure --prefix=/mingw
make
make install

configure script will complain if xgettext, msgmerge and msgfmt are not found. I got these programs from my static gettext package I compiled previously.



Then, I compiled gtk-engines as follows:


tar xzvf gtk2-engines_2.20.1.orig.tar.gz
cd gtk-engines-2.20.1/
./configure --prefix=/mingw --disable-deprecated --enable-animation
make

I only wanted clearlooks, so I copied libclearlooks.dll.


find -iname \*dll
cp ./engines/clearlooks/.libs/libclearlooks.dll /mingw/lib/gtk-2.0/2.10.0/engines


Compiling Aurora Theme Engine


I downloaded the Aurora source from here and unpack it. I compiled Aurora like this:


./configure --prefix=/mingw --enable-animation
make
make install


Cygwin: Compiling Smooth Theme Engine


The source code of smooth theme engine can be downloaded from here. Compiling is easy:


./configure --prefix=/usr
make
make install

Monday, May 31, 2010

Compiling GTK+ for Windows with MinGW

GTK+ is a set of open-source widget libraries that are mature, functional and portable. GTK+ library is mainly used by many Linux programs. I am building a complete stack of GTK+ 2.x library before beginning my programming projects. This tutorial makes use of the free MinGW compiler to build GTK+.



If you haven't installed MinGW yet, read this tutorial on installing MinGW in Windows. Alternatively, you can also install MinGW Portable on your USB flash drive so you can enjoy compiling anywhere. GTK+ depends on many basic libraries that provide image, localization, font and other functions. These prerequisite libraries have be compiled first. Once you've installed MinGW and MSYS, launch MSYS. The following steps require you to type commands into MSYS console.




  1. Zlib 1.2.7


    Zlib is an essential compression library required by png, tiff and cairo. Get the zlib source and unpack it:

    tar xzvf zlib-1.2.7.tar.gz
    cd zlib-1.2.7/

    Compile zlib like this:


    make -f win32/Makefile.gcc

    Then, manually copy the files as follows:


    cp -iv zlib1.dll /mingw/bin
    cp -iv zconf.h zlib.h /mingw/include
    cp -iv libz.a /mingw/lib
    cp -iv libz.dll.a /mingw/lib


  2. libiconv 1.14


    libiconv is a character-set conversion library, and is needed by gettext. Download the libiconv source and compile libiconv:


    ./configure --prefix=/mingw
    make
    make install


  3. gettext 0.18.1.1


    GNU gettext is a tool for localizing and translating programs. Build gettext like this:


    ./configure --prefix=/mingw --enable-threads=win32 --enable-relocatable
    cd gettext-runtime/
    make
    make install


  4. glib 2.32.4


    glib's configure script requires pkg-config.exe and msgfmt.exe in the PATH. Download the executables and save them in /mingw/bin. Remember to set the system-wide environment variable PKG_CONFIG_PATH:


    export PKG_CONFIG_PATH=/mingw/lib/pkgconfig

    glib 2.30 and later depends on libffi. Compile libffi like this:


    ./configure --prefix=/mingw && make && make install

    Then, get the glib source from ftp.gnome.org and compile glib as follows:


    ./configure --prefix=/mingw --with-threads=win32 --with-pcre=internal --disable-debug
    make
    make install


  5. ATK 2.4.0


    Download ATK from here. Compile it like this:


    ./configure --prefix=/mingw
    make
    make install


  6. libpng 1.5.12


    PNG can be compiled like this:


    ./configure --prefix=/mingw
    make
    make install


  7. Optional libraries


    The following libraries are optional, but many GTK+ packages include them. It's up to you to decide whether to compile them or not.



    As usual, compile any of them like this:


    ./configure --prefix=/mingw && make && make install


  8. Pixman 0.26.2 and Cairo 1.12.2


    Get Pixman and Cairo from cairographics.org. Compile Pixman as follows:


    ./configure --prefix=/mingw

    make

    make install

    Then, compile cairo:


    ./configure --prefix=/mingw --enable-pthread
    make
    make install


  9. Pango Library 1.30.1


    Compile Pango like this:


    ./configure --prefix=/mingw --with-included-modules=yes

    make

    make install


  10. gdk-pixbuf 2.26.2


    Download and compile gdk-pixbuf:


    ./configure --prefix=/mingw --without-libjasper --with-included-loaders=yes --disable-modules --disable-debug
    make
    make install


  11. GTK+ 2.24.11 and GTK+ 3.4.2


    At last, we are ready to compile GTK+ for Windows. I compiled GTK+ like this:


    ./configure --prefix=/mingw --with-included-immodules=ime --disable-modules --disable-debug

    make

    make install


    To test your newly compiled GTK+ library, run gtk-demo.exe or testgtk.exe.



Friday, April 30, 2010

Compile wxDownload Fast for Windows

I once used wxDownload Fast as a tool for getting something off the Web quickly. But it crashes every once in a while. So I stopped using it long ago. Now I am compiling wxDownload Fast only to test my static wxMSW library.



I am using MinGW GCC compiler to build wxDownload Fast. I downloaded the source for wxDownload Fast. I unpacked the source and configured it:



tar xzvf wxdfast_0.6.0.tar.gz
cd wxdfast-0.6.0/
./configure --prefix=/mingw --enable-win32build


I got some errors during the final linking stage. I had to modify src/Makefile to fix the errors. The end of Makefile was modified.



wxDFast.res: wxDFast.rc
windres -i $< -J rc -O coff -o $@ --include-dir=/mingw/include/wx-2.8


The other fix involves linking with expat because my wxMSW library depends on expat.



wxdfast$(EXEEXT): $(wxdfast_OBJECTS) $(wxdfast_DEPENDENCIES) 
@rm -f wxdfast$(EXEEXT)
$(CXXLINK) $(wxdfast_LDFLAGS) $(wxdfast_OBJECTS) $(wxdfast_LDADD) $(LIBS) -lexpat


Then, I started make.



make
make install


I double-clicked wxdfast and it started alright. The following files are installed onto the system (under the MinGW folder).



./bin/wxdfast.exe
./share/applications/wxdfast.desktop
./share/locale/cs/LC_MESSAGES/wxDFast.mo
./share/locale/de/LC_MESSAGES/wxDFast.mo
./share/locale/es/LC_MESSAGES/wxDFast.mo
./share/locale/fr/LC_MESSAGES/wxDFast.mo
./share/locale/hu/LC_MESSAGES/wxDFast.mo
./share/locale/id/LC_MESSAGES/wxDFast.mo
./share/locale/nl/LC_MESSAGES/wxDFast.mo
./share/locale/pl/LC_MESSAGES/wxDFast.mo
./share/locale/pt_BR/LC_MESSAGES/wxDFast.mo
./share/locale/ru/LC_MESSAGES/wxDFast.mo
./share/locale/tr/LC_MESSAGES/wxDFast.mo
./share/man/man1/wxdfast.1
./share/man/pt_BR/man1/wxdfast.1
./share/pixmaps/wxdfast.png
./share/wxdfast/RipStop/icon/dfast48x48.png
./share/wxdfast/RipStop/icon/wxdfast.ico
./share/wxdfast/RipStop/icon/wxdfast.png
./share/wxdfast/RipStop/license.txt
./share/wxdfast/RipStop/logo/about.png
./share/wxdfast/RipStop/menubar/about.png
./share/wxdfast/RipStop/menubar/completed.png
./share/wxdfast/RipStop/menubar/copydata.png
./share/wxdfast/RipStop/menubar/copyurl.png
./share/wxdfast/RipStop/menubar/details.png
./share/wxdfast/RipStop/menubar/downloading.png
./share/wxdfast/RipStop/menubar/error.png
./share/wxdfast/RipStop/menubar/find.png
./share/wxdfast/RipStop/menubar/graph.png
./share/wxdfast/RipStop/menubar/help.png
./share/wxdfast/RipStop/menubar/new.png
./share/wxdfast/RipStop/menubar/options.png
./share/wxdfast/RipStop/menubar/pasteurl.png
./share/wxdfast/RipStop/menubar/pause.png
./share/wxdfast/RipStop/menubar/progressbar.png
./share/wxdfast/RipStop/menubar/properties.png
./share/wxdfast/RipStop/menubar/quit.png
./share/wxdfast/RipStop/menubar/remove.png
./share/wxdfast/RipStop/menubar/schedule.png
./share/wxdfast/RipStop/menubar/scheduled.png
./share/wxdfast/RipStop/menubar/start.png
./share/wxdfast/RipStop/menubar/startall.png
./share/wxdfast/RipStop/menubar/stop.png
./share/wxdfast/RipStop/menubar/stopall.png
./share/wxdfast/RipStop/preview/ripstop.png
./share/wxdfast/RipStop/preview/wxdownloads_small.png
./share/wxdfast/RipStop/readme.txt
./share/wxdfast/RipStop/svg/ripstop.svg
./share/wxdfast/RipStop/svg/wxdownloads_small.svg
./share/wxdfast/RipStop/toolbar/download_info.png
./share/wxdfast/RipStop/toolbar/download_move_down.png
./share/wxdfast/RipStop/toolbar/download_move_up.png
./share/wxdfast/RipStop/toolbar/download_new.png
./share/wxdfast/RipStop/toolbar/download_remove.png
./share/wxdfast/RipStop/toolbar/download_schedule.png
./share/wxdfast/RipStop/toolbar/download_start.png
./share/wxdfast/RipStop/toolbar/download_start_all.png
./share/wxdfast/RipStop/toolbar/download_stop.png
./share/wxdfast/RipStop/toolbar/download_stop_all.png
./share/wxdfast/boxabout.xrc
./share/wxdfast/boxnew.xrc
./share/wxdfast/boxoptions.xrc
./share/wxdfast/images.xrc
./share/wxdfast/mainwindow.xrc
./share/wxdfast/menubar.xrc
./share/wxdfast/toolbar.xrc
./share/wxdfast/xpm/big/close.xpm
./share/wxdfast/xpm/big/down.xpm
./share/wxdfast/xpm/big/new.xpm
./share/wxdfast/xpm/big/properties.xpm
./share/wxdfast/xpm/big/remove.xpm
./share/wxdfast/xpm/big/schedule.xpm
./share/wxdfast/xpm/big/start.xpm
./share/wxdfast/xpm/big/startall.xpm
./share/wxdfast/xpm/big/stop.xpm
./share/wxdfast/xpm/big/stopall.xpm
./share/wxdfast/xpm/big/up.xpm
./share/wxdfast/xpm/small/error.xpm
./share/wxdfast/xpm/small/exit.xpm
./share/wxdfast/xpm/small/graph.xpm
./share/wxdfast/xpm/small/new.xpm
./share/wxdfast/xpm/small/noresume.xpm
./share/wxdfast/xpm/small/ok.xpm
./share/wxdfast/xpm/small/options.xpm
./share/wxdfast/xpm/small/paste.xpm
./share/wxdfast/xpm/small/progress.xpm
./share/wxdfast/xpm/small/properties.xpm
./share/wxdfast/xpm/small/queue.xpm
./share/wxdfast/xpm/small/remove.xpm
./share/wxdfast/xpm/small/resume.xpm
./share/wxdfast/xpm/small/schedule.xpm
./share/wxdfast/xpm/small/start.xpm
./share/wxdfast/xpm/small/startall.xpm
./share/wxdfast/xpm/small/stop.xpm
./share/wxdfast/xpm/small/stopall.xpm
./share/wxdfast/xpm/small/wxdfast.xpm
./share/wxdfast/xpm/wxdfast.ico
./share/wxdfast/xpm/wxdfast.xpm

Saturday, April 24, 2010

MinGW: To Compile Vorbis Tools

Vorbis tools include oggenc and vorbiscomment that can be used to produce Ogg-Vorbis music files. Ogg Vorbis provides people with free, open-source audio format and encoding algorithm. Because the MP3 algorithm is patented and creating MP3 exposes people to legal risks, use of the Ogg Vorbis format is a reasonable choice for legally conscious people. Besides its openness and patent-free characteristics, Ogg Vorbis offers good compression and sound quality, comparable to MP3 and AAC. Therefore, everyone is recommended to create, use and spread Ogg Vorbis music files, instead of MP3 and AAC.



To learn how to prepare a MinGW environment, read this post. Then, download the source for libogg, libvorbis and vorbis-tools from xiph.org.





To build Vorbis tools, libogg and libvorbis should be compiled first. Start the MinGW rxvt console from the Start menu. Unpack the libogg source and compile it as follows:



tar xzvf libogg-1.2.0.tar.gz
cd libogg-1.2.0/
./configure --prefix=/mingw
make
make install


libvorbis can be compiled likewise:



tar xzvf libvorbis-1.3.1.tar.gz
cd libvorbis-1.3.1/
./configure --prefix=/mingw
make
make install


Then, build vorbis-tools as follows:



tar xzvf vorbis-tools-1.4.0.tar.gz
cd vorbis-tools-1.4.0/
./configure --prefix=/mingw --disable-nls --enable-threads=win32
make
make install


When done, the following files are created in /mingw/bin:



libogg-0.dll
libvorbis-0.dll
libvorbisenc-2.dll
libvorbisfile-3.dll
oggdec.exe
oggenc.exe
ogginfo.exe
vorbiscomment.exe


Copy these files whereever you want. To create an Ogg Vorbis file from a .WAV file, use a command like this:



oggenc -q5 audio.wav


Related Posts


Friday, April 9, 2010

MinGW: Building TwoLAME

TwoLAME is MPEG-2 audio encoder. First, compile libsndfile which is used is read sound files in various formats.


tar xzvf libsndfile-1.0.21.tar.gz
cd libsndfile-1.0.21/
./configure --prefix=/mingw --disable-shared --enable-static
make
make install

Then, build twolame.


tar xzvf twolame-0.3.12.tar.gz
cd twolame-0.3.12/
./configure --prefix=/mingw CPPFLAGS='-DLIBTWOLAME_STATIC'
make
make install

When linking a program with a static TwoLAME library, define LIBTWOLAME_STATIC with CPPFLAGS.


CPPFLAGS=' -DLIBTWOLAME_STATIC' ./configure --enable-static --enable-twolame

MinGW: MPlayer와 Mencoder 동적 컴파일하기

MinGW의 GCC 컴파일러를 사용하여 Windows용 MPlayer와 Mencoder를 컴파일해 보자. MPlayer는 동영상을 보는 프로그램이고 Mencoder는 동영상이나 음악을 인코딩하는 프로그램이다. 예전에는 정적으로 컴파일하였지만 이번에는 동적으로 컴파일해 보자.


우선 MinGW를 설치한다. MPlayer는 FFmpeg 라이브러리에 의존하므로 먼저 FFmpeg 라이브러리를 동적으로 컴파일하도록 한다.


시작 메뉴를 열어 MinGW (rxvt)를 실행한다. 노란 창이 나타날 것이다. 그럼 다음과 같이 MPlayer와 의존 라이브러리를 컴파일하자.



  1. LZO 압축 라이브러리 컴파일 (옵션)

    tar xzvf lzo-2.03.tar.gz
    cd lzo-2.03/
    ./configure --prefix=/mingw
    make
    make install


  2. Fribidi 라이브러리 컴파일 (옵션)

    Fribidi는 아랍어와 히브리어의 표시에 필요하다. 솔직히 이 기능은 빠뜨려도 된다.

    tar xzvf fribidi-0.19.2.tar.gz
    cd fribidi-0.19.2/
    ./configure --prefix=/mingw --disable-debug
    make
    make install

    자세한 내용은 Fribidi에 관한 글을 참조.

  3. giflib 라이브러리 컴파일 (옵션)

    tar xjvf giflib-4.1.6.tar.bz2 
    cd giflib-4.1.6/
    ./configure --prefix=/mingw
    make
    make install


  4. Live555 라이브러리 컴파일 (권장)

    Live 라이브러리는 인터넷 동영상을 보는 데 쓰인다. live555.com에서 최신 버전을 받아 다음과 같이 컴파일한다:

    export CC=/mingw/bin/gcc.exe
    cd /mingw/lib/
    tar xzvf live.2010.04.01.tar.gz
    cd live/
    ./genMakefiles mingw
    make


  5. JPEG 라이브러리 컴파일 (권장)

    tar xzvf jpegsrc.v8a.tar.gz
    cd jpeg-8a/
    ./configure --prefix=/mingw
    make
    make install


  6. PNG 라이브러리 컴파일 (권장)

    tar xzvf libpng-1.4.1.tar.gz 
    cd libpng-1.4.1
    ./configure --prefix=/mingw
    make
    make install


  7. FreeType 라이브러리 컴파일 (필수)

    자막 표시에 필요하다.

    그리고 Freetype를 컴파일한다.

    tar xzvf freetype-2.3.12.tar.gz 
    cd freetype-2.3.12/
    ./configure --prefix=/mingw
    make install


  8. 만일 iconv 라이브러리가 설치되어 있지 않다면 컴파일한다. libXML2 그리고 fontconfig 에 필요하다.

  9. libXML2 컴파일

    만약에 fontconfig 라이브러리를 컴파일하려면 필요하다. 먼저 testThreads.c를 고친다.

    --- testThreads.c.orig  2009-09-11 18:09:00.268640135 +0200
    +++ testThreads.c 2009-09-11 18:12:43.412653512 +0200
    @@ -107,7 +107,7 @@

    for (i = 0; i < num_threads; i++) {
    results[i] = NULL;
    - tid[i] = (pthread_t) -1;
    + memset(&tid[i], 0, sizeof(pthread_t));
    }

    for (i = 0; i < num_threads; i++) {

    그리고 컴파일한다:


    ./configure --prefix=/mingw
    make install


  10. Fontconfig 라이브러리 컴파일 (권장)

    SSA 자막 표시에 필요하다.

    tar xzvf fontconfig-2.8.0.tar.gz 
    cd fontconfig-2.8.0/
    ./configure --prefix=/mingw
    make install


  11. Libcdio 컴파일 (옵션)

    tar xzvf libcdio-0.83.tar.gz 
    cd libcdio-0.83/
    ./configure --prefix=/mingw
    make
    make install


  12. Libdca 컴파일 (권장)

    tar xjvf libdca-0.0.5.tar.bz2 
    cd libdca-0.0.5/
    ./configure --prefix=/mingw
    make install


  13. DirectX 7 라이브러리 추출 (권장)

    cd /mingw/include/
    tar xzvf dx7headers.gz


  14. MPlayer, Mencoder 컴파일

    ffmpeg 소스를 받아서 mplayer 소스 디렉토리에 넣는다.

    tar xjvf mplayer-export-snapshot.tar.bz2

    cd mplayer-export-2011-11-25/

    tar xjvf ffmpeg-snapshot.tar.bz2

    CPPFLAGS='-DWIN32 -DHAVE_INT32_T' ./configure --prefix=/mingw --enable-runtime-cpudetection --enable-theora --enable-fribidi --disable-ffmpeg_a --yasm=/mingw/bin/yasm

    MPlayer를 컴파일하기 전에 config.mak를 텍스트 에디터(notepad.exe)로 수정한다.

    EXTRALIBS_MPLAYER  = -lgdi32 -lopengl32 -lwinmm -lfaac -lx264 -lmp3lame -lfribidi
    EXTRALIBS_MENCODER = -lfaac -lx264 -lfribidi -lmp3lame

    MPlayer 컴파일 시작한다.

    make

  15. MPlayer.exe와 Mencoder.exe를 복사한다.

    strip mencoder.exe mplayer.exe
    cp -iv m*.exe /mingw/bin

Sunday, April 4, 2010

윈도용 MPlayer / Mencoder 사용 및 설정

MinGW로 컴파일한 MPlayer를 시험해 보고 최적으로 설정해 보자. 다음은 내가 컴파일한 MPlayer와 Mencoder이다. bzip2.exe로 압축을 풀어야 한다(bzip2 -d mplayer.exe.bz2).





  1. DirectX 8.1 설치(Windows 95/98/ME Only)


    업데이트: Windows 98/ME 사용자도 아래의 DirectX 9.0c를 설치할 수 있다. 만일 DirectX 9을 설치할 경우, DirectX 8.1을 설치할 필요가 없게 된다.


    Windows 98/ME 사용자는 DirectX 8.0a, DirectX 8.1b 혹은 DirectX 8.2를 받아서 설치해야 MPlayer가 제대로 작동한다. 다음은 다운로드 링크를 여러 군데 모은 것이다.



    DirectX 8.1는 Windows XP에 포함되어 있다.



  2. DirectX 9.0c 설치


    MPlayer의 최신 개발 코드는 기본적으로 DirectX 9와 링크되도록 되어 있다. 그러므로 이렇게 만든 mplayer.exe 실행 파일을 Windows 98/ME/XP에서 실행하면 DirectX 9를 못 찾고 오류가 발생할 수가 있다. 이러한 오류를 방지하기 위해 MPlayer를 configure 할 때 --disable-direct3d 옵션을 주어서 DX9 링크 못하게 할 수 있다. 그렇지 않으면 filehippo.com에서 DirectX 9.0c 2006년 12월 릴리스를 받아서 설치해야 한다.



  3. MPlayer의 간단한 명령행 도움말


    mplayer.exe를 처음 실행하면 검은 콘솔 창이 나타나 아래처럼 짧은 도움말이 나온다.


    MPlayer SVN-r29464-snapshot-3.4.5 (C) 2000-2009 MPlayer Team
    Usage: mplayer [options] [url|path/]filename

    Basic options: (complete list in the man page)
    -vo select video output driver ('-vo help' for a list)
    -ao select audio output driver ('-ao help' for a list)
    vcd:// play (S)VCD (Super Video CD) track (raw device, no mount)
    dvd:// play DVD title from device instead of plain file
    -alang/-slang select DVD audio/subtitle language (by 2-char country code)
    -ss seek to given (seconds or hh:mm:ss) position
    -nosound do not play sound
    -fs fullscreen playback (or -vm, -zoom, details in the man page)
    -x -y set display resolution (for use with -vm or -zoom)
    -sub specify subtitle file to use (also see -subfps, -subdelay)
    -playlist specify playlist file
    -vid x -aid y select video (x) and audio (y) stream to play
    -fps x -srate y change video (x fps) and audio (y Hz) rate
    -pp enable postprocessing filter (details in the man page)
    -framedrop enable frame dropping (for slow machines)

    Basic keys: (complete list in the man page, also check input.conf)
    <- or -> seek backward/forward 10 seconds
    down or up seek backward/forward 1 minute
    pgdown or pgup seek backward/forward 10 minutes
    < or > step backward/forward in playlist
    p or SPACE pause movie (press any key to continue)
    q or ESC stop playing and quit program
    + or - adjust audio delay by +/- 0.1 second
    o cycle OSD mode: none / seekbar / seekbar + timer
    * or / increase or decrease PCM volume
    x or z adjust subtitle delay by +/- 0.1 second
    r or t adjust subtitle position up/down, also see -vf expand

    * * * SEE THE MAN PAGE FOR DETAILS, FURTHER (ADVANCED) OPTIONS AND KEYS * * *


    mplayer -vo help 명령은 다음과 같이 어떤 화면 출력 장치가 사용 가능한지 보여 준다.


    MPlayer SVN-r29464-snapshot-3.4.5 (C) 2000-2009 MPlayer Team
    Available video output drivers:
    directx Directx DDraw YUV/RGB/BGR renderer
    direct3d Direct3D 9 Renderer
    gl X11 (OpenGL)
    gl2 X11 (OpenGL) - multiple textures version
    winvidix WIN32 (VIDIX)
    cvidix console VIDIX
    null Null video output
    mpegpes MPEG-PES file
    yuv4mpeg yuv4mpeg output for mjpegtools
    png PNG file
    jpeg JPEG file
    gif89a animated GIF output
    tga Targa output
    pnm PPM/PGM/PGMYUV file
    md5sum md5sum of each frame

    mplayer -ao help 명령은 어떤 음향 출력 장치가 사용 가능한지 보여 준다.


    MPlayer SVN-r29464-snapshot-3.4.5 (C) 2000-2009 MPlayer Team
    Available audio output drivers:
    dsound Windows DirectSound audio output
    win32 Windows waveOut audio output
    mpegpes MPEG-PES audio output
    null Null audio output
    pcm RAW PCM/WAVE file writer audio output


  4. MPlayer 시험


    일단 명령 프롬프트(cmd.exe)나 실행 대화창(Run...)에서 다음과 같은 명령을 입력하여 MPlayer를 테스트해 보자. 위에 보이는 -vo 도움말과 -ao 도움말을 참고하여 자신의 시스템에 가장 알맞은 옵션을 찾아 보자.


    mplayer -vo direct3d -ao dsound -font C:\WINDOWS\FONTS\Tahoma.ttf -framedrop mymoviefile.avi

    또는 좀 느리지만 기본적인 출력 장치로 GL과 win32를 사용해 볼 수 있다.


    mplayer -vo gl -ao win32 Bear.wmv

    샘플 동영상 파일은 인터넷에서 검색하여 받도록 한다. Vista와 Windows 7 사용자는 C:\Users\Public\Videos\Sample Videos 폴더에 있는 샘플 동영상 파일로 MPlayer를 테스트해 볼 수 있다.



  5. MPlayer 설정


    처음으로 MPlayer를 실행하기 전에 HOME 환경변수를 정하여 자신의 폴더를 정해 준다. 그리고 MPlayer를 처음으로 더블클릭하면 사용자의 %HOME% 디렉토리에 “mplayer”라는 폴더가 생기고 그 안에 "config"라는 파일이 있다. "config" 파일에 다음과 같이 설정 사항을 적는다:



    # Write your default config options here!
    cdrom-device=D:
    dvd-device=D:
    ao=dsound
    vo=direct3d
    font=C:\WINDOWS\FONTS\MALGUN.TTF
    framedrop=yes
    subcp=cp949

    Windows 98/ME 사용자는 화면 출력 장치 설정으로 vo=direct3d 대신에 vo=directx 또는 vo=directx:noaccel 라고 적어야 한다. directx:noaccel은 가속 기능이 없는 DirectDraw 출력 장치인데 화면 출력에 문제가 있을 경우에 사용한다.



  6. MPlayer 코덱


    MPlayer 코덱을 받는 게 좋다. 파일 이름은 windows-essential-20071007.zip이다. 압축을 풀면 "windows-essential-20071007" 폴더가 나오는데 "codecs"으로 이름을 바꾸어 mplayer.exe가 있는 폴더로 옮기도록 한다.


    또한, MPlayer 소스의 etc 디렉토리에 codecs.conf 파일이 있을 것이다. 이것을 사용자의 mplayer 폴더에 복사해 놓는다. 그리고 mplayer를 실행하면 메시지 첫머리에 다음과 같이 코덱 숫자가 표시된다.


    MPlayer SVN-r29464-snapshot-3.4.5 (C) 2000-2009 MPlayer Team
    138 audio & 299 video codecs
    Usage: mplayer [options] [url|path/]filename

    이제 다음 명령어를 실행하면 mplayer 코덱에 관한 정보가 나올 것이다.


    mplayer -vc help
    mplayer -ac help


  7. 다음처럼 동영상을 볼 수 있다:

    mplayer mymoviefile.avi > C:\Windows\Temp\error.txt

    이제 남은 일은 SMPlayer를 받아서 MPlayer 인터페이스로 설정하는 것이다.


Thursday, April 1, 2010

윈도용 MPlayer와 Mencoder 정적 컴파일

Windows에서 MPlayer/Mencoder를 컴파일하려면 MinGW 컴파일러가 필요하다. 이 글을 읽고 MinGW를 설치하도록 한다. 이 글은 정적 실행 파일(특별한 DLL에 의존하지 않는 단일 프로그램)을 생성하기 위해 쓰여졌다. 동적 실행 파일을 만들려면 이 글을 읽기 바란다.



시작 메뉴에서 MSYS (rxvt)를 오른쪽 클릭하여 관리자로 실행한다. Windows Vista와 Windows 7에서 문제 없이 컴파일하기 위함이다.




  1. LZO 라이브러리는 빠른 압축 기능으로 순수 비디오를 압축하는 데 쓰인다.

    tar xzvf lzo-2.03.tar.gz
    cd lzo-2.03
    ./configure --prefix=/mingw
    make
    make install

  2. Zlib는 압축 헤더가 붙은 몇몇 mov 파일을 보기 위해 필요하다. zlib.net에서 소스를 받아 컴파일한다:

    cd ~

    tar xjvf zlib-1.2.4.tar.bz2

    cd zlib-1.2.4

    ./configure --prefix=/mingw

    make

    make install


  3. PNG 이미지 라이브러리


    영화 보는 데 PNG 라이브러리가 왜 필요한지 궁금할 것이다. 가끔 영화의 인상적인 부분을 한 장면 한 장면 사진으로 저장하고 싶을 때 쓸 수 있다. PNG 라이브러리 소스를 받아 컴파일하자:


    cd ~
    tar xzvf libpng-1.4.1.tar.gz
    cd libpng-1.4.1/
    ./configure --prefix=/mingw --disable-shared
    make
    make install


  4. Freetype 및 Iconv 라이브러리


    Freetype은 자막 표시에 필요하다. iconv 라이브러리에 의존하므로 먼저 iconv 소스를 받아 컴파일하자:


    cd ~

    tar xvzf libiconv-1.13.1.tar.gz

    cd libiconv-1.13.1

    ./configure --prefix=/mingw --disable-shared

    make

    make install

    그런 다음, Freetype2를 받아 컴파일한다:


    cd ~

    tar xzvf freetype-2.3.12.tar.gz

    cd freetype-2.3.12

    ./configure --prefix=/mingw --disable-shared

    make

    make install


  5. Fontconfig 라이브러리는 SSA 자막 표시에 필요하다. expat 라이브러리에 의존하므로 먼저 expat 라이브러리를 컴파일하자.

    cd ~
    tar xzvf expat-2.0.1.tar.gz
    cd expat-2.0.1/
    ./configure --prefix=/mingw --disable-shared
    make install

    그리고 fontconfig 라이브러리를 컴파일한다.

    cd
    tar xzvf fontconfig-2.8.0.tar.gz
    cd fontconfig-2.8.0/
    ./configure --prefix=/mingw --disable-shared
    make install


  6. Libcdio 소스를 여기서 받아 컴파일하고 설치하자.

    tar xzvf libcdio-0.81.tar.gz

    cd libcdio-0.81

    ./configure --prefix=/mingw --disable-shared

    make

    make install


  7. Libogg, Libvorbis, speex, Theora 컴파일


    libogg, libvorbis, speex 그리고 theora 라이브러리 모두 xiph.org에서 받아 다음과 같이 컴파일하자:


    ./configure --prefix=/mingw --disable-shared

    make

    make install


  8. DirectX 헤더를 아래의 위치에서 받아서:


    MinGW의 include 폴더(예를 들어, C:\MinGW\include)에 압축을 푼다.



  9. MPlayer 정적 컴파일을 위한 configure 명령


    pkg-config.exe와 yasm.exe를 받아서 /mingw/bin에 저장한다. MPlayer 소스를 받아서 풀자:


    tar xjvf mplayer-export-snapshot.tar.bz2
    cd mplayer-export-2009-08-02/

    다음과 같이 configure 명령어를 입력한다.


    ./configure --prefix=/mingw --enable-runtime-cpudetection --enable-static --enable-theora --disable-vidix --yasm=/mingw/bin/yasm


  10. configure가 끝나면 config.mak를 열어서 손보자. MPlayer.exe를 실행할 때 검은 로그 창이 나타나는 현상을 원하지 않는다면 EXTRALIBS_MPLAYER= 행에 -mwindows 추가하도록 한다:

    EXTRALIBS_MPLAYER =  -mwindows -lopengl32 -lgdi32 -lwinmm -ld3d9 -lfaac -lx264 -lmp3lame


  11. MPlayer/Mencoder 컴파일


    드디어 MPlayer 컴파일을 시작한다.


    make

    컴파일이 성공적으로 끝나면 mplayer.exe 그리고 mencoder.exe 두 개의 파일이 생긴다. strip 명령을 쓰면 실행 파일의 크기를 약간 줄일 수 있다.


    strip m*.exe

    UPX로 압축한다.


    upx --best --strip-relocs=0 mplayer.exe
    upx --best --strip-relocs=0 mencder.exe

    가령, C:\Program Files로 복사하도록 한다.


    cp -iv m*.exe /c/Program\ Files



mplayer.exe와 mencoder.exe 두 개의 실행 파일이 성공적으로 만들어졌으니, 이제 MPlayer를 테스트하고 설정하는 일이 남았다.

Monday, June 8, 2009

Compiling Mencoder for Windows

Mencoder is a command-line tool for creating multimedia files. It allows you to convert video from one format to another. When used together with OGMRip, mencoder helps you to rip DVD into a video file that's convenient to watch on computers. Note that the instruction herein explains how to compile Mencoder for the Windows platform, not Linux.



MinGW must be installed first (Look here for how). Once you have MinGW, launch MSYS (rxvt) from the Start menu and type the following commands.




  1. PNG and JPEG


    PNG depends on zlib compression library. Download the zlib source from zlib.net and compile as follows:

    tar xzvf zlib-1.2.3.tar.gz
    cd zlib-1.2.3
    ./configure --prefix=/mingw
    make
    make install

    Now get the PNG library here and compile it as follows:

    tar xzvf libpng-1.2.34.tar.gz
    cd libpng-1.2.34/
    ./configure --prefix=/mingw --disable-shared
    make
    make install

    Download the source for JPEG library, compile and install JPEG as follows:

    tar xzvf jpegsrc.v7.tar.gz
    cd jpeg-7
    ./configure --prefix=/mingw
    make
    make install


  2. libdca Library


    Download the libdca source from videolan.org and compile it like this:


    tar xjvf libdca-0.0.5.tar.bz2
    cd libdca-0.0.5
    ./configure --prefix=/mingw
    make
    make install


  3. OGG, Vorbis and Theora


    The source for these libraries can be obtained from xiph.org. Compile them like this:

    ./configure --prefix=/mingw --disable-shared
    make
    make install


  4. Libcdio Library


    Download the libcdio source from here. Compile and install libcdio as follows:

    tar xzvf libcdio-0.81.tar.gz
    cd libcdio-0.81
    ./configure --prefix=/mingw --disable-shared
    make
    make install


  5. Live555 library


    The Live555 library is used to decode streaming media. Get the live555 source from here and compile it as follows:

    cd /mingw/lib
    tar xzvf live.2009.07.28.tar.gz
    cd live
    ./genMakefiles mingw
    make


  6. LAME


    LAME is an MP3 encoder. This library allows Mencoder to encode DVD sound into MP3 audio. Download LAME from lame.sf.net and compile it as follows.


    ./configure --prefix=/mingw --enable-expopt=full

    make

    make install


  7. TwoLame


    TwoLAME is an MP2 audio encoder. Get the source from twolame.org and compile it:

    ./configure --prefix=/mingw CPPFLAGS='-DLIBTWOLAME_STATIC'
    make
    make install


  8. XviD


    In case you didn't know, XviD is the most popular video encoder used in creating movie files found on the P2P networks. With this library, mencoder can rip a DVD into XviD video. Get the XviD source from xvid.org and compile as follows:


    tar xzvf xvidcore-1.2.2.tar.gz

    cd xvidcore/build/generic

    ./configure --prefix=/mingw

    make

    make install

    In addition, change to the /mingw/bin directory and copy xvidcore.a to libxvidcore.a.


    cd /mingw/lib

    cp xvidcore.a libxvidcore.a


  9. FAAC


    FAAC is an MPEG-4 AAC audio encoder. Get the source (faac-1.28.tar.gz) and unpack the package. Then, edit Makefile.am:

    SUBDIRS = include libfaac

    Also, edit the line beginning with AC_OUTPUT in the file configure.in:

    AC_OUTPUT(libfaac/Makefile include/Makefile Makefile)

    Then, compile FAAC like this

    sh bootstrap
    ./configure --prefix=/mingw --enable-static --disable-shared
    make
    make install


  10. x264


    x264 is yet another good video encoder. x264 requires YASM to build an optimized executable. So get yasm and save it as /mingw/bin/yasm.exe. Then, compile x264 like this:


    sh configure --prefix=/mingw --extra-cflags="-DX264_VERSION=20090608"

    make

    make install


  11. Compiling Mencoder


    Now you're ready to compile mencoder. Download the MPlayer source snapshot from mplayerhq.hu and unpack it. Then, type the following commands into the MSYS window to produce the executable mencoder.exe.


    CPPFLAGS='-DHAVE_INT32_T -DLIBTWOLAME_STATIC'./configure --prefix=/mingw --enable-runtime-cpudetection --enable-static --enable-theora --yasm=/mingw/bin/yasm

    make mencoder

    strip *.exe

    mv -iv mencoder.exe /c/Windows

    This produces a static executable mencoder.exe and copies it into the C:\WINDOWS folder.




If you'd like to try my mencoder build, download it from here. Its filename is MPlayer-svn-r30521-snapshot-3.4.5.zip.

Friday, June 5, 2009

Building gtk-gnutella for Windows

I built gtk-gnutella for the Windows platform using MinGW. gtk-gnutella is an application that allows you to share files in the gnutella P2P network. Here I show how I built GTK-gnutella step-by-step:




  1. Install MinGW


    First of all, I installed MinGW. GCC 4.4 and higher versions are recommended.



  2. Compile Pthread and Regex (Optional)


    Build pthread and regex as shown in the following posts.




  3. Build GTK+ Library


    Follow the instruction in the following post to compile the whole GTK+ library.




  4. Build GnuTLS (Optional)


    I think GnuTLS is optional but it provides secure communication between gnutella clients. I chose to build GTK-gnutella with gnuTLS features. So I compiled GnuTLS as shown in this post.



  5. Unpack the Source


    Then, I downloaded the gtk-gnutella source and unpacked it in my HOME directory.


    cd $HOME

    tar xjvf gtk-gnutella-0.96.6.tar.bz2

    cd gtk-gnutella-0.96.6


  6. Run the Configure script


    Then, I ran ./Configure. For convenience, I am providing here my config.sh file generated by the Configure script. You can copy this file to your source tree before running the Configure script.


    #!/bin/sh
    #
    # This file was produced by running the Configure script. It holds all the
    # definitions figured out by Configure. Should you modify one of these values,
    # do not forget to propagate your changes by running "Configure -der". You may
    # instead choose to run each of the .SH files by yourself, or "Configure -S".
    #

    # Package name : gtk-gnutella
    # Source directory : .
    # Configuration time: Wed Aug 15 14:50:53 HST 2012
    # Configured by : Ken
    # Target system : mingw32_nt-6.1 a7n8x 1.0.17(0.4832) 2011-04-24 23:39 i686 msys

    : Configure command line arguments.
    config_arg0='./Configure'
    config_args=''
    config_argc=0

    Author=''
    Date=''
    Header=''
    Id='$Id'
    Locker=''
    Log=''
    RCSfile=''
    Revision=''
    Source=''
    State=''
    _a='.a'
    _exe='.exe'
    _o='.o'
    afs='false'
    afsroot='/afs'
    alignbytes='8'
    aphostname=''
    ar='/mingw/bin/ar'
    archlib='/mingw/lib/gtk-gnutella'
    archlibexp='/mingw/lib/gtk-gnutella'
    archname='i686-mingw'
    archobjs=''
    awk='/bin/awk'
    bash=''
    bin='/mingw/bin'
    binexp='/mingw/bin'
    bison='/bin/bison'
    byacc='byacc'
    byteorder='1234'
    c=''
    cat='/bin/cat'
    cc='/mingw/bin/gcc.exe'
    ccflags='-march=pentium2 -mtune=i586 -pipe -Wall -Wshadow -DMINGW32 -D_POSIX'
    ccname='gcc'
    ccversion=''
    cf_by='Ken'
    cf_time='Wed Aug 15 14:50:53 HST 2012'
    charsize='1'
    chgrp='/bin/chgrp'
    chmod='/bin/chmod'
    chown='/bin/chown'
    clocktype='int'
    comm=''
    compress=''
    contains='grep'
    cp='/bin/cp'
    cpio=''
    cpp='/mingw/bin/cpp'
    cpp_quote=''
    cpp_stuff='42'
    cppfilter=''
    cppflags='-march=pentium2 -mtune=i586 -pipe -Wall -Wshadow -DMINGW32 -D_POSIX'
    cpplast='-'
    cppminus='-'
    cpprun='/mingw/bin/gcc.exe -E'
    cppstdin='/mingw/bin/gcc.exe -E'
    csh=''
    d_access='define'
    d_alarm='undef'
    d_arc4random='undef'
    d_archlib='define'
    d_attribut='define'
    d_backtrace='undef'
    d_bcmp='undef'
    d_bcopy='undef'
    d_bfd_lib='undef'
    d_bindtxtcode='define'
    d_bsd='undef'
    d_built_clz='define'
    d_built_ctz='define'
    d_built_popcount='define'
    d_bzero='undef'
    d_can64='define'
    d_closefrom='undef'
    d_const='define'
    d_dbus='undef'
    d_deflate='define'
    d_dev_poll='undef'
    d_dirent_d_type='undef'
    d_dirnamlen=''
    d_dladdr='undef'
    d_dos='undef'
    d_enablenls='define'
    d_end_symbol='define'
    d_eofnblk='define'
    d_epoll='undef'
    d_etext_symbol='undef'
    d_eunice='undef'
    d_fast_assert='undef'
    d_fork='undef'
    d_ftime='undef'
    d_getaddrinfo='define'
    d_geteuid='undef'
    d_gethname='undef'
    d_getifaddrs='undef'
    d_getinvent='undef'
    d_getlogin='undef'
    d_getppid='undef'
    d_gettblsz='define'
    d_gettext='define'
    d_gettimeod='define'
    d_getuid='undef'
    d_glib='define'
    d_gnulibc='undef'
    d_gnutls='define'
    d_gtk='define'
    d_headless='undef'
    d_herror='undef'
    d_hstrerror='undef'
    d_iconv='define'
    d_ieee754='define'
    d_ilp32='define'
    d_ilp64='undef'
    d_index='undef'
    d_inflate='define'
    d_iptos='undef'
    d_ipv6='define'
    d_isascii='define'
    d_kevent_int_udata='undef'
    d_kqueue='undef'
    d_linux='undef'
    d_locale_charset='undef'
    d_lp64='undef'
    d_lstat='undef'
    d_madvise='undef'
    d_memalign='undef'
    d_memcpy='define'
    d_memmove='define'
    d_mempcpy='undef'
    d_mmap='undef'
    d_msghdr_msg_flags='undef'
    d_nanosleep='undef'
    d_nls='define'
    d_official='define'
    d_open3='define'
    d_os2='undef'
    d_pause='undef'
    d_phostname='undef'
    d_poll='undef'
    d_popen='define'
    d_portable='undef'
    d_posix_fadvise='undef'
    d_posix_memalign='undef'
    d_pread='undef'
    d_preadv='undef'
    d_pwage='undef'
    d_pwchange='undef'
    d_pwclass='undef'
    d_pwcomment='undef'
    d_pwexpire='undef'
    d_pwquota='undef'
    d_pwrite='undef'
    d_pwritev='undef'
    d_recvmsg='undef'
    d_regcomp='define'
    d_regparm='define'
    d_remotectrl='undef'
    d_rusage='undef'
    d_sbrk='undef'
    d_sched_yield='undef'
    d_select='define'
    d_sendfile='undef'
    d_setproctitle='undef'
    d_setsid='undef'
    d_sigaction='undef'
    d_sigprocmask='undef'
    d_sigsetjmp='undef'
    d_sockaddr_in_sin_len='undef'
    d_sockaddr_un='undef'
    d_socker_get='undef'
    d_statfs='undef'
    d_statvfs='undef'
    d_strchr='define'
    d_strlcat='undef'
    d_strlcpy='undef'
    d_sync_atomic='define'
    d_sysctl='undef'
    d_system='define'
    d_times='undef'
    d_ttyname='undef'
    d_uctx_mctx='undef'
    d_uctx_mctx_gregs='undef'
    d_uname='undef'
    d_useglib1='undef'
    d_useglib2='define'
    d_usegtk1='undef'
    d_usegtk2='define'
    d_usleep='define'
    d_voidsig='define'
    d_volatile='define'
    d_vsnprintf='define'
    d_waitpid='undef'
    d_windows='define'
    d_xenix='undef'
    date='/bin/date'
    dbuscflags=''
    dbusconfig='false'
    dbusldflags=''
    defvoidused='15'
    direntrytype=''
    eagain='EAGAIN'
    ebcdic='undef'
    echo='/bin/echo'
    egrep='/bin/egrep'
    emacs=''
    enablenls='true'
    eunicefix=':'
    expr='/bin/expr'
    fieldn='3'
    find=''
    firstmakefile=''
    flex=''
    from=':'
    gcc=''
    gccosandvers=''
    gccversion='4'
    glade='glade-2'
    glibcflags='-mms-bitfields -I/mingw/include/glib-2.0 -I/mingw/lib/glib-2.0/include -I/mingw/include'
    glibconfig='pkg-config glib-2.0 gobject-2.0'
    glibldflags='-L/mingw/lib -lgobject-2.0 -lgthread-2.0 -lglib-2.0 -lintl '
    glibpackage='glib-2.0 gobject-2.0'
    glibpth='/mingw/lib'
    glibversion='2'
    gmake=''
    gmsgfmt='/mingw/bin/msgfmt'
    gnulibc_version=''
    gnutlscflags=''
    gnutlsconfig='pkg-config gnutls'
    gnutlsldflags='-L/mingw/lib -lgnutls'
    grep='/bin/grep'
    groupcat=':'
    gtkcflags='-mms-bitfields -I/mingw/include/gtk-2.0 -I/mingw/lib/gtk-2.0/include -I/mingw/include/atk-1.0 -I/mingw/include/cairo -I/mingw/include/gdk-pixbuf-2.0 -I/mingw/include/pango-1.0 -I/mingw/include/glib-2.0 -I/mingw/lib/glib-2.0/include -I/mingw/include -I/mingw/include/pixman-1 -I/mingw/include/libpng15'
    gtkconfig='pkg-config gtk+-2.0'
    gtkgversion='0.98.3'
    gtkldflags='-Wl,-luuid -L/mingw/lib -lgtk-win32-2.0 -lgdk-win32-2.0 -limm32 -lshell32 -lole32 -latk-1.0 -lpangocairo-1.0 -lgio-2.0 -lgdk_pixbuf-2.0 -lpangowin32-1.0 -lgdi32 -lpango-1.0 -lcairo -lgobject-2.0 -lgmodule-2.0 -lgthread-2.0 -lglib-2.0 -lintl'
    gtkpackage='gtk+-2.0'
    gtkversion='2'
    gzip=''
    h_fcntl='false'
    h_sysfile='true'
    hint='previous'
    hostcat=':'
    huge=''
    i_alloca='undef'
    i_arpainet='undef'
    i_dirent='define'
    i_dlfcn='undef'
    i_execinfo='undef'
    i_fcntl='undef'
    i_iconv='define'
    i_ifaddrs='undef'
    i_inttypes='define'
    i_invent='undef'
    i_langinfo='undef'
    i_libcharset='define'
    i_libintl='define'
    i_limits='define'
    i_linux_netlink='undef'
    i_linux_rtnetlink='undef'
    i_malloc='define'
    i_math='define'
    i_mswsock='define'
    i_netdb='undef'
    i_netif='undef'
    i_netroute='undef'
    i_niin='undef'
    i_niip='undef'
    i_poll='undef'
    i_pthread='define'
    i_pwd='undef'
    i_regex='define'
    i_sched='define'
    i_stdarg='define'
    i_stdlib='define'
    i_string='define'
    i_sysfile='define'
    i_sysin='undef'
    i_sysmman='undef'
    i_sysmount='undef'
    i_sysparam='define'
    i_syspoll='undef'
    i_sysresrc='undef'
    i_sysselct='undef'
    i_syssendfile='undef'
    i_syssock='undef'
    i_sysstat='define'
    i_sysstatvfs='undef'
    i_syssysctl='undef'
    i_systime='define'
    i_systimeb='define'
    i_systimek='undef'
    i_systimes='undef'
    i_systypes='define'
    i_sysun='undef'
    i_sysutsname='undef'
    i_sysvfs='undef'
    i_syswait='undef'
    i_time='undef'
    i_ucontext='undef'
    i_unistd='define'
    i_varargs='undef'
    i_varhdr='stdarg.h'
    i_winsock2='define'
    i_ws2tcpip='define'
    i_zlib='define'
    ieee754_byteorder='1234'
    ilp='32'
    incpath=''
    inews=''
    install='/bin/install.exe'
    installarchlib='/mingw/lib/gtk-gnutella'
    installbin='/mingw/bin'
    installdir='mkdir -p'
    installmansrc=''
    installprivlib='/mingw/lib/gtk-gnutella'
    intsize='4'
    issymlink=''
    ksh=''
    large=''
    ldflags='-Wl,--enable-auto-image-base -Wl,--enable-auto-import -Wl,--enable-runtime-pseudo-reloc'
    less=''
    libc=''
    libnames=''
    libpth='/mingw/lib'
    libs='-liberty -lws2_32 -lpthread -lregex -lz -lintl -liconv -limagehlp -liphlpapi -lpowrprof -lpsapi -lkernel32'
    libscheck=''
    libsdirs=' /mingw/lib'
    libsfiles=' libbfd.a libm.a'
    libsfound=' /mingw/lib/libbfd.a /mingw/lib/libm.a'
    libspath=' /mingw/lib /mingw/lib'
    libswanted='bfd iberty sendfile z resolv iconv m intl dl'
    line=''
    lint=''
    lkflags=''
    ln='/bin/ln'
    lns='ln -s'
    locale='/mingw/share/locale'
    localeexp='/mingw/share/locale'
    locincpth=''
    loclibpth=''
    longsize='4'
    lp=''
    lpr=''
    ls=''
    mail=''
    mailx=''
    make='/bin/make'
    make_set_make='#'
    manext='0'
    mansrc=' '
    mansrcexp=''
    medium=''
    mips_type=''
    mkdep='/c/Users/Ken/Downloads/gtk-gnutella-0.98.3/mkdep'
    mkdir='/bin/mkdir'
    models='none'
    more=''
    msgfmt='/mingw/bin/msgfmt'
    msgmerge='/mingw/bin/msgmerge'
    msgmerge_update='/mingw/bin/msgmerge --update'
    mv='/bin/mv'
    myarchname='i686-mingw'
    mydomain=''
    myhostname='lenovo-a8nvm'
    myuname='mingw32_nt-6.1 a7n8x 1.0.17(0.4832) 2011-04-24 23:39 i686 msys '
    n='-n'
    nawk='/bin/nawk'
    nm='/mingw/bin/nm'
    nm_opt=''
    nm_so_opt=''
    nofile=''
    nroff='nroff'
    o_nonblock=''
    official='true'
    optimize='-O2 -g0'
    orderlib='false'
    osname='mingw'
    osvers='1.0.17'
    package='gtk-gnutella'
    passcat=':'
    perl=''
    pg=''
    phostname='hostname'
    pkgsrc='/home/Ken/Downloads/gtk-gnutella-0.98.3'
    plibpth=''
    pmake=''
    pr=''
    prefix='/mingw'
    prefixexp='/mingw'
    privlib='/mingw/lib/gtk-gnutella'
    privlibexp='/mingw/lib/gtk-gnutella'
    prototype='define'
    ptrsize='4'
    ranlib=':'
    rd_nodata=''
    remotectrl='false'
    rm='/bin/rm'
    rmail=''
    run=''
    runnm='false'
    sed='/bin/sed'
    sendmail=''
    sh='/bin/sh'
    shar=''
    sharpbang='#!'
    shortsize='2'
    shsharp='true'
    sig_count='23'
    sig_name='ZERO NUM1 INT NUM3 ILL NUM5 NUM6 NUM7 FPE NUM9 NUM10 SEGV NUM12 NUM13 NUM14 TERM NUM16 NUM17 NUM18 NUM19 NUM20 BREAK ABRT '
    sig_name_init='"ZERO", "NUM1", "INT", "NUM3", "ILL", "NUM5", "NUM6", "NUM7", "FPE", "NUM9", "NUM10", "SEGV", "NUM12", "NUM13", "NUM14", "TERM", "NUM16", "NUM17", "NUM18", "NUM19", "NUM20", "BREAK", "ABRT", 0'
    sig_num='0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 '
    sig_num_init='0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 0'
    sig_size='23'
    signal_t='void'
    sleep=''
    smail=''
    small=''
    so='dll'
    sockercflags=''
    sockerldflags=''
    sort='/bin/sort'
    spackage='Gtk-gnutella'
    spitshell='cat'
    split=''
    src='.'
    startsh='#!/bin/sh'
    strings='/mingw/include/string.h'
    submit=''
    sysman='/mingw/share/man'
    tablesize='NOFILE'
    tail=''
    tar=''
    targetarch=''
    tbl=''
    tee=''
    test='test'
    timeincl='/mingw/include/sys/time.h '
    to=':'
    touch='/bin/touch'
    tr='/bin/tr'
    trnl='\n'
    troff=''
    uname='/bin/uname'
    uniq='/bin/uniq'
    usecrosscompile='undef'
    usenm='false'
    usrinc='/mingw/include'
    uuname=''
    vi=''
    voidflags='15'
    wc='/bin/wc'
    xgettext='/mingw/bin/xgettext'
    xlibpth='/mingw/lib'
    yacc='bison -y'
    yaccflags=''
    zcat=''
    zip=''
    CONFIG=true

    Alternatively, if your config.sh needs no modification, just run the following commands.


    ./Configure -S
    make depend


  7. Before running make, open src/Makefile and insert -mwindows into the gtk-gnutella section:

  8. gtk-gnutella:  $(OBJ) $(EXTRA)
    $(RM) $@
    if test -f $@$(_EXE); then \
    $(MV) $@$(_EXE) $@~$(_EXE); fi
    $(CC) -o $@ $(OBJ) $(EXTRA) -mwindows $(JLDFLAGS) $(LIBS)

    This prevents GTK-gnutella from outputting error logs to a black console window.



  9. Then, I compiled gtk-gnutella with the following commands:


    make

    make install




gtk-gnutella_winnt

Monday, January 26, 2009

Installing MinGW on Windows

MinGW is a free software development system for Windows. Not only is MinGW useful for porting Linux software to Windows, but you can also use MinGW to write native Windows programs. The following is an excerpt from the MinGW web site:


MinGW: A collection of freely available and freely distributable Windows specific header files and import libraries, augmenting the GNU Compiler Collection (GCC) and its associated tools (GNU binutils). MinGW provides a complete Open Source programming tool set which is suitable for the development of native Windows programs that do not depend on any 3rd-party C runtime DLLs.

Now, let's install MinGW. Note that MinGW doesn't run smoothly on Windows Vista because of weird filesystem restrictions. The workaround is:




  • to install MinGW in your home folder (C:\Users\username) or a public folder (somewhere in C:\Users\Public, for example, C:\Users\Public\Desktop)
  • to run MSYS (rxvt) as administrator (Right-click and select Run as administrator)
  • to install MinGW on FAT filesystem,
  • to work in the safe mode, or
  • to use MinGW Portable which is said to be working well.


To Set up the Latest MinGW


To have a functional MinGW installation, just download and run the latest MinGW installer.





To Set up GCC toolchain 3.4.5


To install the outdated GCC toolchain 3.4.5, download the following installers and run them in the order:




After Installation


After successfully installing MSYS, check the file /etc/fstab inside the MSYS folder. Mine looks like:


C:/MinGW /mingw
C:/MinGW /usr/local


You can try MSYS by double-clicking the MSYS icon on the desktop. This will bring up a console window where you can type in some UNIX commands. For example, the following command will display the version of installed GCC compiler:


$ gcc --version
gcc.exe (GCC) 3.4.5 (mingw-vista special r3)
Copyright (C) 2004 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


The environment variable HOME can be used to set the user's working directory. If your username has a space or foreign character, it may confuse MinGW and hinder the compile process. In Windows Vista and Windows 7, access restriction is imposed outside C:\Users. In such cases, set $HOME to some other location. For example, set the HOME variable like this:




Don't forget to create ~/.profile. This file can be used to set environment variables, such as CC, CFLAGS, CXXFLAGS, CPPFLAGS and LDFLAGS. These environment variables are used to customize the compiler settings. The following is my .profile contents:


CC=/mingw/bin/gcc.exe
CFLAGS='-march=pentium2 -mtune=i586 -mthreads -mms-bitfields -O2'
CXXFLAGS='-march=pentium2 -mtune=i586 -mthreads -mms-bitfields -O2'
LDFLAGS='-Wl,--enable-auto-image-base,--enable-auto-import,--enable-runtime-pseudo-reloc'
PKG_CONFIG_PATH=/mingw/lib/pkgconfig
TERM=cygwin
export CC CFLAGS CXXFLAGS LDFLAGS PKG_CONFIG_PATH TERM


Testing GCC with simple codes


Let's compile a very simple C program. Using a text editor, such as Notepad, create a text file called test.c:


#include <stdio.h>

int main(void)
{
printf("Greetings, ladies and gentlemen.\n");
return 0;
}


The following command will produce an executable code.


gcc -o test.exe test.c


Now, let's try a very simple C++ code:



#include <iostream>
using namespace std;

int main()
{
cout << "Hello, boys and girls.\n";
return 0;
}


To build it, type:


g++ -o test.exe test.cpp


Additonal Tools to Install


You can optionally install other tools from the MinGW download site, such as mingw-utils and bison. mingw-utils provides some useful tools, including dos2unix, a2dll, pexports and reimp. I find dos2unix particularly useful as it converts DOS-style line endings (CR+LF) to UNIX-style (LF) in text files. mingw-utils should be extracted into the MinGW folder and bison should be extracted into the MSYS folder.


Some tools are commonly used in the Linux development environment, such as pkg-config and msgfmt. I've compiled static versions of these programs in order to ease compiling processes. Download them from the links below and place them in /mingw/bin.




Integrated Development Environments for MinGW


If you prefer to use a convenient IDE to the command line, you have several choices:





Related Posts


About This Blog

KBlog logo This blog seeks to share useful information on freely available fonts on the Internet. Thanks for visiting the blog and posting your comments.

© Contents by KBlog

© Blogger template by Emporium Digital 2008

Followers

Total Pageviews

CyberChimps Professional WordPress Themes
Powered By Blogger