OSX如何使用位于当前工作目录或C ​​/C ++子目录中的GCC/G ++编译框架 [英] OSX How to compile a framework using GCC/G++ sitting in a current working directory or subdirectory C/C++

查看:53
本文介绍了OSX如何使用位于当前工作目录或C ​​/C ++子目录中的GCC/G ++编译框架的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

希望这是一件好事.但是,由于我前段时间很费力地想出了这个问题,并且还没有在堆栈溢出中看到它,所以我想我都会发布问题和答案.

Hopefully this is an ok thing to do. But since I figured it out a while ago with much struggle and haven't yet seen it on stack overflow I figured I'd both post the question and answer.

此问题/解决方案适用于OSX用户使用GCC或G ++编译框架,而无需在其系统上的以下路径中放置框架

This question/solution is for OSX users to compile a framework using GCC or G++ without needing to have the framework in the following path on their system

/System/Library/Frameworks/

推荐答案

此代码将从问题中列出的目录中编译框架.(之前已回答)如何编译使用Framework而不使用Xcode的C程序

This code will compile a framework from the listed directory in the question. (Answered before) How to compile a C program that uses a Framework without using Xcode

gcc ...  -framework frameworkName a.c b.c ... -o out

此代码将从自定义目录编译框架.(据我所知,尚未回答).以下目录/文件的示例.

This code will compile a framework from a custom directory. (Not Answered before as far as I've seen). Example of the following dir/file.

/alt/path/to/framework/frameworkName.framework

.

FLAGS+="-F /alt/path/to/framework/ -framework frameworkName rpath /alt/path/to/framework/"
gcc ...  $FLAGS a.c b.c ... -o out

这将是工作目录的子目录的示例.我知道./通常是惯例,但是我不记得这里是否对我有用.

This would be an example of a subdirectory of the working directory. I know ./ is usually the convention, but I cant remember if that worked for me or not here.

FLAGS+="-F $(PWD)/alt/path/to/framework/ -framework frameworkName rpath $(PWD)/alt/path/to/framework/"
gcc ...  $FLAGS a.c b.c ... -o out 

这是/System/Library/Frameworks/路径和$(PWD)/alt/path/to/framework/路径在同一编译中的组合.

This is a combination of the /System/Library/Frameworks/ path, and the path $(PWD)/alt/path/to/framework/ in the same compilation.

FLAGS+="-F $(PWD)/alt/path/to/framework/ -framework frameworkName2 rpath $(PWD)/alt/path/to/framework/"
gcc ...  -framework frameworkName1 $FLAGS a.c b.c ... -o out

如果有人在堆栈溢出时找到了这个答案/问题,我将立即删除我的问题".这样做的目的是为我自己以外的人提供框架的可移植性.如何?因为如果框架在工作目录中,则可以轻松地随文件/文件夹本身一起移动框架.人们正在尝试这显然不是一件平常的事,但也许会让某人满意的.

If someone does locate this answer/question on stack overflow I will promptly delete my 'question'. The goal of this was to make portability of frameworks for people other than myself. How? Because if the framework is in a working directory, it can easily be moved around with the files/folder itself. It's obviously not a common thing people are trying, but maybe it'll make someones day.

这篇关于OSX如何使用位于当前工作目录或C ​​/C ++子目录中的GCC/G ++编译框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