{"id":339,"date":"2013-02-07T22:57:04","date_gmt":"2013-02-08T03:57:04","guid":{"rendered":"http:\/\/www.compdigitec.com\/labs\/?p=339"},"modified":"2013-08-17T18:53:56","modified_gmt":"2013-08-17T23:53:56","slug":"compiling-mingw-w64-with-gcc-4-8","status":"publish","type":"post","link":"http:\/\/www.compdigitec.com\/labs\/2013\/02\/07\/compiling-mingw-w64-with-gcc-4-8\/","title":{"rendered":"Compiling mingw-w64 with GCC 4.8"},"content":{"rendered":"<p>You need at least <b>mingw-w64 rev 5579<\/b>, build-essential, and a working compiler. Be sure to have installed <strong>flex<\/strong> and <strong>bison<\/strong>.<\/p>\n<p>Replace the demo prefix \/usr\/i686-w64-mingw32 with whatever you feel like, if you want to.<\/p>\n<p>Extract the gcc tarball, and pull in mpfr, mpc, and and gmp tarballs under the extracted gcc root.<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nsudo mkdir \/usr\/i686-w64-mingw32\r\n\r\n..\/binutils-2.22\/configure --disable-multilib --target=i686-w64-mingw32 --with-sysroot=\/usr\/i686-w64-mingw32 --prefix=\/usr\/i686-w64-mingw32\r\nmake -j4\r\nsudo make install\r\n\r\nln -s \/usr\/i686-w64-mingw32\/i686-w64-mingw32 \/usr\/i686-w64-mingw32\/mingw\r\n\r\n..\/mingw-w64\/mingw-w64-headers\/configure --build=i686-linux-gnu --host=i686-w64-mingw32 --prefix=\/usr\/i686-w64-mingw32\/i686-w64-mingw32 # notice the extra i686-w64-mingw32\r\nmake\r\nsudo make install\r\n\r\n..\/gcc-4.8-20130120\/configure --target=i686-w64-mingw32 --disable-multilib --enable-languages=c,c++  --with-system-zlib --enable-shared --prefix=\/usr\/i686-w64-mingw32 --with-sysroot=\/usr\/i686-w64-mingw32\r\nmake all-gcc -j4\r\nsudo make install-gcc\r\n\r\n..\/mingw-w64\/configure --host=i686-w64-mingw32 --prefix=\/usr\/i686-w64-mingw32 --with-sysroot=\/usr\/i686-w64-mingw32\r\nmake -j4\r\nsudo su\r\nexport PATH=\/usr\/i686-w64-mingw32\/bin:$PATH\r\nmake install\r\nexit\r\n\r\ncd ..\/gcc-4.8-20130120-build\r\nmake -j4\r\n# \/usr\/i686-w64-mingw32\/i686-w64-mingw32\/bin\/ld: cannot find dllcrt2.o: No such file or directory\r\nsudo ln -s \/usr\/i686-w64-mingw32\/lib\/dllcrt2.o \/usr\/i686-w64-mingw32\/mingw\/lib\/\r\nmake\r\n# checking for ld that supports -Wl,--gc-sections... configure: error: Link tests are not allowed after GCC_NO_EXECUTABLES.\r\n# dig into i686-w64-mingw32\/libstdc++-v3\/config.log, you find this:\r\n# \/usr\/i686-w64-mingw32\/i686-w64-mingw32\/bin\/ld: cannot find crt2.o: No such file or directory\r\n# solution:\r\nsudo ln -s \/usr\/i686-w64-mingw32\/lib\/crt2.o \/usr\/i686-w64-mingw32\/mingw\/lib\/\r\nmake\r\nsudo make install\r\n\r\n..\/..\/..\/mingw-w64\/mingw-w64-libraries\/winstorecompat\/configure --prefix=\/usr\/i686-w64-mingw32 --host=i686-w64-mingw32\r\nmake\r\nsudo su\r\nexport PATH=\/usr\/i686-w64-mingw32\/bin:$PATH\r\nmake install\r\nexit\r\n<\/pre>\n<p>And just for fun, let&#8217;s test it:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\ni686-w64-mingw32-gcc --version\r\n# i686-w64-mingw32-gcc (GCC) 4.8.0 20130120 (experimental)\r\n# Copyright (C) 2013 Free Software Foundation, Inc.\r\n# This is free software; see the source for copying conditions.  There is NO\r\n# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\r\n\r\ni686-w64-mingw32-gcc ~\/c\/hello.c\r\n\r\nfile a.exe\r\n# a.exe: PE32 executable for MS Windows (console) Intel 80386 32-bit\r\n\r\nwine a.exe\r\n# Hello, World!\r\n\r\n<\/pre>\n<p><b>Bibliography:<\/b><\/p>\n<ul>\n<li><a href=\"http:\/\/pete.akeo.ie\/2010\/07\/compiling-mingw-w64-with-multilib-on.html\">http:\/\/pete.akeo.ie\/2010\/07\/compiling-mingw-w64-with-multilib-on.html<\/a><\/li>\n<li><a href=\"http:\/\/mingw.5.n7.nabble.com\/Rantings-of-a-crazy-dude-on-GCC-NO-EXECUTABLES-td20091.html\">http:\/\/mingw.5.n7.nabble.com\/Rantings-of-a-crazy-dude-on-GCC-NO-EXECUTABLES-td20091.html<\/a><\/li>\n<li><a href=\"http:\/\/www.mail-archive.com\/mingw-w64-public@lists.sourceforge.net\/msg02903.html\">http:\/\/www.mail-archive.com\/mingw-w64-public@lists.sourceforge.net\/msg02903.html<\/a><\/li>\n<\/ul>","protected":false},"excerpt":{"rendered":"<p>You need at least mingw-w64 rev 5579, build-essential, and a working compiler. Be sure to have installed flex and bison. Replace the demo prefix \/usr\/i686-w64-mingw32 with whatever you feel like, if you want to. Extract the gcc tarball, and pull in mpfr, mpc, and and gmp tarballs under the extracted gcc root. And just for [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[3],"tags":[43,823,298,821,820,822,60],"_links":{"self":[{"href":"http:\/\/www.compdigitec.com\/labs\/wp-json\/wp\/v2\/posts\/339"}],"collection":[{"href":"http:\/\/www.compdigitec.com\/labs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.compdigitec.com\/labs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.compdigitec.com\/labs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.compdigitec.com\/labs\/wp-json\/wp\/v2\/comments?post=339"}],"version-history":[{"count":0,"href":"http:\/\/www.compdigitec.com\/labs\/wp-json\/wp\/v2\/posts\/339\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.compdigitec.com\/labs\/wp-json\/wp\/v2\/media?parent=339"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.compdigitec.com\/labs\/wp-json\/wp\/v2\/categories?post=339"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.compdigitec.com\/labs\/wp-json\/wp\/v2\/tags?post=339"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}