如何在mingw-w64 win32线程上构建静态glib库

时间:2019-02-03 01:05:51

标签: winapi glib mingw-w64 msys2 meson-build

我想构建一个glib静态库。我已经安装了MSYS2,并且已经在上面安装了MinGW-W64 Win32线程。我没有下载MSYS2软件包。相反,我从SourceForge下载了MinGW-W64,并将其安装到MSYS2目录。这就是我设置系统的方式。我对编译需要安装GLib的GTK + 3.24静态库感兴趣。如何通过以下设置构建静态库?我对用于编译GLib的Meson构建系统不熟悉。我也不知道如何传递安装前缀和构建静态库。命令

    meson builddir

给出以下输出:

The Meson build system
Version: 0.49.0
Source dir: /home/Sean/glib-2.59.1
Build dir: /home/Sean/glib-2.59.1/builddir
Build type: native build
Project name: glib
Project version: 2.59.1
Native C compiler: gcc (gcc 8.1.0 "gcc.exe (i686-win32-dwarf-rev0, Built by MinGW-W64 project) 8.1.0")
Native C++ compiler: c++ (gcc 8.1.0 "c++.exe (i686-win32-dwarf-rev0, Built by MinGW-W64 project) 8.1.0")
Build machine cpu family: x86
Build machine cpu: x86
Compiler for C supports arguments -fno-strict-aliasing: YES
Checking if "GNU C visibility attributes test" compiles: NO
Compiler for C supports arguments -fvisibility=hidden: YES
Has header "alloca.h" : NO
Has header "crt_externs.h" : NO
Has header "dirent.h" : YES
Has header "float.h" : YES
Has header "fstab.h" : NO
Has header "grp.h" : NO
Has header "inttypes.h" : YES
Has header "limits.h" : YES
Has header "linux/magic.h" : NO
Has header "locale.h" : YES
Has header "mach/mach_time.h" : NO
Has header "memory.h" : YES
Has header "mntent.h" : NO
Has header "poll.h" : NO
Has header "pwd.h" : NO
Has header "sched.h" : YES
Has header "spawn.h" : NO
Has header "stdint.h" : YES
Has header "stdlib.h" : YES
Has header "string.h" : YES
Has header "strings.h" : YES
Has header "sys/auxv.h" : NO
Has header "sys/event.h" : NO
Has header "sys/filio.h" : NO
Has header "sys/inotify.h" : NO
Has header "sys/mkdev.h" : NO
Has header "sys/mntctl.h" : NO
Has header "sys/mnttab.h" : NO
Has header "sys/mount.h" : NO
Has header "sys/param.h" : YES
Has header "sys/resource.h" : NO
Has header "sys/select.h" : NO
Has header "sys/statfs.h" : NO
Has header "sys/stat.h" : YES
Has header "sys/statvfs.h" : NO
Has header "sys/sysctl.h" : NO
Has header "sys/time.h" : YES
Has header "sys/times.h" : NO
Has header "sys/types.h" : YES
Has header "sys/uio.h" : NO
Has header "sys/vfs.h" : NO
Has header "sys/vfstab.h" : NO
Has header "sys/vmount.h" : NO
Has header "sys/wait.h" : NO
Has header "termios.h" : NO
Has header "unistd.h" : YES
Has header "values.h" : NO
Has header "xlocale.h" : NO
Checking if "malloc.h" compiles: YES
Has header "linux/netlink.h" : NO
Header <locale.h> has symbol "LC_MESSAGES" : NO
Checking whether type "struct stat" has member "st_mtimensec" : NO
Checking whether type "struct stat" has member "st_mtim.tv_nsec" : NO
Checking whether type "struct stat" has member "st_atimensec" : NO
Checking whether type "struct stat" has member "st_atim.tv_nsec" : NO
Checking whether type "struct stat" has member "st_ctimensec" : NO
Checking whether type "struct stat" has member "st_ctim.tv_nsec" : NO
Checking whether type "struct stat" has member "st_birthtime" : NO
Checking whether type "struct stat" has member "st_birthtimensec" : NO
Checking whether type "struct stat" has member "st_birthtim" : NO
Checking whether type "struct stat" has member "st_birthtim.tv_nsec" : NO
Checking whether type "struct stat" has member "st_blksize" : NO
Checking whether type "struct stat" has member "st_blocks" : NO
Checking whether type "struct statfs" has member "f_fstypename" : NO
Checking whether type "struct statfs" has member "f_bavail" : NO
Checking whether type "struct dirent" has member "d_type" : NO
Checking whether type "struct statvfs" has member "f_basetype" : NO
Checking whether type "struct statvfs" has member "f_fstypename" : NO
Checking whether type "struct tm" has member "tm_gmtoff" : NO
Checking whether type "struct tm" has member "__tm_gmtoff" : NO
Compiler for C supports arguments -Wall: YES
Compiler for C supports arguments -Wduplicated-branches: YES
Compiler for C supports arguments -Wimplicit-fallthrough: YES
Compiler for C supports arguments -Wmisleading-indentation: YES
Compiler for C supports arguments -Wstrict-prototypes: YES
Compiler for C supports arguments -Wunused: YES
Compiler for C supports arguments -Wno-bad-function-cast -Wbad-function-cast: YES
Compiler for C supports arguments -Wno-pedantic -Wpedantic: YES
Compiler for C supports arguments -Werror=declaration-after-statement: YES
Compiler for C supports arguments -Werror=format=2: YES
Compiler for C supports arguments -Werror=implicit-function-declaration: YES
Compiler for C supports arguments -Werror=init-self: YES
Compiler for C supports arguments -Werror=missing-include-dirs: YES
Compiler for C supports arguments -Werror=missing-prototypes: YES
Compiler for C supports arguments -Werror=pointer-arith: YES
Compiler for C supports link arguments -Wl,-z,nodelete: NO
Compiler for C supports link arguments -Wl,-Bsymbolic-functions: YES
Checking for function "endmntent" : NO
Checking for function "endservent" : NO
Checking for function "fallocate" : NO
Checking for function "fchmod" : NO
Checking for function "fchown" : NO
Checking for function "fdwalk" : NO
Checking for function "fsync" : NO
Checking for function "getauxval" : NO
Checking for function "getc_unlocked" : NO
Checking for function "getfsstat" : NO
Checking for function "getgrgid_r" : NO
Checking for function "getmntent_r" : NO
Checking for function "getpwuid_r" : NO
Checking for function "getresuid" : NO
Checking for function "getvfsstat" : NO
Checking for function "gmtime_r" : NO
Checking for function "hasmntopt" : NO
Checking for function "inotify_init1" : NO
Checking for function "issetugid" : NO
Checking for function "kevent" : NO
Checking for function "kqueue" : NO
Checking for function "lchmod" : NO
Checking for function "lchown" : NO
Checking for function "link" : NO
Checking for function "localtime_r" : NO
Checking for function "lstat" : NO
Checking for function "mbrtowc" : YES
Checking for function "memalign" : NO
Checking for function "mmap" : NO
Checking for function "newlocale" : NO
Checking for function "pipe2" : NO
Checking for function "poll" : NO
Checking for function "prlimit" : NO
Checking for function "readlink" : NO
Checking for function "recvmmsg" : NO
Checking for function "sendmmsg" : NO
Checking for function "setenv" : NO
Checking for function "setmntent" : NO
Checking for function "strerror_r" : NO
Checking for function "strnlen" : YES
Checking for function "strsignal" : NO
Checking for function "strtod_l" : NO
Checking for function "strtoll_l" : NO
Checking for function "strtoull_l" : NO
Checking for function "symlink" : NO
Checking for function "timegm" : NO
Checking for function "unsetenv" : NO
Checking for function "uselocale" : NO
Checking for function "utimes" : NO
Checking for function "valloc" : NO
Checking for function "vasprintf" : YES
Checking for function "vsnprintf" : YES
Checking for function "wcrtomb" : YES
Checking for function "wcslen" : YES
Checking for function "wcsnlen" : YES
Checking for function "sysctlbyname" : NO
Checking for function "_NSGetEnviron" : NO
Checking for function "if_indextoname" : NO
Checking for function "if_nametoindex" : NO
Checking for function "splice" : NO
Checking for function "stpcpy" : NO
Checking for function "posix_memalign" : NO
Checking for function "posix_spawn" : NO
Checking for function "snprintf" : YES
Checking for function "strcasecmp" : YES
Checking for function "strncasecmp" : YES
Header <sys/sysmacros.h> has symbol "major" : NO
Header <sys/mkdev.h> has symbol "major" : NO
Header <sys/types.h> has symbol "major" : NO
Header <dlfcn.h> has symbol "RTLD_LAZY" : NO
Header <dlfcn.h> has symbol "RTLD_NOW" : NO
Header <dlfcn.h> has symbol "RTLD_GLOBAL" : NO
Message: Checking whether to use statfs or statvfs .. neither
Checking if "futex(2) system call" links: NO
Checking if "eventfd(2) system call" links: NO
Checking if "clock_gettime" links: NO
Checking if "clock_gettime in librt" links: NO
Checking if "open() option O_DIRECTORY" compiles: NO
Checking if "C99 vsnprintf" runs: NO (1)
Checking if "C99 snprintf" runs: NO (1)
Checking if "Unix98 printf positional parameters" runs: NO (1)
Checking if "nl_langinfo and CODESET" links: NO
Checking if "nl_langinfo (PM_STR)" links: NO
Checking if "nl_langinfo (_NL_CTYPE_OUTDIGITn_MB)" links: NO
Checking if "nl_langinfo (ALTMON_n)" links: NO
Checking if "nl_langinfo (_NL_ALTMON_n)" links: NO
Checking if "signed" compiles: YES
Header <stddef.h> has symbol "ptrdiff_t" : YES
Checking if "sig_atomic_t" links: YES
Checking if "long long" compiles: YES
Checking if "long double" compiles: YES
Header <stddef.h> has symbol "wchar_t" : YES
Header <wchar.h> has symbol "wint_t" : YES
Checking if "uintmax_t in inttypes.h" compiles: YES
Checking if "uintmax_t in stdint.h" compiles: YES
Checking for size of "char" : 1
Checking for size of "short" : 2
Checking for size of "int" : 4
Checking for size of "void*" : 4
Checking for size of "long" : 4
Checking for size of "long long" : 8
Checking for size of "size_t" : 4
Checking for size of "ssize_t" : 4
Checking for alignment of "char" : 1
Checking for alignment of "short" : 2
Checking for alignment of "int" : 4
Checking for alignment of "void*" : 4
Checking for alignment of "long" : 4
Checking for alignment of "long long" : 8
Checking for alignment of "size_t" : 4
Checking if "__va_copy check" compiles: YES
Checking if "va_copy check" compiles: YES
Checking if "va_lists can be copied as values" runs: YES
Checking if "ISO C99 varargs macros in C" compiles: YES
Checking if "ISO C99 varargs macros in C++" compiles: YES
Checking if "GNUC varargs macros" compiles: YES
Has header "alloca.h" : NO
Has header "sys/poll.h" : NO
Has header "sys/types.h" : YES
Has header "winsock2.h" : YES

meson.build:1476:2: ERROR:  Entry _WIN32_WINNT not in configuration data.

我不确定如何告诉它设置安装前缀甚至启用静态构建。 谢谢

1 个答案:

答案 0 :(得分:0)

您应该能够使用-Ddefault_library=static构建glib,并且必须使用cross-file进行mingw,但是由于大多数库均不支持它,因此无法静态地构建整个GTK堆栈。因此,我个人建议使用共享库,这没有任何弊端,并且一切都会得到支持。