News:

The new Release 25.03 is out! You can download binaries for Windows and many major Linux distros here .

Main Menu

Linking separate object files to get .map files

Started by 21region, February 18, 2012, 05:28:09 PM

Previous topic - Next topic

21region

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.

oBFusCATed

What is this map file?
You can disable the linking of a file by "Right clicking on it-> Properties -> Build -> Link file"
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

21region

Quote from: 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"
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.

oBFusCATed

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.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

MortenMacFly

Quote from: oBFusCATed on February 19, 2012, 11:55:22 AM
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...
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

21region

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.

MortenMacFly

Quote from: 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
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.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

votuananhs

you click right project -> Build Options... -> Linker Setting -> in Other Linker Options: -Wl,-Map,test_gtk.map