C++博客 :: 首页 :: 联系 ::  :: 管理
  163 Posts :: 4 Stories :: 350 Comments :: 0 Trackbacks

常用链接

留言簿(48)

我参与的团队

搜索

  •  

积分与排名

  • 积分 - 393089
  • 排名 - 58

最新评论

阅读排行榜

评论排行榜

该宏放置一个注释到对象文件或者可执行文件。
#pragma comment( comment-type [,"commentstring"] )

comment-type是一个预定义的标识符,指定注释的类型,应该是compiler,exestr,lib,linker之一。
commentstring是一个提供为comment-type提供附加信息的字符串,
Remarks:
1、compiler:放置编译器的版本或者名字到一个对象文件,该选项是被linker忽略的。
2、exestr:在以后的版本将被取消。
3、lib:放置一个库搜索记录到对象文件中,这个类型应该是和commentstring(指定你要Liner搜索的lib的名称和路径)
这个库的名字放在Object文件的默认库搜索记录的后面,linker搜索这个这个库就像你在命令行输入这个命令一样。你可以
在一个源文件中设置多个库记录,它们在object文件中的顺序和在源文件中的顺序一样。如果默认库和附加库的次序是需要
区别的,使用Z编译开关是防止默认库放到object模块。
4、linker:指定一个连接选项,这样就不用在命令行输入或者在开发环境中设置了。
只有下面的linker选项能被传给Linker.
  • /DEFAULTLIB

  • /EXPORT

  • /INCLUDE

  • /MANIFESTDEPENDENCY

  • /MERGE

  • /SECTION

(1)/DEFAULTLIB:library

/DEFAULTLIB 选项将一个 library 添加到 LINK 在解析引用时搜索的库列表。用 /DEFAULTLIB 指定的库在命令行上指定的库之后和 .obj 文件中指定的默认库之前被搜索。

忽略所有默认库 (/NODEFAULTLIB) 选项重写 /DEFAULTLIB:library。如果在两者中指定了相同的 library 名称,忽略库 (/NODEFAULTLIB:library) 选项将重写 /DEFAULTLIB:library

(2)/EXPORT:entryname[,@ordinal[,NONAME]][,DATA]

使用该选项,可以从程序导出函数,以便其他程序可以调用该函数。也可以导出数据。通常在 DLL 中定义导出。entryname 是调用程序要使用的函数或数据项的名称。ordinal 在导出表中指定范围在 1 至 65,535 的索引;如果没有指定 ordinal,则 LINK 将分配一个。NONAME 关键字只将函数导出为序号,没有 entryname

DATA 关键字指定导出项为数据项。客户程序中的数据项必须用 extern __declspec(dllimport) 来声明。
有三种导出定义的方法,按照建议的使用顺序依次为:

  1. 源代码中的 __declspec(dllexport)

  2. .def 文件中的 EXPORTS 语句

  3. LINK 命令中的 /EXPORT 规范

所有这三种方法可以用在同一个程序中。LINK 在生成包含导出的程序时还创建导入库,除非生成中使用了 .exp 文件。
LINK 使用标识符的修饰形式。编译器在创建 .obj 文件时修饰标识符。如果 entryname 以其未修饰的形式指定给链接器(与其在源代码中一样),则 LINK 将试图匹配该名称。如果无法找到唯一的匹配名称,则 LINK 发出错误信息。当需要将标识符指定给链接器时,请使用 Dumpbin 工具获取该标识符的修饰名形式。

(3)/INCLUDE:symbol

/INCLUDE 选项通知链接器将指定的符号添加到符号表。

若要指定多个符号,请在符号名称之间键入逗号 (,)、分号 (;) 或空格。在命令行上,对每个符号指定一次 /INCLUDE:symbol
链接器通过将包含符号定义的对象添加到程序来解析 symbol。该功能对于添包含不会链接到程序的库对象非常有用。用该选项指定符号将通过 /OPT:REF 重写该符号的移除。



我们经常用到的是#pragma   comment(lib,"*.lib")这类的。
#pragma   comment(lib,"Ws2_32.lib")表示链接Ws2_32.lib这个库。  
和在工程设置里写上链入Ws2_32.lib的效果一样,不过这种方法写的  
程序别人在使用你的代码的时候就不用再设置工程settings了


