因此,这里我有一个用于Objective-C的基本“ hello world”脚本,我在笔记本电脑上安装了Ubuntu,并希望使用Ubuntu开始编译基本思想,额外的类或任何有价值的东西,这些东西可以随时随地为我当前的任何项目编写代码,这样一来,无论我身在何处,我都可以编写一些代码,而不必总是在我的iMac上。
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
我进行了一些研究,找到了目前可行的解决方案。我可能会发布一个新问题,以查看是否有一种方法可以缩短此时间。但这成功地编译了我的代码。谢谢所有提供帮助的人,我肯定学到了一些新东西。
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] 删除。
我来说两句