Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows(msys2 mingw)でコンパイルできない #21

Open
yumetodo opened this issue Jun 16, 2016 · 2 comments
Open

Windows(msys2 mingw)でコンパイルできない #21

yumetodo opened this issue Jun 16, 2016 · 2 comments

Comments

@yumetodo
Copy link

yumetodo commented Jun 16, 2016

msys2( https://msys2.github.io/ )のmingwでコンパイルできない。

環境構築

OSはWIndows7 x64

https://msys2.github.io/
よりインストーラーを落としてインストール、msys2_shell.cmdを実行して

pacman -S git mingw-w64-i686-gcc mingw-w64-x86_64-gcc mingw-w64-i686-postgresql mingw-w64-x86_64-postgresql

なお

$ pacman -Sl | grep pacman
msys pacman 5.0.1.6403.520736d-1 [インストール済み]
msys pacman-mirrors 20160112-1 [インストール済み]

再現手順

msys2_shell.cmdがあるディレクトリをコマンドプロンプトで開き

call msys2_shell.cmd -mingw64

そして

$ git clone https://github.com/nocotan/chppl-tool  
$ cd chppl-tool/chppl-tool/src
$ make

すると

$ make
gcc -g -std=c++11 -I C:/msys64/mingw64/include -I C:/msys64/mingw64/include/POST                                               GR~1/server -MD -MF obj/chppl.dep -o obj/chppl.o -c chppl.cpp
In file included from C:/msys64/mingw64/include/POSTGR~1/server/c.h:1114:0,
                 from C:/msys64/mingw64/include/POSTGR~1/server/postgres.h:47,
                 from ../include/common_pg.h:7,
                 from ../include/chppl.h:6,
                 from chppl.cpp:2:
C:/msys64/mingw64/include/POSTGR~1/server/port.h:17:19: fatal error: netdb.h: No                                                such file or directory
compilation terminated.
make: *** [makefile:20: obj/chppl.o] エラー 1

とコンパイルエラーになる。仕方ないので
./mingw64/include/postgresql/server/port.h

@@ -12,12 +12,12 @@
  */
 #ifndef PG_PORT_H
 #define PG_PORT_H

 #include <ctype.h>
-#include <netdb.h>
-#include <pwd.h>
+// #include <netdb.h>
+// #include <pwd.h>

 /* socket has a different definition on WIN32 */
 #ifndef WIN32
 typedef int pgsocket;

@@ -385,12 +385,12 @@
 #ifndef HAVE_RINT
 extern double rint(double x);
 #endif

 #ifndef HAVE_INET_ATON
-#include <netinet/in.h>
-#include <arpa/inet.h>
+// #include <netinet/in.h>
+// #include <arpa/inet.h>
 extern int inet_aton(const char *cp, struct in_addr * addr);
 #endif

 #if !HAVE_DECL_STRLCAT
 extern size_t strlcat(char *dst, const char *src, size_t siz);

のように書き換えた所

gcc -g -std=c++11 -I C:/msys64/mingw64/include -I C:/msys64/mingw64/include/POST                                               GR~1/server -MD -MF obj/chppl.dep -o obj/chppl.o -c chppl.cpp
In file included from C:/msys64/mingw64/include/POSTGR~1/server/postgres.h:48:0,
                 from ../include/common_pg.h:7,
                 from ../include/chppl.h:6,
                 from chppl.cpp:2:
C:/msys64/mingw64/include/POSTGR~1/server/utils/elog.h:41:0: warning: "ERROR" re                                               defined
 #define ERROR  20   /* user error - abort transaction; return to
 ^
In file included from C:/msys64/mingw64/x86_64-w64-mingw32/include/windows.h:71:                                               0,
                 from C:/msys64/mingw64/x86_64-w64-mingw32/include/winsock2.h:23                                               ,
                 from C:/msys64/mingw64/include/POSTGR~1/server/pg_config_os.h:3                                               7,
                 from C:/msys64/mingw64/include/POSTGR~1/server/c.h:101,
                 from C:/msys64/mingw64/include/POSTGR~1/server/postgres.h:47,
                 from ../include/common_pg.h:7,
                 from ../include/chppl.h:6,
                 from chppl.cpp:2:
C:/msys64/mingw64/x86_64-w64-mingw32/include/wingdi.h:75:0: note: this is the lo                                               cation of the previous definition
 #define ERROR 0
 ^
gcc -g -std=c++11 -I C:/msys64/mingw64/include -I C:/msys64/mingw64/include/POST                                               GR~1/server -MD -MF obj/common_pg.dep -o obj/common_pg.o -c common_pg.cpp
In file included from C:/msys64/mingw64/include/POSTGR~1/server/postgres.h:48:0,
                 from ../include/common_pg.h:7,
                 from common_pg.cpp:2:
C:/msys64/mingw64/include/POSTGR~1/server/utils/elog.h:41:0: warning: "ERROR" re                                               defined
 #define ERROR  20   /* user error - abort transaction; return to
 ^
In file included from C:/msys64/mingw64/x86_64-w64-mingw32/include/windows.h:71:                                               0,
                 from C:/msys64/mingw64/x86_64-w64-mingw32/include/winsock2.h:23                                               ,
                 from C:/msys64/mingw64/include/POSTGR~1/server/pg_config_os.h:3                                               7,
                 from C:/msys64/mingw64/include/POSTGR~1/server/c.h:101,
                 from C:/msys64/mingw64/include/POSTGR~1/server/postgres.h:47,
                 from ../include/common_pg.h:7,
                 from common_pg.cpp:2:
C:/msys64/mingw64/x86_64-w64-mingw32/include/wingdi.h:75:0: note: this is the lo                                               cation of the previous definition
 #define ERROR 0
 ^
gcc -g -std=c++11 -I C:/msys64/mingw64/include -I C:/msys64/mingw64/include/POST                                               GR~1/server -MD -MF obj/operation.dep -o obj/operation.o -c operation.cpp
In file included from C:/msys64/mingw64/include/POSTGR~1/server/c.h:101:0,
                 from C:/msys64/mingw64/include/POSTGR~1/server/postgres.h:47,
                 from ../include/common_pg.h:7,
                 from ../include/operation.h:9,
                 from operation.cpp:2:
C:/msys64/mingw64/include/POSTGR~1/server/pg_config_os.h:459:0: warning: "S_IRGR                                               P" redefined
 #define S_IRGRP 0
 ^
In file included from ../include/operation.h:6:0,
                 from operation.cpp:2:
C:/msys64/mingw64/x86_64-w64-mingw32/include/sys/stat.h:155:0: note: this is the                                                location of the previous definition
 #define S_IRGRP    (S_IRUSR >> 3)
 ^
In file included from C:/msys64/mingw64/include/POSTGR~1/server/c.h:101:0,
                 from C:/msys64/mingw64/include/POSTGR~1/server/postgres.h:47,
                 from ../include/common_pg.h:7,
                 from ../include/operation.h:9,
                 from operation.cpp:2:
C:/msys64/mingw64/include/POSTGR~1/server/pg_config_os.h:460:0: warning: "S_IWGR                                               P" redefined
 #define S_IWGRP 0
 ^
In file included from ../include/operation.h:6:0,
                 from operation.cpp:2:
C:/msys64/mingw64/x86_64-w64-mingw32/include/sys/stat.h:156:0: note: this is the                                                location of the previous definition
 #define S_IWGRP    (S_IWUSR >> 3)
 ^
In file included from C:/msys64/mingw64/include/POSTGR~1/server/c.h:101:0,
                 from C:/msys64/mingw64/include/POSTGR~1/server/postgres.h:47,
                 from ../include/common_pg.h:7,
                 from ../include/operation.h:9,
                 from operation.cpp:2:
C:/msys64/mingw64/include/POSTGR~1/server/pg_config_os.h:461:0: warning: "S_IXGR                                               P" redefined
 #define S_IXGRP 0
 ^
In file included from ../include/operation.h:6:0,
                 from operation.cpp:2:
C:/msys64/mingw64/x86_64-w64-mingw32/include/sys/stat.h:157:0: note: this is the                                                location of the previous definition
 #define S_IXGRP    (S_IXUSR >> 3)
 ^
In file included from C:/msys64/mingw64/include/POSTGR~1/server/c.h:101:0,
                 from C:/msys64/mingw64/include/POSTGR~1/server/postgres.h:47,
                 from ../include/common_pg.h:7,
                 from ../include/operation.h:9,
                 from operation.cpp:2:
C:/msys64/mingw64/include/POSTGR~1/server/pg_config_os.h:462:0: warning: "S_IRWX                                               G" redefined
 #define S_IRWXG 0
 ^
In file included from ../include/operation.h:6:0,
                 from operation.cpp:2:
C:/msys64/mingw64/x86_64-w64-mingw32/include/sys/stat.h:158:0: note: this is the                                                location of the previous definition
 #define S_IRWXG    (S_IRWXU >> 3)
 ^
In file included from C:/msys64/mingw64/include/POSTGR~1/server/c.h:101:0,
                 from C:/msys64/mingw64/include/POSTGR~1/server/postgres.h:47,
                 from ../include/common_pg.h:7,
                 from ../include/operation.h:9,
                 from operation.cpp:2:
C:/msys64/mingw64/include/POSTGR~1/server/pg_config_os.h:463:0: warning: "S_IROT                                               H" redefined
 #define S_IROTH 0
 ^
In file included from ../include/operation.h:6:0,
                 from operation.cpp:2:
C:/msys64/mingw64/x86_64-w64-mingw32/include/sys/stat.h:160:0: note: this is the                                                location of the previous definition
 #define S_IROTH    (S_IRGRP >> 3)
 ^
In file included from C:/msys64/mingw64/include/POSTGR~1/server/c.h:101:0,
                 from C:/msys64/mingw64/include/POSTGR~1/server/postgres.h:47,
                 from ../include/common_pg.h:7,
                 from ../include/operation.h:9,
                 from operation.cpp:2:
C:/msys64/mingw64/include/POSTGR~1/server/pg_config_os.h:464:0: warning: "S_IWOT                                               H" redefined
 #define S_IWOTH 0
 ^
In file included from ../include/operation.h:6:0,
                 from operation.cpp:2:
C:/msys64/mingw64/x86_64-w64-mingw32/include/sys/stat.h:161:0: note: this is the                                                location of the previous definition
 #define S_IWOTH    (S_IWGRP >> 3)
 ^
In file included from C:/msys64/mingw64/include/POSTGR~1/server/c.h:101:0,
                 from C:/msys64/mingw64/include/POSTGR~1/server/postgres.h:47,
                 from ../include/common_pg.h:7,
                 from ../include/operation.h:9,
                 from operation.cpp:2:
C:/msys64/mingw64/include/POSTGR~1/server/pg_config_os.h:465:0: warning: "S_IXOT                                               H" redefined
 #define S_IXOTH 0
 ^
In file included from ../include/operation.h:6:0,
                 from operation.cpp:2:
C:/msys64/mingw64/x86_64-w64-mingw32/include/sys/stat.h:162:0: note: this is the                                                location of the previous definition
 #define S_IXOTH    (S_IXGRP >> 3)
 ^
In file included from C:/msys64/mingw64/include/POSTGR~1/server/c.h:101:0,
                 from C:/msys64/mingw64/include/POSTGR~1/server/postgres.h:47,
                 from ../include/common_pg.h:7,
                 from ../include/operation.h:9,
                 from operation.cpp:2:
C:/msys64/mingw64/include/POSTGR~1/server/pg_config_os.h:466:0: warning: "S_IRWX                                               O" redefined
 #define S_IRWXO 0
 ^
In file included from ../include/operation.h:6:0,
                 from operation.cpp:2:
C:/msys64/mingw64/x86_64-w64-mingw32/include/sys/stat.h:163:0: note: this is the                                                location of the previous definition
 #define S_IRWXO    (S_IRWXG >> 3)
 ^
In file included from C:/msys64/mingw64/include/POSTGR~1/server/postgres.h:48:0,
                 from ../include/common_pg.h:7,
                 from ../include/operation.h:9,
                 from operation.cpp:2:
C:/msys64/mingw64/include/POSTGR~1/server/utils/elog.h:41:0: warning: "ERROR" re                                               defined
 #define ERROR  20   /* user error - abort transaction; return to
 ^
In file included from C:/msys64/mingw64/x86_64-w64-mingw32/include/windows.h:71:                                               0,
                 from C:/msys64/mingw64/x86_64-w64-mingw32/include/winsock2.h:23                                               ,
                 from C:/msys64/mingw64/include/POSTGR~1/server/pg_config_os.h:3                                               7,
                 from C:/msys64/mingw64/include/POSTGR~1/server/c.h:101,
                 from C:/msys64/mingw64/include/POSTGR~1/server/postgres.h:47,
                 from ../include/common_pg.h:7,
                 from ../include/operation.h:9,
                 from operation.cpp:2:
C:/msys64/mingw64/x86_64-w64-mingw32/include/wingdi.h:75:0: note: this is the lo                                               cation of the previous definition
 #define ERROR 0
 ^
gcc -g -std=c++11 -I C:/msys64/mingw64/include -I C:/msys64/mingw64/include/POSTGR~1/server -MD -MF obj/error.dep -o obj/error.o -c error.cpp
gcc -o ../bin/chppl obj/validate.o obj/chppl.o obj/common_pg.o obj/operation.o obj/error.o -L C:/msys64/mingw64/lib -lpq  -lstdc++ -g -std=c++11
obj/operation.o: In function `Operation::install_lib() const':
C:\msys64\home\yumetodo\chppl-tool\chppl-tool\src/operation.cpp:97: undefined reference to `pgwin32_system(char const*)'
C:\msys64\home\yumetodo\chppl-tool\chppl-tool\src/operation.cpp:98: undefined reference to `pgwin32_system(char const*)'
C:\msys64\home\yumetodo\chppl-tool\chppl-tool\src/operation.cpp:100: undefined reference to `pgwin32_system(char const*)'
obj/operation.o: In function `Operation::download_lib() const':
C:\msys64\home\yumetodo\chppl-tool\chppl-tool\src/operation.cpp:117: undefined reference to `pgwin32_system(char const*)'
C:\msys64\home\yumetodo\chppl-tool\chppl-tool\src/operation.cpp:118: undefined reference to `pgwin32_system(char const*)'
obj/operation.o:C:\msys64\home\yumetodo\chppl-tool\chppl-tool\src/operation.cpp:120: more undefined references to `pgwin32_system(char const*)' follow
collect2.exe: error: ld returned 1 exit status
make: *** [makefile:15: ../bin/chppl] エラー 1

LINKエラーになる。

@yumetodo yumetodo changed the title Windwos(msys2 mingw)でコンパイルできない Windows(msys2 mingw)でコンパイルできない Jun 16, 2016
@nocotan
Copy link
Owner

nocotan commented Jun 16, 2016

ご連絡ありがとうございます。
報告いただいた環境で検証、再現してみます。:frowning:

@yumetodo
Copy link
Author

念の為にこれ以外に入れているパッケージのリストも書いておきます。関係ないと思いますが。

$ pacman -Qt
autoconf 2.69-3
autogen 5.18.4-2
automake-wrapper 10-1
bash-completion 2.3-1
bison 3.0.4-1
bsdcpio 3.2.0-1
bsdtar 3.2.0-1
catgets 1.1-2
cloog 0.18.3-1
crypt 1.3-1
dos2unix 7.3.4-1
file 5.25-1
flex 2.6.0-1
gcc 5.3.0-3
git 2.8.2-1
inetutils 1.9.2-1
libtool 2.4.6-2
lndir 1.0.3-1
make 4.2-1
mingw-w64-i686-boost 1.60.0-2
mingw-w64-i686-clang 3.8.0-3
mingw-w64-i686-cloog 0.18.1-3
mingw-w64-i686-gdb 7.11.1-2
mingw-w64-i686-postgresql 9.5.2-1
mingw-w64-x86_64-boost 1.60.0-2
mingw-w64-x86_64-clang 3.8.0-3
mingw-w64-x86_64-cloog 0.18.1-3
mingw-w64-x86_64-dlfcn 1.0.0-2
mingw-w64-x86_64-gdb 7.11.1-2
mingw-w64-x86_64-postgresql 9.5.2-1
mintty 1~2.2.3-1
nasm 2.12-1
p7zip 9.38.1-1
pactoys-git r1.e58a7ac-1
patch 2.7.5-1
pkg-config 0.29.1-1
rebase 4.4.2-1
rsync 3.1.2-2
ruby 2.3.0-2
scons 2.5.0-1
texinfo 6.0-1
time 1.7-1
tzcode 2015.e-1
unzip 6.0-2
util-linux 2.26.2-1
yasm 1.3.0-2
zip 3.0-1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants