Query the installation and configuration environments. Because I have long said goodbye to VMware, I started to build the compiling environment for obj-C under my ubuntu. However, I started to find a gnustep-devel Project Manager IDE in Ubuntu Software Center, and then install it directly. So, I don't know if I have installed this IDE, and then executed it again according to the order of the post to get Hello world. I am a little uncertain. Is it true that my ide has succeeded and this post does not play a role? I should say that both have been successfully set up, but I just repeated it again. But the final result is good, that is, success. If you want to re-build it later, check whether the installation is successful directly from the Ubuntu Software Center. You can also check the installation to avoid repeated installation, which is a waste of time.
| [Date: 2010-08-24] |
Source: lnux community Author: liangmangui |
I. From one o'clock P.M. to half past five, four simple applications were introduced at the iPhone application presentation, which is really interesting.
2. There are three methods below, and only the third method is successful.
1. You can program the objective-C without macbook.
Please refer the below link to install objective-C compiler in you Ubuntu
Mchine.
Http://d.hatena.ne.jp/tomute/20090112/1231809116
2. Ubuntu
9.10 build an object-C development environment (for example, this write is complete but fails)
Object-
C is an extension of the C language by Apple, but its supporting development environment must run on the leopard system, and the system must run on the Mac machine, but I am still a student, change the apple book
Not very practical. It is really willing to change the current system to Leopard. It didn't take much effort to configure this system at the beginning. The performance of installing leopard on a virtual machine is unacceptable, but you have to try to build it.
We are lucky to have a development environment other than xcode, ubuntu.
You can use gnustep. There are a lot of instructions on the installation process on the Internet, but they are not detailed, and there are many errors, even more helpless is that there are still n more people who don't verify that the content is correct or incorrect, so they use the post, which brings a lot of trouble to the search, but they have no choice but to study and query the information, finally, let's talk about the specific steps:
1) install gnustep-devel. you can install gnustep through sudo apt-Get.
Gnustep-devel installation, but the installation will tell you that many packages are no longer available, a better way is to install it using the new software package manager, and enter: gnustep-
Devel: Right-click the package to install it. A prompt is displayed, indicating that you need to install many other dependent packages. click confirm and then click the application.
2) After installation, it is also the most critical step. It is to configure the environment variables of gnustep-make. Unlike windows, UBUNTU
Of
The user environment variables are placed in. in the bashrc file, this file is in the root directory of the user. Of course, you cannot find it because it is hidden. If the Ubuntu system wants to hide the file, it is in the file
Add. In front of the name to display the hidden file by pressing CTRL + H. Therefore, in the root directory of the user, after displaying the hidden file, find. cshrc
[Bing Note: I didn't see this when I installed it early. I copied this configuration directly at the end of bashrc. I don't know if it was my mistake, or if my version is Ubuntu 10. there are too many, not that file
], Add the following configuration at the end:
# Set gnustep
Gnustep_root =/usr/share/gnustep
Export gnustep_root
Source/usr/share/gnustep/makefiles/gnustep. Sh
If you do not add the above configuration, the/common will be prompted when compiling the objective-C source file. make,/tool. make cannot be found, which has plagued me for a long time, so this is very important.
After completing the above configuration, we have already set up the object-C development environment. Next we will use gnustep to develop an object-C for testing.
1) application-> programming-> Project Manager ide-> file-> New-> source file-> Objective-C language source file
Then write a simple hello World Program
2) file-> Save is saved in a directory. Remember to save it as the objective-C type. You can see that the file type is. M.
3) then create an empty file in the directory. No file type is required, but the name must be gnumakefile. The content is as follows:
Include $ (gnustep_makefiles)/common. Make
Tool_name = logtest
Logtest_objc_files = source. m
Include $ (gnustep_makefiles)/tool. Make
Here, logtest can be changed to the task name, which indicates the executable file name after compilation. It only needs to be unified in two places. Source. m is the original file name you just saved and changed to you.
Here, $ (gnustep_makefiles) references the path of the gnustep-make that we have set. Therefore, step 1 is not set. It cannot be found here.
Directory.
4) after writing the file, enter the directory on the terminal and execute make. If everything is okay, an OBJ directory will be added to the directory, it contains compiled executable files.
5) Run./obj/logtest again to see the running result. Note that the logtest here corresponds to the above. Of course, you can replace it with your own
3. Ubuntu
Set up the development environment of Object-C (this is simple and successful)
The GNU Compiler only supports the most basic part of Object-C.
To use the entire objective-C Cocoa/openstep environment, you must install the packages supported by GCC and objective-C, and the gnustep environment.
First install gnustep and gobjc
Sudo apt-Get install gobjc gnustep-devel
Get a hello World code and try to compile it once.
# Import <stdio. h>
Int main (INT argc, const char * argv []) {
Printf ("Hello World/N ");
Return 0;
}
Then execute the compilation:
GCC hello. M-O hello
If the object-C library is called, the above compilation command will fail. Use the following command:
GCC 'gnustep-config -- objc-flags '-lgnustep-base hello. M-O hello
Then let the Code look at it
./Hello
Entered
Hello World
OK
// Here is my test code:
# Import <stdio. h>
# Import <Foundation/Foundation. h>
Int main (INT argc, const char * argv []) {
Printf ("say: Hello World/N ");
Printf ("Use the foudation/N ");
Nslog (@ "nslog Object C/N ");
Return 0;
}
Output:
Host @ host-LAPTOP :~ $ GCC 'g-O testconfig -- objc-flags '-lgnustep-base test. M-o Test
Host @ host-LAPTOP :~ $./Test
Say: Hello World
Use the foudation
12:32:58. 365 test [10910] nslog Object C
Host @ host-LAPTOP :~ $