News:

Download Pelles C here: http://www.pellesc.se

Main Menu

Combining object files

Started by Vortex, May 11, 2026, 09:45:46 PM

Previous topic - Next topic

Vortex

Ld, the GNU linker has an interesting feature, it can combine object modules files to create one monolithic object file. The example below combines StdOut.obj ( function to write to the console window ) and the dependency StrLen.obj ( string lenght calculator ) to output one file named Modules.obj

\PellesC\bin\poasm /AIA32 StrLen.asm

\PellesC\bin\poasm /AIA32 StdOut.asm

\PellesC\bin\poasm /AIA32 Sample.asm

C:\msys64\mingw32\i686-w64-mingw32\bin\ld -r -m i386pe -o Modules.obj StdOut.obj StrLen.obj

C:\Masm64\bin64\link /SUBSYSTEM:CONSOLE /LIBPATH:\PellesC\Lib\Win Sample.obj Modules.obj kernel32.lib user32.lib

Code it... That's all...

TimoVJL

Sadly have to say, that is a bad idea, as no COMDATs  :(
May the source be with you

Vortex

Hi Timo,

I guess you are referring to the duplicate symbols issue. Polink cannot link those combined object files. This is why I used MS Link. I think my example should be fine as it's a very simple one.
Code it... That's all...