{"id":4518,"date":"2022-01-23T12:49:31","date_gmt":"2022-01-23T03:49:31","guid":{"rendered":"https:\/\/www.skyer9.pe.kr\/wordpress\/?p=4518"},"modified":"2022-02-01T15:42:51","modified_gmt":"2022-02-01T06:42:51","slug":"%ec%9a%b0%eb%b6%84%ed%88%ac-18-04%ec%97%90%ec%84%9c-arm-cross-compile-%ed%95%98%ea%b8%b0","status":"publish","type":"post","link":"https:\/\/www.skyer9.pe.kr\/wordpress\/?p=4518","title":{"rendered":"Ubuntu 20.04 ARM Cross Compile \ud558\uae30"},"content":{"rendered":"<h1>Ubuntu 20.04 ARM Cross Compile \ud558\uae30<\/h1>\n<h2>\uae30\ucd08\uc9c0\uc2dd<\/h2>\n<p>ARM \uc740 hard float(\ud558\ub4dc\uc6e8\uc5b4 GPU) \uac00 \uc788\ub294 \ubc84\uc804\uc774 \uc788\uace0,<br \/>\n\uc5c6\ub294 \ubc84\uc804\uc774 \uc788\uc2b5\ub2c8\ub2e4.<\/p>\n<p>EABI(Embedded Application Binary Interface)\ub294,<br \/>\nARM\uc758 C \ud638\ucd9c \uad00\ud589\uc774\ub77c\uace0 \uc774\ud574\ud558\uba74 \ub429\ub2c8\ub2e4.<\/p>\n<h2>\ud234\uccb4\uc778 \uc124\uce58<\/h2>\n<h3>\uac1c\ubc1c\uc6a9 \ud544\uc218 \ub77c\uc774\ube0c\ub7ec\ub9ac \uc124\uce58<\/h3>\n<pre><code class=\"language-bash\"> sudo apt-get install build-essential<\/code><\/pre>\n<h3>hard float(\ud558\ub4dc\uc6e8\uc5b4 GPU) \uac00 \uc788\ub294 \uacbd\uc6b0<\/h3>\n<pre><code class=\"language-bash\"># gnu c compiler(32bit)\nsudo apt-get install gcc-arm-linux-gnueabihf\n# gnu c++ compiler(32bit)\nsudo apt-get install g++-arm-linux-gnueabihf<\/code><\/pre>\n<h3>hard float(\ud558\ub4dc\uc6e8\uc5b4 GPU) \uac00 \uc5c6\ub294 \uacbd\uc6b0<\/h3>\n<pre><code class=\"language-bash\"># gnu c compiler(32bit)\nsudo apt-get install gcc-arm-linux-gnueabi\n# gnu c++ compiler(32bit)\nsudo apt-get install g++-arm-linux-gnueabi<\/code><\/pre>\n<h3>64bit \ubc84\uc804<\/h3>\n<pre><code class=\"language-bash\"># gnu c compiler\nsudo apt-get install gcc-aarch64-linux-gnu\n# gnu c++ compiler\nsudo apt-get install g++-aarch64-linux-gnu<\/code><\/pre>\n<h2>\ucef4\ud30c\uc77c<\/h2>\n<h3>Hello, World!<\/h3>\n<pre><code class=\"language-c++\">vi hello.cpp\n--------------------------\n#include &lt;iostream&gt;\nusing namespace std;\n\nint main() {\n    cout &lt;&lt; &quot;Hello, World!&quot; &lt;&lt; endl;\n    return 0;\n}\n--------------------------\n\narm-linux-gnueabihf-g++ -g -o hello hello.cpp\nfile hello\nhello: ELF 32-bit LSB shared object, ARM, EABI5 version 1 (SYSV) ......\n\naarch64-linux-gnu-g++ -g -o hello hello.cpp\nfile hello\nhello: ELF 64-bit LSB shared object, ARM aarch64, version 1 (SYSV) ......<\/code><\/pre>\n<h3>make<\/h3>\n<p><font color=red>\uc6b0\uc120 \uc54c\uc544\uc57c \ud560 \uac83\uc740 make \uac00 \uc9c1\uc811\uc801\uc73c\ub85c cross compile \uc744 \uc9c0\uc6d0\ud558\ub294 \uac83\uc774 \uc544\ub2c8\ub77c,<br \/>\nMakefile \uc5d0 cross compile \uc744 \uc9c0\uc6d0\ud558\ub3c4\ub85d \uc124\uc815\ud574\uc57c \ud558\ub294 \uac83\uc785\ub2c8\ub2e4.<\/font><\/p>\n<p>\ub4e4\uc5ec\uc4f0\uae30\ub294 TAB \ubb38\uc790\ub85c\ub9cc \uc774\ub8e8\uc5b4\uc838\uc57c \ud569\ub2c8\ub2e4.<br \/>\n\uacf5\ubc31\ubb38\uc790\uac00 \uc788\ub294 \uacbd\uc6b0 \uc624\ub958\uac00 \ubc1c\uc0dd\ud569\ub2c8\ub2e4.<\/p>\n<pre><code class=\"language-Makefile\">AR=${CROSS_COMPILE}ar\nAS=${CROSS_COMPILE}as\nLD=${CROSS_COMPILE}ld\nCC=$(CROSS_COMPILE)gcc\nCXX=$(CROSS_COMPILE)g++\nNM=${CROSS_COMPILE}nm\nRANLIB=${CROSS_COMPILE}ranlib\n\nCFLAGS=&quot;&quot;\nCPPFLAGS=&quot;&quot;\nLDFLAGS=&quot;&quot;\nLIBS=&quot;&quot;\n\nhello : hello.cpp\n        $(CXX) -g -o hello hello.cpp\n\nclean:\n        rm hello<\/code><\/pre>\n<p>make \ub97c \uc774\uc6a9\ud558\uc5ec \ucef4\ud30c\uc77c\ud558\ub294 \uacbd\uc6b0, \uc544\ub798\uc640 \uac19\uc774 \ud658\uacbd\uc124\uc815\uc744 \ucd94\uac00\ud558\uace0 \ucef4\ud30c\uc77c\ud558\uba74 \ub429\ub2c8\ub2e4.<\/p>\n<pre><code class=\"language-bash\"># 32bit, GPU \uc5c6\ub294 \uacbd\uc6b0\nexport CROSS_COMPILE=arm-linux-gnueabi-\nexport ARCH=arm\n# 32bit, GPU \uc788\ub294 \uacbd\uc6b0\nexport CROSS_COMPILE=arm-linux-gnueabihf-\nexport ARCH=arm\n# 64bit\nexport CROSS_COMPILE=aarch64-linux-gnu-\nexport ARCH=arm64\n\nmake\n\nfile hello\nhello: ELF 64-bit LSB shared object, ARM aarch64, version 1 (SYSV) ......<\/code><\/pre>\n<p>\uc544\ub798 \uba85\ub839\uc744 .bashrc \uc5d0 \ucd94\uac00\ud574 \ub193\uc73c\uba74 \ud3b8\ud569\ub2c8\ub2e4.<\/p>\n<pre><code class=\"language-bash\">alias armmake=&#039;make -j8 ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- &#039;\nalias arm64make=&#039;make -j8 ARCH=arm CROSS_COMPILE=aarch64-linux-gnu- &#039;<\/code><\/pre>\n<h3>cmake<\/h3>\n<p>\uc0d8\ud50c\ub85c json-c \ub77c\uc774\ube0c\ub7ec\ub9ac\ub97c \ucef4\ud30c\uc77c\ud569\ub2c8\ub2e4.<\/p>\n<pre><code class=\"language-bash\">git clone https:\/\/github.com\/json-c\/json-c.git\ncd json-c\nmkdir build\ncd build\n# cmake ..<\/code><\/pre>\n<pre><code class=\"language-bash\">vi ..\/toolchain.arm.cmake\n-------------------------------\nSET(CMAKE_C_COMPILER ${CROSS_COMPILE}gcc)\nSET(CMAKE_CXX_COMPILER ${CROSS_COMPILE}g++)\nSET(CMAKE_LINKER ${CROSS_COMPILE}ld)\nSET(CMAKE_NM ${CROSS_COMPILE}nm)\nSET(CMAKE_OBJCOPY ${CROSS_COMPILE}objcopy)\nSET(CMAKE_OBJDUMP ${CROSS_COMPILE}objdump)\nSET(CMAKE_RANLIB ${CROSS_COMPILE}ranlib)\n-------------------------------<\/code><\/pre>\n<pre><code class=\"language-bash\">cmake -DCMAKE_TOOLCHAIN_FILE=toolchain.arm.cmake -DCROSS_COMPILE=aarch64-linux-gnu- ..\n\nmake\nfile libjson-c.so.5.1.0\nlibjson-c.so.5.1.0: ELF 64-bit LSB shared object, ARM aarch64, version ......<\/code><\/pre>\n<h3>configure<\/h3>\n<pre><code class=\"language-bash\">.\/configure --host=arm-linux-gnueabi<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Ubuntu 20.04 ARM Cross Compile \ud558\uae30 \uae30\ucd08\uc9c0\uc2dd ARM \uc740 hard float(\ud558\ub4dc\uc6e8\uc5b4 GPU) \uac00 \uc788\ub294 \ubc84\uc804\uc774 \uc788\uace0, \uc5c6\ub294 \ubc84\uc804\uc774 \uc788\uc2b5\ub2c8\ub2e4. EABI(Embedded Application Binary Interface)\ub294, ARM\uc758 C \ud638\ucd9c \uad00\ud589\uc774\ub77c\uace0 \uc774\ud574\ud558\uba74 \ub429\ub2c8\ub2e4. \ud234\uccb4\uc778 \uc124\uce58 \uac1c\ubc1c\uc6a9 \ud544\uc218 \ub77c\uc774\ube0c\ub7ec\ub9ac \uc124\uce58 sudo apt-get install build-essential hard float(\ud558\ub4dc\uc6e8\uc5b4 GPU) \uac00 \uc788\ub294 \uacbd\uc6b0 # gnu c compiler(32bit) sudo apt-get install gcc-arm-linux-gnueabihf # gnu\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.skyer9.pe.kr\/wordpress\/?p=4518\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23],"tags":[],"class_list":["post-4518","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/4518","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4518"}],"version-history":[{"count":24,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/4518\/revisions"}],"predecessor-version":[{"id":4641,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/4518\/revisions\/4641"}],"wp:attachment":[{"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4518"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4518"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4518"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}