{"id":12721,"date":"2019-02-03T23:55:41","date_gmt":"2019-02-03T22:55:41","guid":{"rendered":"http:\/\/blog.wenzlaff.de\/?p=12721"},"modified":"2019-02-03T12:31:01","modified_gmt":"2019-02-03T11:31:01","slug":"quick-howto-erzeugung-von-makefiles-mit-cmake-auf-dem-raspberry-pi","status":"publish","type":"post","link":"http:\/\/blog.wenzlaff.de\/?p=12721","title":{"rendered":"Quick-Howto: Erzeugung von Makefiles mit cmake auf dem Raspberry Pi"},"content":{"rendered":"<p>Wir wollen nun mal auf dem Raspberry Pi ein C Programm mit dem Make-Tool <strong>cmake<\/strong> auf dem Pi compilieren und linken. <\/p>\n<p>Gem\u00e4\u00df Wikipedia ist CMake (cross-platform make) eine plattformunabh\u00e4ngiges Programmierwerkzeug f\u00fcr die Entwicklung und Erstellung von Software. <\/p>\n<p>Dazu erstellen wir ein neues Verzeichnis und legen dort die Builddatei <strong>CMakeLists.txt<\/strong> an und f\u00fchren <strong>cmake<\/strong> aus.<\/p>\n<p>Also 1. ein Verzeichnis anlegen und dahin wechseln<\/p>\n<pre class=\"lang:default decode:true \" >mkdir cmake-beispiel\r\ncd cmake-beispiel<\/pre>\n<p>2. Erstellen einer C Beispiel Datei <strong>start.c<\/strong> mit folgenden Inhalt:<\/p>\n<pre class=\"lang:c decode:true \" >#include &lt;stdio.h&gt;\r\nint main()\r\n{\r\n   printf(\"Hallo Thomas, cmake ist cool!\");\r\n   return 0;\r\n}\r\n<\/pre>\n<p>3. Erstellen einer <strong>CMakeLists.txt<\/strong> Datei. Achtung Gro\u00df und Kleinschreibung genau so. Mit folgenden Inhalt:<\/p>\n<pre class=\"lang:default decode:true \" >add_executable(startthomas start.c)<\/pre>\n<p>Diese Anweisung besagt, das die <strong>start.c<\/strong> compiliert werden soll und das das Programm dann <strong>startthomas<\/strong> hei\u00dfen soll.<\/p>\n<p>4. Nun k\u00f6nnen wir das Projekt konfigurieren mit <strong>cmake .<\/strong><\/p>\n<p>5. Das Projekt \u00fcbersetzen mit <strong>make<\/strong><\/p>\n<p>6. Nun k\u00f6nnen wir das erzeugte Programm <strong>startthomas<\/strong> ausf\u00fchren <strong>.\/startthomas<\/strong><\/p>\n<p>Hier das Ergebnis:<!--more--><\/p>\n<p><a href=\"http:\/\/blog.wenzlaff.de\/wp-content\/uploads\/2019\/02\/Bildschirmfoto-2019-02-03-um-12.27.07.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/blog.wenzlaff.de\/wp-content\/uploads\/2019\/02\/Bildschirmfoto-2019-02-03-um-12.27.07.png\" alt=\"\" width=\"948\" height=\"752\" class=\"aligncenter size-full wp-image-12729\" srcset=\"http:\/\/blog.wenzlaff.de\/wp-content\/uploads\/2019\/02\/Bildschirmfoto-2019-02-03-um-12.27.07.png 948w, http:\/\/blog.wenzlaff.de\/wp-content\/uploads\/2019\/02\/Bildschirmfoto-2019-02-03-um-12.27.07-300x238.png 300w, http:\/\/blog.wenzlaff.de\/wp-content\/uploads\/2019\/02\/Bildschirmfoto-2019-02-03-um-12.27.07-768x609.png 768w\" sizes=\"auto, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Wir wollen nun mal auf dem Raspberry Pi ein C Programm mit dem Make-Tool cmake auf dem Pi compilieren und linken. Gem\u00e4\u00df Wikipedia ist CMake (cross-platform make) eine plattformunabh\u00e4ngiges Programmierwerkzeug f\u00fcr die Entwicklung und Erstellung von Software. Dazu erstellen wir ein neues Verzeichnis und legen dort die Builddatei CMakeLists.txt an und f\u00fchren cmake aus. Also &hellip; <\/p>\n<p class=\"link-more\"><a href=\"http:\/\/blog.wenzlaff.de\/?p=12721\" class=\"more-link\"><span class=\"screen-reader-text\">\u201eQuick-Howto: Erzeugung von Makefiles mit cmake auf dem Raspberry Pi\u201c <\/span>weiterlesen<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[220],"tags":[377,2741,3537,3538],"class_list":["post-12721","post","type-post","status-publish","format-standard","hentry","category-anleitung","tag-build","tag-c","tag-cmake","tag-make"],"_links":{"self":[{"href":"http:\/\/blog.wenzlaff.de\/index.php?rest_route=\/wp\/v2\/posts\/12721","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/blog.wenzlaff.de\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/blog.wenzlaff.de\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/blog.wenzlaff.de\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/blog.wenzlaff.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=12721"}],"version-history":[{"count":0,"href":"http:\/\/blog.wenzlaff.de\/index.php?rest_route=\/wp\/v2\/posts\/12721\/revisions"}],"wp:attachment":[{"href":"http:\/\/blog.wenzlaff.de\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=12721"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/blog.wenzlaff.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=12721"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/blog.wenzlaff.de\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=12721"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}