Bug 1214605 - Build failure on MinGW64
Summary: Build failure on MinGW64
Alias: None
Product: Virtualization Tools
Classification: Community
Component: libvirt
Version: unspecified
Hardware: x86_64
OS: Windows
Target Milestone: ---
Assignee: Libvirt Maintainers
QA Contact:
Depends On:
TreeView+ depends on / blocked
Reported: 2015-04-23 08:08 UTC by Pavel Fedin
Modified: 2015-04-28 15:45 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Last Closed: 2015-04-28 15:45:23 UTC

Attachments (Terms of Use)

Description Pavel Fedin 2015-04-23 08:08:48 UTC
Description of problem:

 libvirt currently fails to build for 64-bit Windows because of missing index() function. First it produces a warning:
--- cut ---
util/virstring.c:1006:9: warning: implicit declaration of function 'index' [-Wimplicit-function-declaration]
         if (index(control_chars, str[i]))
--- cut ---
 but when linking it fails with "undefined symbol" error. MinGW's libc does not have deprecated index() and rindex(). The solution is to replace index() with strchr().

Version-Release number of selected component (if applicable):

 git HEAD

How reproducible:

 configure and build it natively under MinGW64

Comment 1 Eric Blake 2015-04-23 14:19:18 UTC
Fixed upstream. For issues like this, proposing the (obvious) patch to libvir-list@redhat.com is faster (and less hoops to jump through) than opening up a bug report, especially when the bug only affects git builds and not a released tarball.

commit 1268820a632846267b75432dc155779a716e289c
Author: Eric Blake <eblake@redhat.com>
Date:   Thu Apr 23 08:13:53 2015 -0600

    build: avoid obsolete index()
    Commit 2a530a3e5 is not portable to mingw, which intentionally
    avoids declaring the obsolete index().  See also:
    * src/util/virstring.c (virStringStripControlChars): Use strchr.
    Signed-off-by: Eric Blake <eblake@redhat.com>

Comment 2 Pavel Fedin 2015-04-24 11:39:53 UTC
 I decided to reopen it because there is additional problem affecting MinGW build. LDFLAGS definitions for all shared libraries in tests/Makefile.am miss $(MINGW_EXTRA_LDFLAGS) addon, and virnetserverclientmock_la_LDFLAGS needs also $(GNULIB_LIBS).
MINGW_EXTRA_LDFLAGS specified -no-undefined, without which building shared library fails on MinGW. The later explicitly adds gnulib, this is necessary because .dll module on Windows has to be self-contained, it cannot import anything from the executable which is importing the dll (without special tricks).
 Sorry, i cannot post patches, because i am reporting from my workplace, and according to regulations of our company i need an explicit approval to post patches. Currently it is being processed, and it can take a long time. Much longer than fixing the bug as described (reporting and discussion is OK here).

Comment 3 Eric Blake 2015-04-24 20:29:54 UTC
Normally, I'd suggest that you use a separate bug for separate issues.  But reopening is probably okay here.

Meanwhile, let me reiterate that since the issue you are seeing affects the latest libvirt.git, you'll probably  get faster response by posting on the upstream libvir-list@redhat.com mailing list than you will by making a BZ.

Comment 4 Martin Kletzander 2015-04-28 15:45:23 UTC
This should be fixed upstream by commits v1.2.14-324-g9dc57ce and v1.2.15-rc1-16-g922563e:

commit 9dc57ce2c49e06b206504b45d1104ac641761c57
Author:     Pavel Fedin <p.fedin@samsung.com>
AuthorDate: Mon Apr 27 13:40:53 2015 +0300

    Add missing linker flags for MinGW build

commit 922563e73ab5585205aba7a15ead04c458b9c02a
Author: Martin Kletzander <mkletzan@redhat.com>
Date:   Mon Apr 27 15:59:18 2015 +0200

    Fix building virnetserverclientmock with MinGW

Note You need to log in before you can comment on or make changes to this bug.