Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 929
Yippie-Ki-Yay Avatar asked Jun 09 '10 13:06

Yippie-Ki-Yay


People also ask

Do static libraries have dependencies?

So what is a Static library?? When linked like this the library is called a static library, because the library will remain unchanged unless the program is recompiled. This is the most straight forward way of using a library as the final result is a simple executable with no dependencies.

What creates static libraries?

Static libraries are created using some type of archiving software, such as ar. ar takes one or more object files (that end in .o), zips them up, and generates an archive file (ends in . a) — This is our “static library”. Now that we have the object file(s), we can archive them and make a static library using ar.

What happens when you link a static library?

Static linking increases the file size of your program, and it may increase the code size in memory if other applications, or other copies of your application, are running on the system. This option forces the linker to place the library procedures your program references into the program's object file.

Why do we need static library?

Static libraries increase the size of the code in your binary. They're always loaded and whatever version of the code you compiled with is the version of the code that will run.


1 Answers

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.

like image 91
Yippie-Ki-Yay Avatar answered Sep 20 '22 01:09

Yippie-Ki-Yay