{"id":7165,"date":"2023-10-09T15:45:32","date_gmt":"2023-10-09T07:45:32","guid":{"rendered":"https:\/\/www.zhidianwl.net\/zhidianwl\/?p=7165"},"modified":"2023-10-09T15:45:32","modified_gmt":"2023-10-09T07:45:32","slug":"mac%e7%94%b5%e8%84%91%e5%b0%86c%e6%96%87%e4%bb%b6%e6%89%93%e5%8c%85exe%e6%80%8e%e4%b9%88%e6%93%8d%e4%bd%9c%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/www.zhidianwl.net\/zhidianwl\/2023\/10\/09\/mac%e7%94%b5%e8%84%91%e5%b0%86c%e6%96%87%e4%bb%b6%e6%89%93%e5%8c%85exe%e6%80%8e%e4%b9%88%e6%93%8d%e4%bd%9c%ef%bc%9f\/","title":{"rendered":"mac\u7535\u8111\u5c06c\u6587\u4ef6\u6253\u5305exe\u600e\u4e48\u64cd\u4f5c\uff1f"},"content":{"rendered":"

\u5728Mac\u7535\u8111\u4e0a\u5c06C\u6587\u4ef6\u6253\u5305\u6210exe\u6587\u4ef6\uff0c\u9700\u8981\u4f7f\u7528\u4ea4\u53c9\u7f16\u8bd1\u5de5\u5177\u3002\u4ea4\u53c9\u7f16\u8bd1\u5de5\u5177\u53ef\u4ee5\u5728Mac\u7535\u8111\u4e0a\u7f16\u8bd1Windows\u53ef\u6267\u884c\u6587\u4ef6\u3002\u5e38\u7528\u7684\u4ea4\u53c9\u7f16\u8bd1\u5de5\u5177\u6709MinGW\u548cCygwin\u3002\u4e0b\u9762\u5c06\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528MinGW\u5c06C\u6587\u4ef6\u6253\u5305\u6210exe\u6587\u4ef6\u3002<\/p>\n

MinGW\u662f\u4e00\u4e2a\u514d\u8d39\u7684\u5f00\u6e90\u8f6f\u4ef6\uff0c\u7528\u4e8eWindows\u7684\u4ea4\u53c9\u7f16\u8bd1\u3002\u5b83\u5141\u8bb8\u5f00\u53d1\u4eba\u5458\u5728\u975eWindows\u5e73\u53f0\u4e0a\u7f16\u8bd1Windows\u5e94\u7528\u7a0b\u5e8f\u3002\u5728Mac\u7535\u8111\u4e0a\u4f7f\u7528MinGW\u7f16\u8bd1C\u6587\u4ef6\uff0c\u9700\u8981\u5148\u5b89\u88c5MinGW\u3002<\/p>\n

1. \u4e0b\u8f7dMinGW<\/p>\n

MinGW\u5b98\u65b9\u7f51\u7ad9\u63d0\u4f9b\u4e86\u5b89\u88c5\u7a0b\u5e8f\u7684\u4e0b\u8f7d\u94fe\u63a5\u3002\u5728\u7f51\u7ad9\u4e0a\u9009\u62e9\u6700\u65b0\u7248\u672c\u7684MinGW\u5b89\u88c5\u7a0b\u5e8f\uff0c\u4e0b\u8f7d\u5e76\u5b89\u88c5\u3002<\/p>\n

2. \u914d\u7f6eMinGW<\/p>\n

\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u9700\u8981\u914d\u7f6eMinGW\u73af\u5883\u53d8\u91cf\u3002\u6253\u5f00\u7ec8\u7aef\uff0c\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n

“`bash<\/p>\n

export PATH=$PATH:\/usr\/local\u684c\u9762\u5e94\u7528\u7a0b\u5e8f\u7528\u4ec0\u4e48\u5f00\u53d1<\/a>\/mingw-w64\/bin<\/p>\n

“`<\/p>\n

\u8fd9\u4e2a\u547d\u4ee4\u5c06MinGW\u7684bin\u76ee\u5f55\u6dfb\u52a0\u5230\u73af\u5883\u53d8\u91cf\u4e2d\uff0c\u4ee5\u4fbf\u5728\u7ec8\u7aef\u4e2d\u4f7f\u7528MinGW\u3002<\/p>\n

3. \u7f16\u5199C\u7a0b\u5e8f<\/p>\n

\u7f16\u5199\u4e00\u4e2a\u7b80\u5355\u7684C\u7a0b\u5e8f\uff0c\u6bd4\u5982\uff1a<\/p>\n

“`c<\/p>\n

#include <\/p>\n

int main() {<\/p>\n

printf(“Hello, World!\\n”);<\/p>\n

return 0;<\/p>\n

}<\/p>\n

“`<\/p>\n

\u5c06\u5176\u4fdd\u5b58\u4e3ahello.c\u3002<\/p>\n

4. \u7f16\u8bd1C\u7a0b\u5e8f<\/p>\n

\u5728\u7ec8\u7aef\u4e2d\uff0c\u5207\u6362\u5230\u4fdd\u5b58\u6709hello.c\u6587\u4ef6\u7684\u76ee\u5f55\u4e0b\uff0c\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n

“`bash<\/p>\n

i686-w64-mingw32-gcc hello.c -o hexe\u6587\u4ef6\u67e5\u770b\u5de5\u5177<\/a>ello.exe<\/p>\n

“`<\/p>\n

\u8fd9\u4e2a\u547d\u4ee4\u4f7f\u7528MinGW\u7684\u4ea4\u53c9\u7f16\u8bd1\u5de5\u5177i686-w64-mingw32-gcc\u7f16\u8bd1hello.c\u6587\u4ef6\uff0c\u5e76\u5c06\u5176\u4fdd\u5b58\u4e3ahello.exe\u6587\u4ef6\u3002\u5982\u679c\u7f16\u8bd1\u6210\u529f\uff0c\u4f1a\u5728\u540c\u4e00\u76ee\u5f55\u4e0b\u751f\u6210\u4e00\u4e2ahello.exe\u6587\u4ef6\u3002<\/p>\n

5. \u8fd0\u884cexe\u6587\u4ef6<\/p>\n

\u5728Windows\u7cfb\u7edf\u4e2d\uff0c\u53ef\u4ee5\u76f4\u63a5\u8fd0\u884chello.exe\u6587\u4ef6\u3002\u5728Mac\u7535\u8111\u4e0a\uff0c\u9700\u8981\u4f7f\u7528Wine\u8f6f\u4ef6\u6765\u8fd0\u884cexe\u6587\u4ef6\u3002Wine\u662f\u4e00\u4e2a\u514d\u8d39\u7684\u5f00\u6e90\u8f6f\u4ef6\uff0c\u7528\u4e8e\u5728<\/p>\n

<\/figure>\n<\/p>\n

\u975eWindows\u64cd\u4f5c\u7cfb\u7edf\u4e0a\u8fd0\u884cWindows\u5e94\u7528\u7a0b\u5e8f\u3002\u5728\u7ec8\u7aef\u4e2d\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5Wine\uff1a<\/p>\n

“`bash<\/p>\n

brew install wine<\/p>\n

“`<\/p>\n

\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u5728\u7ec8\u7aef\u4e2d\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u8fd0\u884chello.exe\u6587\u4ef6\uff1a<\/p>\n

“`bash<\/p>\n

wine hello.exe<\/p>\n

“`<\/p>\n

\u8fd9\u4e2a\u547d\u4ee4\u5c06\u4f7f\u7528Wine\u6765\u8fd0\u884chello.exe\u6587\u4ef6\uff0c\u5728\u7ec8\u7aef\u4e2d\u8f93\u51fa\u201cHello, World!\u201d\u3002<\/p>\n

\u603b\u7ed3\uff1a<\/p>\n

\u4f7f\u7528MinGW\u53ef\u4ee5\u5728Mac\u7535\u8111\u4e0a\u5c06C\u6587\u4ef6\u6253\u5305\u6210exe\u6587\u4ef6\uff0c\u9700\u8981\u5148\u5b89\u88c5MinGW\u548c\u914d\u7f6e\u73af\u5883\u53d8\u91cf\u3002\u4f7f\u7528i686-w64-mingw32-gcc\u7f16\u8bd1C\u6587\u4ef6\uff0c\u5e76\u5c06\u5176\u4fdd\u5b58\u4e3aexe\u6587\u4ef6\u3002\u5728Mac\u7535\u8111\u4e0a\u4f7f\u7528Wine\u8fd0\u884cexe\u6587\u4ef6\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

\u5728Mac\u7535\u8111\u4e0a\u5c06C\u6587\u4ef6\u6253\u5305\u6210exe\u6587\u4ef6\uff0c\u9700\u8981\u4f7f\u7528\u4ea4\u53c9\u7f16\u8bd1\u5de5\u5177\u3002\u4ea4\u53c9\u7f16\u8bd1\u5de5\u5177\u53ef\u4ee5\u5728Mac\u7535\u8111\u4e0a\u7f16\u8bd1Windows\u53ef\u6267\u884c\u6587\u4ef6\u3002\u5e38\u7528\u7684\u4ea4\u53c9\u7f16\u8bd1\u5de5\u5177\u6709MinGW\u548cCygwin\u3002\u4e0b\u9762\u5c06\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528MinGW\u5c06<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[8224,43,12735,12,1890],"topic":[],"class_list":["post-7165","post","type-post","status-publish","format-standard","hentry","category-zhuomianruanjian","tag-pc","tag-43","tag-exe","tag-12","tag-1890"],"_links":{"self":[{"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/posts\/7165","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/comments?post=7165"}],"version-history":[{"count":0,"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/posts\/7165\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/media?parent=7165"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/categories?post=7165"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/tags?post=7165"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/topic?post=7165"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}