Author Topic: Linking separate object files to get .map files  (Read 6375 times)

Offline 21region

  • Single posting newcomer
  • *
  • Posts: 3
Linking separate object files to get .map files
« 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.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13165
    • Travis build status
Re: Linking separate object files to get .map files
« Reply #1 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"
(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!]

Offline 21region

  • Single posting newcomer
  • *
  • Posts: 3
Re: Linking separate object files to get .map files
« Reply #2 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.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13165
    • Travis build status
Re: Linking separate object files to get .map files
« Reply #3 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.
(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!]

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9613
Re: Linking separate object files to get .map files
« Reply #4 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...
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline 21region

  • Single posting newcomer
  • *
  • Posts: 3
Re: Linking separate object files to get .map files
« Reply #5 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.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9613
Re: Linking separate object files to get .map files
« Reply #6 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.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

votuananhs

  • Guest
Re: Linking separate object files to get .map files
« Reply #7 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