Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.5k views
in Technique[技术] by (71.8m points)

create c++ binary with make for iOS

I am trying to create a binary using a makefile with iOS as target platform. However, I have only seen the option to use a makefile for macOS as target platform. Is there a way to this also for iOS?

Background: I am trying to embed Google's OR tools (optimization solver) to an iOS app. Those OR tools are written in C++ and require a make file for compiling. To make it more complicated, I am using Flutter for the app. Flutter uses Xcode to create the app. Due to this external build control, integrating the C++ code with a make file seems unlikely. So my plan is to create a C++ binary framework, which I can then embed as an external binary to the project in Xcode. But now I am stuck with getting an iOS target work with that make file. Any ideas?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Make allows you to do whatever you want, provided you can describe it in the makefile. Note that make doesn't help you get around the low-level details of the task (build C++ code for iOS), you have to figure it all out yourself. Make merely automates the repetitive tasks.

So the tricky part is setting up your development workflow for iOS. Find and install the iOS cross-compilation toolchain and libraries, come up with a project structure (i.e. where you keep the headers and source, where the binaries go), try to compile and link a simple "hello world" test program. To verify the result, copy the test binaries to an iOS device and run it. Once all that is clear, you can write a Makefile to automate the build process.

If you have an existing Makefile-based source code targeting a PC or Mac platform, and you're trying to compile and run it on an iOS device, then you're actually porting this project. That is potentially a much harder task to solve than writing a Makefile from scratch. You'd have to be quite familiar with your new target platform (iOS) and its development tools; the project itself and, of course, make.

See also the GNU Make manual


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...