在 Windows 上编译 Objective-C 程序 [英] compiling Objective-C program on Windows

查看:47
本文介绍了在 Windows 上编译 Objective-C 程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一个朋友给我发了 4 个文件(两个 .m 文件,一个 .pch 文件,一个 .h 文件),他说一起编译成一个 Objective-C 程序.据我了解,它是一种 Apple 语言,我使用的是 Windows.我一直试图在 Dev-C++ 上的一个新项目中编译它,但没有任何运气.经过一番研究,我为它下载了一个特殊的 Objective-C 库,并在链接一个 Objective C 程序"下选择了是",但是当我尝试编译它时出现构建错误.

A friend sent me 4 files (two .m files, one .pch file, and one .h file) that he says compile together into an Objective-C program. From what I understand, it's an Apple language, and I use Windows. I've been trying to compile it in a new project on Dev-C++, but haven't had any luck. After some research, I downloaded a special Objective-C library for it and selected "Yes" under "Link an Objective C program," but am getting a build error when I try to compile it.

代码使用 Cocoa,但据我朋友说,如果我导入 Foundation.h 而不是 Cocoa.h,它在 Windows 中的工作方式相同.我在 here 中找到了关于如何编译 Objective-C 程序的教程,但是我不明白第 2 步(即为 GCC 编译器设置环境变量 (C:\GNUstep\mingw\bin\gcc.exe)"),因为我的计算机上不存在该文件.当我按照编译说明进行操作时,出现此错误:sh: gcc: command not found.如果可能,我宁愿在基于 GUI 的编译器中编译它,因为我讨厌使用命令提示符.

The code uses Cocoa, but according to my friend, it will work the same in Windows if I import Foundation.h instead of Cocoa.h. I found a tutorial on how to compile Objective-C programs in Windows here, but I don't understand step 2 (which is "Set environment variable for GCC compiler (C:\GNUstep\mingw\bin\gcc.exe)") since that file doesn't exist on my computer. When I follow the compilation instructions, I get this error: sh: gcc: command not found. If possible, I'd rather compile it in a GUI-based compiler, as I hate working with command prompts.

非常感谢在任何程序上编译这些文件的任何帮助!

Any help with compiling these files on any program is greatly appreciated!

推荐答案

环境变量是 Windows 中所有进程存在的命名字符串.如果您打开一个 cmd 窗口并输入命令 SET,您将看到所有当前定义的环境变量的列表.

Environment variables are named strings that exist for all processes in Windows. If you open a cmd window and enter the command SET you will see a list of all the currently defined environment variables.

在 Windows XP 上,通过右键单击我的电脑并选择属性来添加一个新的.然后点击高级选项卡并点击底部的环境变量按钮.您可以为自己或系统上的所有用户添加变量.

On Windows XP, add a new one by right clicking My Computer and selecting properties. Then hit the advanced tab and click on the environment variables button at the bottom. You can either add the variable for just you or for all users on the system.

我不知道如何为更高版本的 Windows 设置环境变量,但我希望 Google 可能有一些 有用 链接.

I don't know how to set environment variables for later versions of Windows but I expect Google might have some useful links.

从您的一些评论来看,很明显您没有按照说明在同一位置安装 GNUStep.只需对 gcc.exe 进行文件搜索,即可找到它的安装位置.

From some of your comments, it is clear you haven't installed GNUStep in the same place as the instructions. Just do a file search for gcc.exe to find out where you have installed it.

这篇关于在 Windows 上编译 Objective-C 程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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