zoukankan      html  css  js  c++  java
  • Makefile编译库

    funs.h:

    #ifndef __FUNS_H__
    #define __FUNS_H__
    
    void fun1();
    
    #endif
    

    funs.c

    #include "funs.h"
    #include <stdio.h>
    
    void fun1()
    {
            printf("this is fun1");
    }

    Makefile

    CC = gcc
    GXX = g++
    LD = ld
    AR = ar
    
    CFLAGS = -g -O2 -Wall -fpic
    LDFLAGS = -shared -fpic
    ARFLAGS = -rc
    
    OBJS = funs.o
    
    LIBNAME = libfuns
    SHARE_LIB = $(LIBNAME).so
    STATIC_LIB = $(LIBNAME).a
    
    .PHONY : all clean
    
    all : clean $(SHARE_LIB) $(STATIC_LIB)
    
    $(STATIC_LIB) : $(OBJS)
            $(AR) $(ARFLAGS) -o $(STATIC_LIB) $(OBJS)
    
    $(SHARE_LIB) : $(OBJS)
            $(LD) $(LDFLAGS) -o $(SHARE_LIB) $(OBJS)
    
    %.o : %.c
            $(CC) $(CFLAGS) -c -o $@ $< 
    
    clean:
            rm -f $(OBJS) $(SHARE_LIB) $(STATIC_LIB)

    main.c

    #include "funs.h"
    
    int main()
    {
            fun1();
    }

    编译:

        gcc -o main.exe -lfuns -L/home/xt/test_lib main.c

  • 相关阅读:
    jQueryEasyUI
    AJAX
    SWFUpload批量上传插件
    jQuery工具函数
    jQuery之Jcrop
    jQuery插件之jqzoom
    jQuery插件之artDialog
    jQuery插件之ajaxFileUpload
    jQuery插件之Cookie
    jQuery插件之Form
  • 原文地址:https://www.cnblogs.com/afan/p/6186886.html
Copyright © 2011-2022 走看看