标题:创建动态链接库
只看楼主
BlueGuy
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:29
帖 子:4476
专家分:4055
注 册:2009-4-18
结帖率:94.72%
已结贴  问题点数:8 回复次数:2 
创建动态链接库
程序代码:
#ifdef _LIB
#ifndef HELLOWORLD_API
#define HELLOWORLD_API extern
#define    HELLOWORLDLIB_API extern
#pragma message("LIB")
#endif
#endif

#ifdef _USRDLL
#ifdef HELLOWORLDLIBDLL_EXPORTS
#define HELLOWORLD_API extern  __declspec(dllexport)
#define HELLOWORLDLIB_API extern __declspec(dllexport)
#pragma message("Create HELLOWORLD dllexport")
#else
#define HELLOWORLD_API extern __declspec(dllimport)
#define HELLOWORLDLIB_API extern __declspec(dllimport)
#pragma message("Using HELLOWORLD dllexport")
#endif
#endif

#ifdef __cplusplus
extern "C" {
#endif 

    HELLOWORLD_API void print();
    HELLOWORLD_API int add(int a, int b);

#ifdef __cplusplus
}
#endif 


程序代码:
#include <stdio.h>
#include "HelloWorldDll.h"

int main()
{
    print();
    int c = add(1, 2);
    return 0;
}

/*
void print()
{
    printf("hello world");
}

int add(int a, int b)
{
    return a+b;
}
*/
搜索更多相关主题的帖子: message color 动态 
2016-01-26 12:29
wp231957
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:神界
等 级:版主
威 望:422
帖 子:13681
专家分:53296
注 册:2012-10-18
得分:8 

DO IT YOURSELF !
2016-01-26 12:46
admrtyz
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2015-1-10
得分:0 
全是宏定义。哈哈
2016-01-29 19:48



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-461358-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.086303 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved