如何使用终端在Ubuntu中编译/构建和运行Objective-C程序?

凯西

因此,这里我有一个用于Objective-C的基本“ hello world”脚本,我在笔记本电脑上安装了Ubuntu,并希望使用Ubuntu开始编译基本思想,额外的类或任何有价值的东西,这些东西可以随时随地为我当前的任何项目编写代码,这样一来,无论我身在何处,我都可以编写一些代码,而不必总是在我的iMac上。

helloworld.m

Now my only question is how do I build and run this code in terminal? Obviously it's not that important since I'm coding for iOS and OSX so the only code that will display is anything that doesn't call on the SDK's or Cocoa scripts, so basically it should only display basic text commands such as "NSLog" or whatever, you get the just of what I'm trying to do, which is what I want. That way I can check for small errors at the very least.

I've looked around and I've found several helps for default shell scripts and such that call on the gcc directory or something of the sort from my understanding. I have created my own folder for Objective-C projects located in my documents and I had no idea if that is effecting my ability to run the file using the terminal commands that I've tried or not, but in case it is I store the projects in:

Home>Documents>Objective-C>helloworld.m

Also when running the command line:

gcc -o helloworld.m

or this

gcc -I/home/caseyerdmann/Documents/Objective-C/helloworld.m

or any version of that command line I receive this error:

gcc: fatal error: no input files
compilation terminated.

I believe I have all the compiler files installed but I am not opposed to a full tutorial, whatever gets this running. Now to clarify and gather a visual aid for you guys to try and help me better my text file is located in my documents:

文件目录

And you can visually see the directory it is placed in. Now when I run any of the commands above that I have tried in terminal it yields this result:

终端

It doesn't matter which command I use it is always that. I hope this helps a little bit more to provide an answer for my situation. I am not opposed to a full tutorial and having to save my file elsewhere or make any other changes by any means, in fact it'd be appreciated! I just would love to get this running.

I did some research and noticed the answers on this already are providing me with help to run the hello.m script that comes inside the GNUstep libraries, this is not what I am trying to do. However because I'm having trouble getting the default script to run I think I may have another problem as well, I'm going to continue researching to see if I can get that script to run, in the mean time any help is appreciated!

UPDATE: I have tried a new command and yielded a new result, though it was also unsuccessful in compiling I think it may help answer others to answer this. This is what I tried:

gcc -o helloworld.m -lobjc

and this was the result:

/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu/crt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
collect2: ld returned 1 exit status
Casey

我进行了一些研究,找到了目前可行的解决方案。我可能会发布一个新问题,以查看是否有一种方法可以缩短此时间。但这成功地编译了我的代码。谢谢所有提供帮助的人,我肯定学到了一些新东西。

gcc -o hello hello.m \
    -I `gnustep-config --variable=GNUSTEP_SYSTEM_HEADERS` \
    -L `gnustep-config --variable=GNUSTEP_SYSTEM_LIBRARIES` \
    -lgnustep-base -fconstant-string-class=NSConstantString \
    -D_NATIVE_OBJC_EXCEPTIONS

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

如何使用终端在Ubuntu中编译/构建和运行Objective-C程序?

来自分类Dev

如何构建从Ubuntu中的终端运行的简单程序

来自分类Dev

如何在Ubuntu终端中编译,运行和反编译C#代码?

来自分类Dev

如何使用c ++ / python程序在终端中运行程序,然后在该程序中执行语句

来自分类Dev

在Vim中编译后如何在新的终端窗口上运行C ++程序?

来自分类Dev

制作bash脚本以构建和运行C ++程序

来自分类Dev

如何在Mac终端中运行C ++程序

来自分类Dev

如何在Ubuntu终端中运行方案程序?

来自分类Dev

如何使用Ubuntu终端运行Map Reduce程序?

来自分类Dev

在Ubuntu终端中编译复杂的Java程序

来自分类Dev

如何构建和部署BPF BCC C ++应用程序?

来自分类Dev

如何使用Eclipse for Mac编译和运行C ++程序?

来自分类Dev

如何使用CMake使Python脚本编译和运行C ++程序

来自分类Dev

使用代码运行器在VS代码中编译C程序

来自分类Dev

c中的mpi程序编译但不运行

来自分类Dev

使用CMake在构建后运行C ++程序

来自分类Dev

如何在Geany IDE中发出构建命令来编译和执行Objective-C程序?

来自分类Dev

如何使用GStreamer编译C / C ++程序

来自分类Dev

从Java程序编译C程序

来自分类Dev

如何在Ubuntu 18.04中编译C程序文件

来自分类Dev

如何在 gmsh 中构建和运行 C++ API 演示?

来自分类Dev

错误:无法运行C编译程序。如果您打算交叉编译使用--host'Ubuntu

来自分类Dev

错误:无法运行C编译程序。如果您打算交叉编译使用--host'Ubuntu

来自分类Dev

在终端(C 文件)中运行程序但未运行完成

来自分类Dev

帮助在Ubuntu中运行C程序

来自分类Dev

帮助在Ubuntu中运行C程序

来自分类Dev

在Ubuntu中运行C#程序的IDE

来自分类Dev

如何在终端中更改已编译C程序的最终位置

来自分类Dev

在Vim中编译C ++程序

Related 相关文章

  1. 1

    如何使用终端在Ubuntu中编译/构建和运行Objective-C程序?

  2. 2

    如何构建从Ubuntu中的终端运行的简单程序

  3. 3

    如何在Ubuntu终端中编译,运行和反编译C#代码?

  4. 4

    如何使用c ++ / python程序在终端中运行程序,然后在该程序中执行语句

  5. 5

    在Vim中编译后如何在新的终端窗口上运行C ++程序?

  6. 6

    制作bash脚本以构建和运行C ++程序

  7. 7

    如何在Mac终端中运行C ++程序

  8. 8

    如何在Ubuntu终端中运行方案程序?

  9. 9

    如何使用Ubuntu终端运行Map Reduce程序?

  10. 10

    在Ubuntu终端中编译复杂的Java程序

  11. 11

    如何构建和部署BPF BCC C ++应用程序?

  12. 12

    如何使用Eclipse for Mac编译和运行C ++程序?

  13. 13

    如何使用CMake使Python脚本编译和运行C ++程序

  14. 14

    使用代码运行器在VS代码中编译C程序

  15. 15

    c中的mpi程序编译但不运行

  16. 16

    使用CMake在构建后运行C ++程序

  17. 17

    如何在Geany IDE中发出构建命令来编译和执行Objective-C程序?

  18. 18

    如何使用GStreamer编译C / C ++程序

  19. 19

    从Java程序编译C程序

  20. 20

    如何在Ubuntu 18.04中编译C程序文件

  21. 21

    如何在 gmsh 中构建和运行 C++ API 演示?

  22. 22

    错误:无法运行C编译程序。如果您打算交叉编译使用--host'Ubuntu

  23. 23

    错误:无法运行C编译程序。如果您打算交叉编译使用--host'Ubuntu

  24. 24

    在终端(C 文件)中运行程序但未运行完成

  25. 25

    帮助在Ubuntu中运行C程序

  26. 26

    帮助在Ubuntu中运行C程序

  27. 27

    在Ubuntu中运行C#程序的IDE

  28. 28

    如何在终端中更改已编译C程序的最终位置

  29. 29

    在Vim中编译C ++程序

热门标签

归档