{"id":52197,"date":"2024-12-03T15:37:50","date_gmt":"2024-12-03T07:37:50","guid":{"rendered":"https:\/\/fwq.ai\/blog\/52197\/"},"modified":"2024-12-03T15:37:50","modified_gmt":"2024-12-03T07:37:50","slug":"linux-gcj%e6%98%af%e4%bb%80%e4%b9%88%e5%8f%8a%e5%ae%89%e8%a3%85%e4%bd%bf%e7%94%a8","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/52197\/","title":{"rendered":"linux gcj\u662f\u4ec0\u4e48\u53ca\u5b89\u88c5\u4f7f\u7528"},"content":{"rendered":"<p><b><\/b>     <\/p>\n<h1>linux gcj\u662f\u4ec0\u4e48\u53ca\u5b89\u88c5\u4f7f\u7528<\/h1>\n<p>\u79ef\u7d2f\u77e5\u8bc6\uff0c\u80dc\u8fc7\u79ef\u84c4\u91d1\u94f6\uff01\u6bd5\u7adf\u5728\u6587\u7ae0\u5f00\u53d1\u7684\u8fc7\u7a0b\u4e2d\uff0c\u4f1a\u9047\u5230\u5404\u79cd\u5404\u6837\u7684\u95ee\u9898\uff0c\u5f80\u5f80\u90fd\u662f\u4e00\u4e9b\u7ec6\u8282\u77e5\u8bc6\u70b9\u8fd8\u6ca1\u6709\u638c\u63e1\u597d\u800c\u5bfc\u81f4\u7684\uff0c\u56e0\u6b64\u57fa\u7840\u77e5\u8bc6\u70b9\u7684\u79ef\u7d2f\u662f\u5f88\u91cd\u8981\u7684\u3002\u4e0b\u9762\u672c\u6587\u300alinux gcj\u662f\u4ec0\u4e48\u53ca\u5b89\u88c5\u4f7f\u7528\u300b\uff0c\u5c31\u5e26\u5927\u5bb6\u8bb2\u89e3\u4e00\u4e0b\u77e5\u8bc6\u70b9\uff0c\u82e5\u662f\u4f60\u5bf9\u672c\u6587\u611f\u5174\u8da3\uff0c\u6216\u8005\u662f\u60f3\u641e\u61c2\u5176\u4e2d\u67d0\u4e2a\u77e5\u8bc6\u70b9\uff0c\u5c31\u8bf7\u4f60\u7ee7\u7eed\u5f80\u4e0b\u770b\u5427~<\/p>\n<\/p>\n<blockquote>\n<p>\u5728linux\u4e2d\uff0cGCJ\u662fGNU\u7684Java\u7f16\u8bd1\u5668\uff0c\u53ef\u4ee5\u628ajava\u7a0b\u5e8f\u7f16\u8bd1\u6210\u672c\u5730\u4ee3\u7801\uff0c\u7f16\u8bd1\u6210\u529f\u540e\u7684\u53ef\u6267\u884c\u6587\u4ef6\u4e0d\u518d\u9700\u8981jre\u5c31\u53ef\u76f4\u63a5\u8fd0\u884c\uff0c\u7f16\u8bd1\u6210\u672c\u5730\u540e\u7684\u7a0b\u5e8f\u8fd0\u884c\u901f\u5ea6\u6709\u6240\u63d0\u9ad8\uff0c\u7f3a\u70b9\u662f\u751f\u6210\u540e\u7684\u6587\u4ef6\u8f83\u5927\u3002GCJ\u80fd\u591f\u5c06Java\u6e90\u6587\u4ef6\u7f16\u8bd1\u4e3aJava\u5b57\u8282\u7801\u6587\u4ef6\u6216\u8005\u76f4\u63a5\u5c06Java\u6e90\u6587\u4ef6\u7f16\u8bd1\u4e3a\u672c\u5730\u673a\u5668\u7801\uff0c\u5b83\u4e5f\u80fd\u591f\u5c06Java\u5b57\u8282\u7801\u6587\u4ef6\u7f16\u8bd1\u4e3a\u672c\u5730\u673a\u5668\u7801\u3002<\/p>\n<\/blockquote>\n<p><strong>linux gcj\u662f\u4ec0\u4e48<\/strong><\/p>\n<p>GCJ \u662fGNU Compiler for the Java Programing Language \u7684\u7b80\u79f0\uff0c\u662fGNU\u7684Java\u7f16\u8bd1\u5668\uff0c\u53ef\u4ee5\u628ajava\u7a0b\u5e8f\u7f16\u8bd1\u6210\u672c\u5730\u4ee3\u7801\uff0c\u7f16\u8bd1\u6210\u529f\u540e\u7684\u53ef\u6267\u884c\u6587\u4ef6\u4e0d\u518d\u9700\u8981jre\u5c31\u53ef\u76f4\u63a5\u8fd0\u884c\uff0c\u7f16\u8bd1\u6210\u672c\u5730\u540e\u7684\u7a0b\u5e8f\u8fd0\u884c\u901f\u5ea6\u6709\u6240\u63d0\u9ad8\uff0c\u7f3a\u70b9\u662f\u751f\u6210\u540e\u7684\u6587\u4ef6\u8f83\u5927\u3002<\/p>\n<p>\u5728GCC\u5185\u90e8\uff0c\u5b83\u5305\u542bJava\u7f16\u7a0b\u8bed\u8a00\u7684\u524d\u7aef(gcc\/java)\uff0c\u4e00\u4e2a\u8fd0\u884c\u65f6\u5e93(libjava)\u548c\u5176\u4ed6\u5de5\u5177\u5e93(boehm-gc, libffi and zlib)\u3002\u5927\u591a\u6570\u7684\u8fd0\u884c\u65f6\u5e93\u7684\u5b9e\u73b0\u662f\u5728GNU Classpath project\u5171\u4eab\u7684\u3002<\/p>\n<p>GCJ \u662f\u4e00\u4e2a\u8f7b\u5de7\u7684\uff0c\u6027\u80fd\u4f18\u8d8a\u7684Java\u8bed\u8a00\u7f16\u8bd1\u5668\u3002\u5b83\u80fd\u591f\u5c06Java\u6e90\u6587\u4ef6\u7f16\u8bd1\u4e3aJava\u5b57\u8282\u7801\u6587\u4ef6\u6216\u8005\u76f4\u63a5\u5c06Java\u6e90\u6587\u4ef6\u7f16\u8bd1\u4e3a\u672c\u5730\u673a\u5668\u7801\uff0c\u5b83\u4e5f\u80fd\u591f\u5c06Java\u5b57\u8282\u7801\u6587\u4ef6\u7f16\u8bd1\u4e3a\u672c\u5730\u673a\u5668\u7801\u3002<\/p>\n<p>\u88ab\u7f16\u8bd1\u7684\u5e94\u7528\u7a0b\u5e8f\u548cGCJ\u8fd0\u884c\u65f6libgcj\u8fdb\u884c\u94fe\u63a5\u3002\u8be5\u8fd0\u884c\u65f6\u63d0\u4f9b\u4e86\u6838\u5fc3\u7c7b\u5e93\uff0c\u5783\u573e\u56de\u6536\u5668\u548c\u4e00\u4e2a\u5b57\u8282\u7801\u89e3\u91ca\u5668\u3002libgcj\u80fd\u591f\u52a8\u6001\u52a0\u8f7d\u548c\u89e3\u91ca\u7c7b\u6587\u4ef6\uff0c\u4ea7\u751f\u6df7\u5408\u7f16\u8bd1\/\u89e3\u91ca\u7684\u5e94\u7528\u7a0b\u5e8f\u3002\u8be5\u8fd0\u884c\u65f6\u540c\u540d\u4e3aGNU Classpath\u7684\u5de5\u7a0b\u6574\u5408\u5728\u4e00\u8d77\u3002\u6700\u591a\u652f\u6301jdk1.4\u7684\u7c7b\u5e93\u548c\u4e00\u4e9bjdk1.5\u7684\u7c7b\u5e93\u3002<\/p>\n<p>GCJ\u4e5f\u80fd\u591f\u88ab\u914d\u7f6e\u6210\u4e3a\u4e00\u4e2a\u9002\u5408\u5d4c\u5165\u5f0f\u7cfb\u7edf\u7684\u4ea4\u53c9\u7f16\u8bd1\u5668\u3002\u6700\u8fd1\u7684GNU Debugger(gdb)\u652f\u6301GCJ\u3002\u4e00\u4e2a\u7b80\u5355\u7684\u5229\u7528gdb\u8c03\u8bd5Java\u7a0b\u5e8f\u7684\u6559\u7a0b\u89c1\u53c2\u8003\u8d44\u6599\u3002<\/p>\n<p><strong>gcj\u5b89\u88c5<\/strong><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20240416\/1713252451661e28632b359.jpg\" class=\"aligncenter\" title=\"linux gcj\u662f\u4ec0\u4e48\u53ca\u5b89\u88c5\u4f7f\u7528\u63d2\u56fe\" alt=\"linux gcj\u662f\u4ec0\u4e48\u53ca\u5b89\u88c5\u4f7f\u7528\u63d2\u56fe\" \/><\/p>\n<p><strong>\u4f7f\u7528gcj\u547d\u4ee4<\/strong><\/p>\n<p>FirstApp.java<\/p>\n<pre>public&nbsp;class&nbsp;FirstApp\n{&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;static&nbsp;void&nbsp;main(String&nbsp;args[])\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(\"This&nbsp;is&nbsp;a&nbsp;test.\");\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}\n}<\/pre>\n<p>\u7f16\u8bd1<\/p>\n<pre>gcj&nbsp;--main=FirstApp&nbsp;-o&nbsp;FirstApp&nbsp;FirstApp.o<\/pre>\n<p>\u8fd0\u884c<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20240416\/1713252451661e2863317fb.jpg\" class=\"aligncenter\" title=\"linux gcj\u662f\u4ec0\u4e48\u53ca\u5b89\u88c5\u4f7f\u7528\u63d2\u56fe1\" alt=\"linux gcj\u662f\u4ec0\u4e48\u53ca\u5b89\u88c5\u4f7f\u7528\u63d2\u56fe1\" \/><\/p>\n<p>\u597d\u4e86\uff0c\u672c\u6587\u5230\u6b64\u7ed3\u675f\uff0c\u5e26\u5927\u5bb6\u4e86\u89e3\u4e86\u300alinux gcj\u662f\u4ec0\u4e48\u53ca\u5b89\u88c5\u4f7f\u7528\u300b\uff0c\u5e0c\u671b\u672c\u6587\u5bf9\u4f60\u6709\u6240\u5e2e\u52a9\uff01\u5173\u6ce8\u7c73\u4e91\u516c\u4f17\u53f7\uff0c\u7ed9\u5927\u5bb6\u5206\u4eab\u66f4\u591a\u6587\u7ae0\u77e5\u8bc6\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>linux gcj\u662f\u4ec0\u4e48\u53ca\u5b89\u88c5\u4f7f\u7528 \u79ef\u7d2f\u77e5\u8bc6\uff0c\u80dc\u8fc7\u79ef\u84c4\u91d1\u94f6\uff01\u6bd5\u7adf\u5728\u6587\u7ae0\u5f00\u53d1\u7684\u8fc7\u7a0b\u4e2d\uff0c\u4f1a\u9047\u5230\u5404\u79cd\u5404\u6837\u7684\u95ee\u9898\uff0c\u5f80\u5f80\u90fd\u662f\u4e00\u4e9b\u7ec6\u8282\u77e5\u8bc6\u70b9\u8fd8\u6ca1\u6709\u638c\u63e1\u597d\u800c\u5bfc\u81f4\u7684\uff0c\u56e0\u6b64\u57fa\u7840\u77e5\u8bc6\u70b9\u7684\u79ef\u7d2f\u662f\u5f88\u91cd\u8981\u7684\u3002\u4e0b\u9762\u672c\u6587\u300alinux gcj\u662f\u4ec0\u4e48\u53ca\u5b89\u88c5\u4f7f\u7528\u300b\uff0c\u5c31\u5e26\u5927\u5bb6\u8bb2\u89e3\u4e00\u4e0b\u77e5\u8bc6\u70b9\uff0c\u82e5\u662f\u4f60\u5bf9\u672c\u6587\u611f\u5174\u8da3\uff0c\u6216\u8005\u662f\u60f3\u641e\u61c2\u5176\u4e2d\u67d0\u4e2a\u77e5\u8bc6\u70b9\uff0c\u5c31\u8bf7\u4f60\u7ee7\u7eed\u5f80\u4e0b\u770b\u5427~ \u5728linux\u4e2d\uff0cGCJ\u662fGNU\u7684Java\u7f16\u8bd1\u5668\uff0c\u53ef\u4ee5\u628ajava\u7a0b\u5e8f\u7f16\u8bd1\u6210\u672c\u5730\u4ee3\u7801\uff0c\u7f16\u8bd1\u6210\u529f\u540e\u7684\u53ef\u6267\u884c\u6587\u4ef6\u4e0d\u518d\u9700\u8981jre\u5c31\u53ef\u76f4\u63a5\u8fd0\u884c\uff0c\u7f16\u8bd1\u6210\u672c\u5730\u540e\u7684\u7a0b\u5e8f\u8fd0\u884c\u901f\u5ea6\u6709\u6240\u63d0\u9ad8\uff0c\u7f3a\u70b9\u662f\u751f\u6210\u540e\u7684\u6587\u4ef6\u8f83\u5927\u3002GCJ\u80fd\u591f\u5c06Java\u6e90\u6587\u4ef6\u7f16\u8bd1\u4e3aJava\u5b57\u8282\u7801\u6587\u4ef6\u6216\u8005\u76f4\u63a5\u5c06Java\u6e90\u6587\u4ef6\u7f16\u8bd1\u4e3a\u672c\u5730\u673a\u5668\u7801\uff0c\u5b83\u4e5f\u80fd\u591f\u5c06Java\u5b57\u8282\u7801\u6587\u4ef6\u7f16\u8bd1\u4e3a\u672c\u5730\u673a\u5668\u7801\u3002 linux gcj\u662f\u4ec0\u4e48 GCJ \u662fGNU Compiler for the Java Programing Language \u7684\u7b80\u79f0\uff0c\u662fGNU\u7684Java\u7f16\u8bd1\u5668\uff0c\u53ef\u4ee5\u628ajava\u7a0b\u5e8f\u7f16\u8bd1\u6210\u672c\u5730\u4ee3\u7801\uff0c\u7f16\u8bd1\u6210\u529f\u540e\u7684\u53ef\u6267\u884c\u6587\u4ef6\u4e0d\u518d\u9700\u8981jre\u5c31\u53ef\u76f4\u63a5\u8fd0\u884c\uff0c\u7f16\u8bd1\u6210\u672c\u5730\u540e\u7684\u7a0b\u5e8f\u8fd0\u884c\u901f\u5ea6\u6709\u6240\u63d0\u9ad8\uff0c\u7f3a\u70b9\u662f\u751f\u6210\u540e\u7684\u6587\u4ef6\u8f83\u5927\u3002 \u5728GCC\u5185\u90e8\uff0c\u5b83\u5305\u542bJava\u7f16\u7a0b\u8bed\u8a00\u7684\u524d\u7aef(gcc\/java)\uff0c\u4e00\u4e2a\u8fd0\u884c\u65f6\u5e93(libjava)\u548c\u5176\u4ed6\u5de5\u5177\u5e93(boehm-gc, libffi and zlib)\u3002\u5927\u591a\u6570\u7684\u8fd0\u884c\u65f6\u5e93\u7684\u5b9e\u73b0\u662f\u5728GNU Classpath project\u5171\u4eab\u7684\u3002 GCJ \u662f\u4e00\u4e2a\u8f7b\u5de7\u7684\uff0c\u6027\u80fd\u4f18\u8d8a\u7684Java\u8bed\u8a00\u7f16\u8bd1\u5668\u3002\u5b83\u80fd\u591f\u5c06Java\u6e90\u6587\u4ef6\u7f16\u8bd1\u4e3aJava\u5b57\u8282\u7801\u6587\u4ef6\u6216\u8005\u76f4\u63a5\u5c06Java\u6e90\u6587\u4ef6\u7f16\u8bd1\u4e3a\u672c\u5730\u673a\u5668\u7801\uff0c\u5b83\u4e5f\u80fd\u591f\u5c06Java\u5b57\u8282\u7801\u6587\u4ef6\u7f16\u8bd1\u4e3a\u672c\u5730\u673a\u5668\u7801\u3002 \u88ab\u7f16\u8bd1\u7684\u5e94\u7528\u7a0b\u5e8f\u548cGCJ\u8fd0\u884c\u65f6libgcj\u8fdb\u884c\u94fe\u63a5\u3002\u8be5\u8fd0\u884c\u65f6\u63d0\u4f9b\u4e86\u6838\u5fc3\u7c7b\u5e93\uff0c\u5783\u573e\u56de\u6536\u5668\u548c\u4e00\u4e2a\u5b57\u8282\u7801\u89e3\u91ca\u5668\u3002libgcj\u80fd\u591f\u52a8\u6001\u52a0\u8f7d\u548c\u89e3\u91ca\u7c7b\u6587\u4ef6\uff0c\u4ea7\u751f\u6df7\u5408\u7f16\u8bd1\/\u89e3\u91ca\u7684\u5e94\u7528\u7a0b\u5e8f\u3002\u8be5\u8fd0\u884c\u65f6\u540c\u540d\u4e3aGNU Classpath\u7684\u5de5\u7a0b\u6574\u5408\u5728\u4e00\u8d77\u3002\u6700\u591a\u652f\u6301jdk1.4\u7684\u7c7b\u5e93\u548c\u4e00\u4e9bjdk1.5\u7684\u7c7b\u5e93\u3002 GCJ\u4e5f\u80fd\u591f\u88ab\u914d\u7f6e\u6210\u4e3a\u4e00\u4e2a\u9002\u5408\u5d4c\u5165\u5f0f\u7cfb\u7edf\u7684\u4ea4\u53c9\u7f16\u8bd1\u5668\u3002\u6700\u8fd1\u7684GNU Debugger(gdb)\u652f\u6301GCJ\u3002\u4e00\u4e2a\u7b80\u5355\u7684\u5229\u7528gdb\u8c03\u8bd5Java\u7a0b\u5e8f\u7684\u6559\u7a0b\u89c1\u53c2\u8003\u8d44\u6599\u3002 gcj\u5b89\u88c5 \u4f7f\u7528gcj\u547d\u4ee4 FirstApp.java public&nbsp;class&nbsp;FirstApp {&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;static&nbsp;void&nbsp;main(String&nbsp;args[]) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(&#8220;This&nbsp;is&nbsp;a&nbsp;test.&#8221;); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} } \u7f16\u8bd1 gcj&nbsp;&#8211;main=FirstApp&nbsp;-o&nbsp;FirstApp&nbsp;FirstApp.o \u8fd0\u884c \u597d\u4e86\uff0c\u672c\u6587\u5230\u6b64\u7ed3\u675f\uff0c\u5e26\u5927\u5bb6\u4e86\u89e3\u4e86\u300alinux gcj\u662f\u4ec0\u4e48\u53ca\u5b89\u88c5\u4f7f\u7528\u300b\uff0c\u5e0c\u671b\u672c\u6587\u5bf9\u4f60\u6709\u6240\u5e2e\u52a9\uff01\u5173\u6ce8\u7c73\u4e91\u516c\u4f17\u53f7\uff0c\u7ed9\u5927\u5bb6\u5206\u4eab\u66f4\u591a\u6587\u7ae0\u77e5\u8bc6\uff01<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-52197","post","type-post","status-publish","format-standard","hentry","category-os"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/52197","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=52197"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/52197\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=52197"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=52197"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=52197"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}