Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: 21region on February 18, 2012, 05:28:09 pm

Title: Linking separate object files to get .map files
Post by: 21region on February 18, 2012, 05:28:09 pm
I've compiled different .cpp files in one project and got .o files. In the linking stage they are tried to be combined in a singe executable. But, as they're  not supposed to be built in one project (every .cpp file deserves it's own project), I get a lot of linking errors. And that's ok.

What I want is to build every .cpp file separately and get it's .map file. Is there any check button for doing this?
Thanks in advance.
Title: Re: Linking separate object files to get .map files
Post by: oBFusCATed on February 18, 2012, 05:56:45 pm
What is this map file?
You can disable the linking of a file by "Right clicking on it-> Properties -> Build -> Link file"
Title: Re: Linking separate object files to get .map files
Post by: 21region on February 19, 2012, 08:44:14 am
What is this map file?
You can disable the linking of a file by "Right clicking on it-> Properties -> Build -> Link file"
http://en.wikipedia.org/wiki/MAP_(file_format)

I don't need disabling linker. I need linker to go through all of .o files and generate .map for every one of them.
Title: Re: Linking separate object files to get .map files
Post by: oBFusCATed on February 19, 2012, 11:55:22 am
If you're using the gcc compiler you won't be able to do it, I think, because gcc is producing debug information in dwarf format not coff or map (or whatever vc++ is producing).
You'll have to read the manual to see what options are available to you about reading the symbols.
Title: Re: Linking separate object files to get .map files
Post by: MortenMacFly on February 19, 2012, 12:19:06 pm
You'll have to read the manual to see what options are available to you about reading the symbols.
...not to forget about the "SymTab" plugin (symbol table plugin) which utilises the GCC nm tool for symbols...
Title: Re: Linking separate object files to get .map files
Post by: 21region on February 19, 2012, 12:21:39 pm
Now I'm generating map files with this command: ld -m "fileName.o" > "fileName.map"
To solve this issue I've written .bat file: for %%x in (c:\projects\obj\*.o) do call ld -M %%x > %%x.map

I think it's brute force and there have to be cleverer methods, for example, with using makefile. But I never used them and it's hard for me to write one for this problem.
Title: Re: Linking separate object files to get .map files
Post by: MortenMacFly on February 19, 2012, 12:30:05 pm
Now I'm generating map files with this command: ld -m "fileName.o" > "fileName.map"
To solve this issue I've written .bat file: for %%x in (c:\projects\obj\*.o) do call ld -M %%x > %%x.map
If you really need this, you can also adjust the compiler command issued to compile a compilation unit. You find this within the advanced settings of the compiler you are using. Using macros the step above is done automatically for you.
Title: Re: Linking separate object files to get .map files
Post by: votuananhs on February 26, 2014, 06:51:35 pm
you click right project -> Build Options... -> Linker Setting -> in Other Linker Options: -Wl,-Map,test_gtk.map