惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
Secure Thoughts
Security Latest
Security Latest
Simon Willison's Weblog
Simon Willison's Weblog
O
OpenAI News
GbyAI
GbyAI
L
LINUX DO - 最新话题
A
Arctic Wolf
T
Tor Project blog
G
GRAHAM CLULEY
I
InfoQ
博客园_首页
IT之家
IT之家
The Register - Security
The Register - Security
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
P
Proofpoint News Feed
The GitHub Blog
The GitHub Blog
Blog — PlanetScale
Blog — PlanetScale
N
Netflix TechBlog - Medium
K
Kaspersky official blog
博客园 - 三生石上(FineUI控件)
S
SegmentFault 最新的问题
U
Unit 42
PCI Perspectives
PCI Perspectives
量子位
P
Palo Alto Networks Blog
S
Securelist
T
Troy Hunt's Blog
博客园 - 【当耐特】
Recorded Future
Recorded Future
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
S
Security Affairs
Engineering at Meta
Engineering at Meta
T
The Blog of Author Tim Ferriss
博客园 - 聂微东
罗磊的独立博客
N
News and Events Feed by Topic
人人都是产品经理
人人都是产品经理
B
Blog RSS Feed
NISL@THU
NISL@THU
C
Cisco Blogs
T
Threatpost
有赞技术团队
有赞技术团队
Forbes - Security
Forbes - Security
Hugging Face - Blog
Hugging Face - Blog
Last Week in AI
Last Week in AI
T
The Exploit Database - CXSecurity.com
Cloudbric
Cloudbric
Cyberwarzone
Cyberwarzone
Google DeepMind News
Google DeepMind News
C
Cyber Attacks, Cyber Crime and Cyber Security

博客园 - Red_angelX

越狱iphone命令行ssh无法连接问题解决 Fedora22编译Qt3.3.X 黑科技项目:英雄无敌III Mod <<Fallen Angel>>介绍 中兴MF667S WCDMA猫Linux拨号笔记 NES模拟器开发-PPU笔记 Source Insight 3.X utf8支持插件更新 NES模拟器开发-CPU笔记 记录Qt的一个诡异Bug 准备开发一款开源NES模拟器 Source Insight 3.X 插件新loader发布 Source Insight 3.X utf8支持插件震撼发布 c语言非线程安全函数引发的BUG一列 Source Insight 3.X 标签插件v1.0发布 用Codeblocks的MinGW编译CxImage BMP图片魔法师KeyGen C#将Trace,Debug信息输出到控件上 让LuaInterface 2.0.1支持中文 五线谱编辑Demo(MFC) C#贴边自动隐藏组件完美版
MinGW编译dll以及静态链接pthread
Red_angelX · 2012-09-03 · via 博客园 - Red_angelX

  最近用MinGW编译一个DLL,遇到几个小问题,记录一下

1,DllMain不执行的问题

DLL写好以后,功能测试ok,但是发现DllMain未执行,导致代码里的初始化和析构均未能执行,查了下生成的dll,发现由于是c++编译,导致DllMain被改名了,解决方法加上extern "C"

2, 静态链接pthreadGC2

用测试程序测试的时候,提示未找到pthreadGC2.dll,于是在MinGW的目录下搜索pthread,发现有个 pthreads-win32-README的文档,里面详细讲述了如何静态链接pthread,概括步骤如下:

编译时定义PTW32_STATIC_LIB宏

链接pthreadGC2-static和ws2_32库(不需要链接pthread)

在调用pthread任何函数之前调用pthread_win32_process_attach_np()初始化(DLL在DLL_PROCESS_ATTACH分支下),结束后调用pthread_win32_process_detach_np()(DLL在下DLL_PROCESS_DETACH)

 3,如果在exe里也用到了多线程,重复2的步骤