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

4 comments:

  1. Cool man! Can you please single zip/rar from your build and send it to guys from
    http://gtk-gnutella.sourceforge.net/ or make it available in some other way? so everyone could just unpack it and use it... maybe you can send them your HOWTO also...

    ReplyDelete
  2. i am giving up... ;)
    i tried to compile gtk-gnutella against cygwin and gtk+ bundle from gtk.org. everythink compiled just fine, but when it tried to link, it failed with this error:

    cc -o gtk-gnutella main.o if/bridge/ui2c.o if/bridge/c2ui.o if/gnet_property.o if/gui_property.o -mwindows -Lshell -lsh
    ell -Lcore -lcore -Ldht -ldht -Lui/gtk -lgtk-common -lgtkx -lgtk-common -ldht -lcore -Llib -lshared -Lsdbm -lsdbm -lshar
    ed -L/devel/dist/win32/expat-2.0.1-1/lib -L/devel/dist/win32/freetype-2.3.11-1/bin/../lib -lgtk-win32-2.0 -lgdk-win32-2.
    0 -latk-1.0 -lgio-2.0 -lgdk_pixbuf-2.0 -lpangowin32-1.0 -lgdi32 -lpangocairo-1.0 -lpango-1.0 -lcairo -lm -lfontconfig -l
    expat -lfreetype -lpng12 -lz -lgobject-2.0 -lgmodule-2.0 -lglib-2.0 -lintl -lgobject-2.0 -lglib-2.0 -lintl -lxml2 -l
    z -liconv -lm -lgnutls -ltasn1 -O2 -g -lz -lresolv -liconv -lm -lintl
    main.o: In function `main':
    /home/Harvie/src/gtk-gnutella-0.96.6/src/main.c:1217: undefined reference to `___printf__'
    /home/Harvie/src/gtk-gnutella-0.96.6/src/main.c:1221: undefined reference to `___printf__'
    /home/Harvie/src/gtk-gnutella-0.96.6/src/main.c:1228: undefined reference to `___printf__'
    /home/Harvie/src/gtk-gnutella-0.96.6/src/main.c:1231: undefined reference to `___printf__'
    /home/Harvie/src/gtk-gnutella-0.96.6/src/main.c:1234: undefined reference to `___printf__'
    main.o:/home/Harvie/src/gtk-gnutella-0.96.6/src/main.c:1241: more undefined references to `___printf__' follow
    collect2: ld returned 1 exit status
    make: *** [gtk-gnutella] Error 1


    did you also experienced this problem?

    ReplyDelete
  3. I uploaded my gtk-gnutella build. Read this post.

    ReplyDelete
  4. From http://users.libero.it/efa/gtkCygwinEn.html

    N.B.2 if sources use ?printf, and in link stage you got an error for:
    undefined reference to '___printf__'
    it is necessary to add '-mno-cygwin' in src/Makefile:
    CFLAGS = -g -O2 -Wall -mno-cygwin
    clean and rebuild all.

    ReplyDelete

About This Blog

KBlog logo This blog seeks to provide a collection of interesting pictures found on the Web. Thanks for visiting the blog and posting your comments.

© Contents by KBlog

© Blogger template by Emporium Digital 2008

Followers

Total Pageviews

Powered By Blogger