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

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.