{"id":97,"date":"2026-07-19T13:08:14","date_gmt":"2026-07-19T13:08:14","guid":{"rendered":"https:\/\/demensdeum.com\/blog\/2026\/07\/19\/crosscompile-for-macos-on-ubuntu-cmake\/"},"modified":"2026-07-19T13:08:14","modified_gmt":"2026-07-19T13:08:14","slug":"crosscompile-for-macos-on-ubuntu-cmake","status":"publish","type":"post","link":"https:\/\/demensdeum.com\/blog\/es\/2026\/07\/19\/crosscompile-for-macos-on-ubuntu-cmake\/","title":{"rendered":"Building macOS applications for Ubuntu OSXCross CMake"},"content":{"rendered":"<p>In this post, I will describe building cross-platform C++ applications for macOS on an Ubuntu build machine using CMake and osxcross.<br \/>\nFirst, install the osxcross toolchain:<br \/>\n<a href=\"https:\/\/github.com\/tpoechtrager\/osxcross\" rel=\"noopener\" target=\"_blank\">https:\/\/github.com\/tpoechtrager\/osxcross<\/a><br \/>\nInstallation occurs in 3 stages, downloading dependencies:<\/p>\n<div class=\"hcb_wrap\">\n<pre class=\"prism undefined-numbers lang-unknown\" data-lang=\"unknown\"><code>cd tools\n.\/get_dependencies.sh\n<\/code><\/pre>\n<\/div>\n<p>Download XCode.xip from the official Apple website, then download the SDK from XCode:<\/p>\n<div class=\"hcb_wrap\">\n<pre class=\"prism undefined-numbers lang-unknown\" data-lang=\"unknown\"><code>.\/gen_sdk_package_pbzx.sh \/media\/demensdeum\/2CE62A79E62A4404\/LinuxSupportStorage\/xcode111.xip\n<\/code><\/pre>\n<\/div>\n<p>I hope you read the XCode license agreement in the last step? Next, build the toolchain with the required prefix:<\/p>\n<div class=\"hcb_wrap\">\n<pre class=\"prism undefined-numbers lang-unknown\" data-lang=\"unknown\"><code>INSTALLPREFIX=\/home\/demensdeum\/Apps\/osxcross .\/build.sh \n<\/code><\/pre>\n<\/div>\n<p>Now you can use osxcross from the prefix directory of the previous step. Let&#8217;s add a new build macro for CMake and write everything necessary:<\/p>\n<div class=\"hcb_wrap\">\n<pre class=\"prism undefined-numbers lang-unknown\" data-lang=\"unknown\"><code>if (OSXCROSS)\nSET(CMAKE_SYSTEM_NAME Darwin)\nSET(CMAKE_C_COMPILER o64-clang)\nSET(CMAKE_CXX_COMPILER o64-clang++)\nSET(CMAKE_C_COMPILER_AR x86_64-apple-darwin19-ar)\nSET(CMAKE_CXX_COMPILER_AR x86_64-apple-darwin19-ar)\nSET(CMAKE_LINKER x86_64-apple-darwin19-ld)\nSET(ENV{OSXCROSS_MP_INC} 1)\nendif()\n<\/code><\/pre>\n<\/div>\n<p>Dynamic linking was not successful for me, so we export the libraries statically:<\/p>\n<div class=\"hcb_wrap\">\n<pre class=\"prism undefined-numbers lang-unknown\" data-lang=\"unknown\"><code>if (OSXCROSS)\nadd_library(FlameSteelCore STATIC ${SOURCE_FILES})\nelse()\n<\/code><\/pre>\n<\/div>\n<p>Next, you may be faced with the fact that you do not have the necessary libraries for osxcross, I encountered this when using SDL2. osxcross supports ready-made library packages &#8211; macports. For example, installing SDL2-mixer:<\/p>\n<div class=\"hcb_wrap\">\n<pre class=\"prism undefined-numbers lang-unknown\" data-lang=\"unknown\"><code>osxcross-macports -v install libsdl2_mixer\n<\/code><\/pre>\n<\/div>\n<p>After this, you can start building libraries\/applications as usual in the cmake-make link, do not forget to specify static linking of libraries if necessary.<\/p>\n<h3>Manual assembly of libraries<\/h3>\n<p>Currently, I have encountered the problem of incorrect archiving of libraries during static linking; when building the final application I receive the error:<\/p>\n<div class=\"hcb_wrap\">\n<pre class=\"prism undefined-numbers lang-unknown\" data-lang=\"unknown\"><code>file was built for archive which is not the architecture being linked (x86_64)\n<\/code><\/pre>\n<\/div>\n<p>Very similar to <a href=\"https:\/\/github.com\/tpoechtrager\/osxcross\/issues\/11\" rel=\"noopener\" target=\"_blank\">this ticket<\/a>, we managed to implement a workaround resulting in the build completing correctly. Let&#8217;s unzip the static library and build it anew using the osxcross archiver:<\/p>\n<div class=\"hcb_wrap\">\n<pre class=\"prism undefined-numbers lang-unknown\" data-lang=\"unknown\"><code>ar x ..\/libFlameSteelCore.a\nrm ..\/libFlameSteelCore.a\nx86_64-apple-darwin19-ar rcs ..\/libFlameSteelCore.a *.o\n<\/code><\/pre>\n<\/div>\n<p>Also, one of the problems I personally consider is the lack of ability to run macOS applications directly on Ubuntu (at least with part of the functionality). Of course, there is a project <a href=\"https:\/\/github.com\/darlinghq\/darling\" rel=\"noopener\" target=\"_blank\">darling<\/a>, but the support still leaves much to be desired.<\/p>\n<h3>Sources<\/h3>\n<p><a href=\"https:\/\/github.com\/tpoechtrager\/osxcross\" rel=\"noopener\" target=\"_blank\">https:\/\/github.com\/tpoechtrager\/osxcross<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this post, I will describe building cross-platform C++ applications for macOS on an Ubuntu build machine using CMake and osxcross. First, install the osxcross toolchain: https:\/\/github.com\/tpoechtrager\/osxcross Installation occurs in 3 stages, downloading dependencies: cd tools .\/get_dependencies.sh Download XCode.xip from the official Apple website, then download the SDK from XCode: .\/gen_sdk_package_pbzx.sh \/media\/demensdeum\/2CE62A79E62A4404\/LinuxSupportStorage\/xcode111.xip I hope you [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-97","post","type-post","status-publish","format-standard","hentry","category-notes"],"translation":{"provider":"WPGlobus","version":"3.0.3","language":"es","enabled_languages":["en","ru","zh","de","ja","fr","es","pt","hi"],"languages":{"en":{"title":true,"content":true,"excerpt":false},"ru":{"title":true,"content":true,"excerpt":false},"zh":{"title":true,"content":true,"excerpt":false},"de":{"title":true,"content":true,"excerpt":false},"ja":{"title":true,"content":true,"excerpt":false},"fr":{"title":true,"content":true,"excerpt":false},"es":{"title":false,"content":false,"excerpt":false},"pt":{"title":true,"content":true,"excerpt":false},"hi":{"title":true,"content":true,"excerpt":false}}},"_links":{"self":[{"href":"https:\/\/demensdeum.com\/blog\/es\/wp-json\/wp\/v2\/posts\/97","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/demensdeum.com\/blog\/es\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/demensdeum.com\/blog\/es\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/demensdeum.com\/blog\/es\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/demensdeum.com\/blog\/es\/wp-json\/wp\/v2\/comments?post=97"}],"version-history":[{"count":0,"href":"https:\/\/demensdeum.com\/blog\/es\/wp-json\/wp\/v2\/posts\/97\/revisions"}],"wp:attachment":[{"href":"https:\/\/demensdeum.com\/blog\/es\/wp-json\/wp\/v2\/media?parent=97"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/demensdeum.com\/blog\/es\/wp-json\/wp\/v2\/categories?post=97"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/demensdeum.com\/blog\/es\/wp-json\/wp\/v2\/tags?post=97"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}