zoukankan      html  css  js  c++  java
  • qt学习(八)动态库和静态库的实现和调用

    动态库和静态库的实现和调用

    1.新建->library->c++库,共享库,编写库的名称

    #ifndef T14LIBRARY_H
    #define T14LIBRARY_H
    
    #include "t14library_global.h"
    
    class T14LIBRARYSHARED_EXPORT T14Library
    {
    
    public:
        T14Library();
    
        void Encrypt();
    };
    
    #endif // T14LIBRARY_H
    #ifndef T14LIBRARY_GLOBAL_H
    #define T14LIBRARY_GLOBAL_H
    
    #include <QtCore/qglobal.h>
    
    #if defined(T14LIBRARY_LIBRARY)
    #  define T14LIBRARYSHARED_EXPORT Q_DECL_EXPORT
    #else
    #  define T14LIBRARYSHARED_EXPORT Q_DECL_IMPORT
    #endif
    
    #endif // T14LIBRARY_GLOBAL_H
    #include "t14library.h"
    #include <QDebug>
    
    T14Library::T14Library()
    {
    }
    
    
    void T14Library::Encrypt()
    {
        qDebug() << "Encrypt";;
    }

    2.新建一个项目调用库函数

    SOURCES += 
        main.cpp
    
    # 如果QT mingw版本,使用动态库方式和linux没区别(-L, -l)
    # 如果QT VS版本。。。使用动态库方式和windows没区别
    # 如果QT mingw版本,要调用VS写的动态库,使用一个工具,生成libXXXXX.a文件
    LIBS += -LD:QTQT0718uild-T14Library-Desktop_Qt_5_3_0_MinGW_32bit-Debugdebug -lT14Library
    #include <QCoreApplication>
    
    #include "../T14Library/t14library.h"
    
    int main(int argc, char* argv[])
    {
        QCoreApplication app(argc, argv);
    
        T14Library d;
        d.Encrypt();
    
        app.exec();
    }

    3.静态库

    1.新建->library->c++库,静态链接库,编写库的名称

  • 相关阅读:
    Maven项目中Spring整合Mybatis
    java中,方法可以访问他的类对象的任何私有特性
    SpringBoot之整合Mybatis(增,改,删)
    SpringBoot之整合Mybatis
    SpringBoot之简单入门
    puppet-master搭建
    基于weka的文本分类实现
    static关键字用法
    Vmware /CentOS访问Windows中的文件
    异常备忘
  • 原文地址:https://www.cnblogs.com/rainbow1122/p/8184099.html
Copyright © 2011-2022 走看看