posted on 2008-01-10 11:23 sdfasdf 阅读(62499) 评论(36)  编辑 收藏 引用 所属分类: C++

Feedback

# re: pragma comment的使用 2009-02-12 09:20 sven
受益,謝謝,  回复  更多评论
  

# re: pragma comment的使用 2009-03-05 14:17 ym.luo
不错,继续发扬光大!  回复  更多评论
  

# re: pragma comment的使用 2009-06-01 16:14 EVE
Package thre Yangchun in March, the dofus power leveling in this lineage 2 power leveling season, Shenzhen Shijiazhuang domain Jia Ming offices and international co-joined to organize activities for the players carefully ----" Plextor optical storage invite you together "QQ Huaxia" world ", to welcome all of you players come to participate.

  回复  更多评论
  

# re: pragma comment的使用 2009-09-30 09:58 brada
很不错,赐教了  回复  更多评论
  

# re: pragma comment的使用 2010-07-21 09:05 Uniker
学习  回复  更多评论
  

# re: pragma comment的使用 2010-07-21 11:20 essay papers
Your topic is supreme, but that could take a lot of time to create such of essay papers for not professional persons. Therefore the essay writing services will suggest to buy essay paper in such case.   回复  更多评论
  

# Custom Essay 2010-09-27 14:58 SarahAngelinaJolie
Very impressive, thank you for posting!
I appreciate the information you provided is excellent post. Thank you for sharing you do.  回复  更多评论
  

# Custom Essay 2010-09-27 15:00 Essay writing
I found your blogs after read topic's related post now I feel my research is almost completed. Thanks to share this nice information.  回复  更多评论
  

# custom essays 2010-10-22 13:38 termpaper99@gmail.com
good job keep it up i like it to much so it is fantastic job you did this is such kinds of good work which always be good forever  回复  更多评论
  

# re: pragma comment的使用 2010-10-25 20:05 research papers
Such a nice article,Very impressive,I appreciate the information you provided is excellent post. Thank you for sharing you do.  回复  更多评论
  

# dress[未登录] 2010-11-29 10:29 dress
I can't believe how much of this I just wasn't aware of. Thank you for bringing moreinformation to this topic for me. I'm truly grateful and really impressed.   回复  更多评论
  

# re: pragma comment的使用 2010-12-16 10:51 dog treats
What a great article, you're really talented, hope to see more exciting  回复  更多评论
  

# re: pragma comment的使用 2011-01-09 20:25 天之骄子'
学习了,受益匪浅。  回复  更多评论
  

# re: pragma comment的使用 2011-01-26 18:47 Access Healthcare
How can I translate this ?  回复  更多评论
  

# re: pragma comment的使用 2011-06-02 18:56 xzzzz1234
great.
<a href="http://www.realessaywriting.com/">essay</a> | <a href="http://www.realdissertationwriting.com/">dissertation</a> | <a href="http://www.realthesiswriting.com/">thesis</a> | <a href="http://www.realassignmentwriting.com/">assignment</a> | <a href="http://www.realcourseworkwriting.com/">coursework</a>  回复  更多评论
  

# re: pragma comment的使用 2011-07-22 22:00 essay
Didn't determine whether to buy history essay paper or to create it by yourself? I could recommend to receive free essays from the custom papers writing company, when you were pressured by time.   回复  更多评论
  

# re: pragma comment的使用 2011-07-25 17:14 jis117
弱弱的问一句,lib是不是指操作系统提供的库,谢谢  回复  更多评论
  

# re: pragma comment的使用 2011-09-02 18:31 chanel watches

Sorry, but she won't be able to enjoy them anymore, while FSF can. XD  回复  更多评论
  

# re: pragma comment的使用 2011-09-02 18:33 replica hermes

-gden compass trilogy by phillip pullman  回复  更多评论
  

# re: pragma comment的使用 2011-11-09 15:32 mosjin
额。,谢谢。  回复  更多评论
  

