Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: carra on July 12, 2012, 04:59:28 pm

Title: Error when linking .res files
Post by: carra on July 12, 2012, 04:59:28 pm
I was trying to use a compiled resource file (.res). Adding it to the project everything worked as expected: the file was selected for linking but nor for compiling. But it seems that, when C::B generates the command line to link it, it is somehow outputting a wrong path. I get the following:

File name (absolute) C:\Programacion\KTools\Objects\Resources\ChoiceBoxDialog.res
File name (relative) ..\..\Objects\Resources\ChoiceBoxDialog.res

Linking error:

\Programacion\KTools\Objects\Objects\Resources\ChoiceBoxDialog.res
No such file or directory

As you see, it has for some reason duplicated the Objects folder. I have verified that it is also being sent to the command line with that path. I don't really get why, since the path is correct in the project data. Any idea why??

PD: This happens in C::B nightly 8059
Title: Re: Error when linking .res files
Post by: carra on July 13, 2012, 09:38:34 am
I have attached here a minimal project (only an empty winmain) that reproduces this. Tested in 8059, I get the following:

Paths in project settings:
Objects output dir: ..\Objects
Resource relative path: ..\Resources\InputBoxDialog.res

Paths in command line:
Path in build error message:   ..\Objects\Resources\InputBoxDialog
Complete linker command line:   g++.exe -L. -LC:/Programacion/KTools\Libraries  -o ..\Binaries\InputBoxTest.exe ..\Objects\Project\InputBoxMain.o ..\Objects\Resources\InputBoxDialog.res   -s -static-libgcc -static-libstdc++

It's worth noting that there is no linking problem when the project uses instead the .RC resource script and compiles it itself. But when using the .RES file to link directly, it seems to "assume" somehow that it comes from a previous compiling step. I'd say it's trying to adapt the path to the structure of subfolders used by GCC when placing object files (as jens describes here http://forums.codeblocks.org/index.php/topic,16467.msg111740.html#msg111740 (http://forums.codeblocks.org/index.php/topic,16467.msg111740.html#msg111740) ).
Title: Re: Error when linking .res files
Post by: MortenMacFly on July 13, 2012, 09:39:42 am
Any idea why??
Not without a minimal sample to reproduce.
Title: Re: Error when linking .res files
Post by: carra on July 13, 2012, 09:50:03 am
You mean like the one I attached 1 minute before your post? Hehehe ;D
Title: Re: Error when linking .res files
Post by: MortenMacFly on July 13, 2012, 11:08:28 am
You mean like the one I attached 1 minute before your post? Hehehe ;D
Yes, out posts crossed.

I inspected what you had provided, but I don't understand: You have included a binary (already compiled) resource file. Usually you are supposed to add the source (*.rc) file and have C::B to compile it.

Do you really want to just link against this binary resource file? Why don't you add it as a linker option then?
Title: Re: Error when linking .res files
Post by: carra on July 13, 2012, 12:09:48 pm
I didn't want to reinclude the RC script in this project because this was about reusing an already compiled .lib file. And since it needs its associated resource to work, I have to link the RES file.

Well I could have added the binary as a linker option, and maybe I was supposed to. The thing is: I have never done this in C::B before, and since C::B would let me add it to the project (and it even managed compile exclusion correctly), I thought this was a normal way to do it. But I can change it without problem if it is not.

However, I isn't it still an error to add the "post-compile" subfolders to something that has not been compiled in the project? Also, the project can know this, since the file is not a known source file type and it is unchecked for compile.