开发者

Resources in static library question

This isn't a duplicate of VC++ resources in a static library because it didn't help :)

I have a static library with TWO .rc files in it's project. When I build my project using the Debug configuration, I retrieve the following error (MSVS2008):

fatal error LNK1241: resource file res_yyy.res already specified

Note, that this happens only in Debug and Release library builds without any troubles. The command line for Resources page in project configuration looks the same for every build:

/fo"...(Path here)/Debug/project_name.res"
/fo"...(Path here)/Release/project_name.res"

and I can't understand what's the trouble. Any ideas?

UPDATE

I 开发者_运维问答don't know why this happens, but when I turn "Use Link-Time Code Generation" option on the problem goes away.

Could somebody explain why does this happen? I feel like MS-compiler is doing something really strange here.

Thanks.


Solved this problem by setting EXACTLY ONE .res output file in the settings. I'm not actually sure why it was ok in Release mode though.


I came across this post because I had the same linker error.

The approach specified in the answer produced a linker warning on my system (xyz.res : warning LNK4042: object specified more than once; extras ignored).

What worked for me was to remove the entries of "Resource File Name" and "Culture" in the Properties/Resources configuration.


I wound up invoking this error during an exploration to get a bunch of dependent projects to all build as dlls from a large set that were all initially set to build as static libraries. I inadvertently changed one of the project settings in the Project References to get the dlls building. Rechecking that my changes worked for the full static library configuration revealed the link error. So for one specific dependent project that had a resource file to include Version information I had the Project Reference Properties: Link Library Dependencies flag set to True. Changing it to False fixed the error.

Incidentally I only needed the resource file for the Dll version, since I actually needed Link Library Dependencies set to True to fix linker errors in the Dll build. So what I wound up doing is excluding the resource file from the static library build by setting Yes to Excluded From Build.


For me I fixed the issue by going to my solution explorer and excluding all files and then re-'include in project'-ed the .h and .cpp files that I was using

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