Build the objective-C compiling environment under longcore 8089d-debian7

Source: Internet
Author: User
Build the objective-C compiling environment directory under the dragon core 8089d-debian7
  • Install Related Files
  • Compilation parameter description
  • Simplify command line parameters
  • Actual compilation instance

Simple Description: Objective-C'sCFile suffix.mThe header file suffix is.hFor example, the routine in this tutorial ismain.m.

Install Related Files

Install these packages:gcc,g++,gobjc,gnustep,gnustep-devel,gnustep-gui-dev,libgnustep-base-dev.

The installation command is simple:

apt-get install gcc g++ gobjc gnustep gnustep-devel gnustep-gui-dev libgnustep-base-dev

After installation, you can proceed to the next step.

Compilation parameter description

For different releasesLinuxCompileObjective-CThe command parameters are slightly different inDebianThe following parameters are required:

`gnustep-config --objc-flags`-fconstant-string-class=NSConstantString-lobjc-lgnustep-base

In addition, you must specify the location of the header file (include file) and library file (LIB file ).DebianAnd their positions are/usr/include/GNUstep/And/usr/lib/GNUstep/The parameters are as follows:

-I /usr/include/GNUstep/-L /usr/lib/GNUstep/

The compilation command that combines the above parameters is as follows:

gcc `gnustep-config --objc-flags` -fconstant-string-class=NSConstantString -lobjc -lgnustep-base -I /usr/include/GNUstep/ -L /usr/lib/GNUstep/ -o main main.m

However, every time you input so many parameters, it is a little complicated. Next we will create an alias for this long string of commands.alias

Simplify command line parameters

The command to create an alias is as follows:

alias objcc=‘gcc `gnustep-config --objc-flags` -fconstant-string-class=NSConstantString -lobjc -lgnustep-base -I /usr/include/GNUstep/ -L /usr/lib/GNUstep/‘

To save this command to the System~/.bashrcFile. Copy this command.bashrcAnd then execute:

source ~/.bashrc

Compile laterObjective-CThe file can use an alias.objccIt's easy:

objcc -o main main.m

Note: In this alias commandSingle quotes: ''AndReverse quotation marks: ''Do not confuse.

Actual compilation instance

Finally, it is based on an actualObjective-CProgram example to illustrate, below is our routinemain.mContent:

#import <Foundation/Foundation.h>int main(int argc,const char * argv[]){    NSLog(@"hello world!");    return(0);}

Save the above Codemain.mAnd then execute:

objcc -o main main.m

The current directory will generatemain.

It must be noted that the executable file can only beDebianIf you wantDebianThe following part can be translated inOSXSome additional cross-compilation parameters are required for the executable file to run.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.