Example of using this static library in manual compilation of static libraries and Xcode under Mac OS (i)

Source: Internet
Author: User
the first part of the Mac OS to create a static library Preface

As we all know, Mac OS is actually written based on Unix, so it retains many of the original UNIX features, in the case of static libraries, still named after Libxxxx.a. There are many ways to compile a static library under a Mac, such as using Xcode creation and compilation, and you can create and compile directly using the command line (which can be combined with makefile), which will be described in the form of a command line (which can be combined makefile).

In this example, a LIBPERSON.A static library is compiled, which provides a showname function to print out the string "Brian" in the console. Write source file Person.h

The contents of the document are as follows:

#ifndef __person_h__
#define __person_h__

void ShowName ();

#endif

The contents of the source file person.c file are as follows:

#include "person.h"
#include <stdio.h>
#include <stdlib.h>

void ShowName ()
{
	printf ("brian./n");
}

compile the static library Libperson.a

$ gcc-c person.c
$ ar-r libperson.a PERSON.O

So far, we have compiled the Libperson.a static library files we need.


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.