# re: pragma comment的使用 2012-01-05 11:14 Haiying_TT
Good, thanks!  回复  更多评论
  

# re: pragma comment的使用[未登录] 2012-01-13 05:14 ZZ
非常好的网站

<a href="http://www.neojogos.com">Jogos online</a> | <a href="http://www.neojocuri.com">Jocuri online</a>

<a href="http://proxy-list.co.uk" target="_blank">Proxy List</a>  回复  更多评论
  

# re: pragma comment的使用 2012-01-18 19:44 essay
Students’ life seems to be very strange thing and very often you have to opt for one thing at one time, then you do not have time to work on some else action. For example, different students should select between job and ancient essay paper writing. In that situation, we suggest to find the trusworthy cheap essay writing service to order the free essays in.   回复  更多评论
  

# re: pragma comment的使用 2012-02-06 15:29 business loans
The loans are very useful for guys, which are willing to start their company. As a fact, this is comfortable to get a small business loan.   回复  更多评论
  

# re: pragma comment的使用 2012-05-25 23:19 xephi
xiexie,hen you yong   回复  更多评论
  

# re: pragma comment的使用 2012-07-02 14:46 Buy an essays uk
Don't understand how to start your academic assignment? Bother no more, just because you have got an opportunity to buy writing services "bestcustompapers.com" and focus on your affairs.   回复  更多评论
  

# re: pragma comment的使用 2012-07-02 14:52 Online essay scholarships
Whenever you are sick and tired of completing writing assignments, a perfect suggestion for you will be to buy article writing bestcustompapers.com.  回复  更多评论
  

# re: pragma comment的使用 2012-09-14 22:33 听雨轩
谢谢, 学习了受益很大  回复  更多评论
  

# re: pragma comment的使用 2012-09-21 16:04 buy essays uk
Open bestwritingservice.co.uk to order high quality uk essays online.  回复  更多评论
  

# re: pragma comment的使用 2012-09-21 16:07 custom writing uk
Select this home page if you have a need to purchase original essays uk. An A+ is secured!  回复  更多评论
  

# re: pragma comment的使用[未登录] 2012-09-22 09:22 lin
为什么*.lib不行啊?  回复  更多评论
  

# re: pragma comment的使用[未登录] 2013-01-04 15:24 小明
据我所知,至少#pragma comment(linker, "/ENTRY:main")这种的是可以的。  回复  更多评论
  

# re: pragma comment的使用 2013-04-14 00:10 professional CV writing services
Are you seeking how to write a resume or where to obtain resume formats and professional CV writing services? Or you just want to buy CV from certified resume writers? Only contact Resume company (perfect-resume.com).  回复  更多评论
  

# re: pragma comment的使用 2013-04-14 00:12 professional CV writing services
If you don’t know how to land the job of your dream, opt for bureaus available on the Internet which propose to buy resume perfect-resume.com done by leading experts.  回复  更多评论
  

# re: pragma comment的使用 2013-04-14 00:30 essay writing reviews
On the home page of this online resource you will be able to read extensive writing services reviews best-essay-sites.com. Therefore, you will discover respectable custom paper writing service to buy essays at.   回复  更多评论
  

# re: pragma comment的使用 2013-04-14 00:35 WritingsCentre rewiew
When learners contact Best Essay Sites firm, they will find informative essay writing reviews of superior quality.  回复  更多评论
  

# re: pragma comment的使用 2013-04-18 08:31 Click here
Collaborate with certified resume writers and astonish your the HR manager with the masterly done curriculum vitae.  回复  更多评论
  

# re: pragma comment的使用 2014-04-07 07:58 site
Are you seeking how to write a resume or where to obtain resume templates and professional CV writing services? Or you merely would like to buy resumes from certified resume writers? Merely contact Resume company.  回复  更多评论
  

# re: pragma comment的使用 2014-04-07 07:59 professional resume service
Go to Exclusive-resume company if you are in need of professional resume writing. Having worked with this dependable writing agency, you will be aware of which service to choose for buying resume and where to run over resume writing samples. Don’t hesitate, order resume of good quality from certified resume writers.  回复  更多评论
  


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理