Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo


#4 Generated linker flags mixes Wl, verbatim options

Jason Heeris

This is using Eclipse 3.5, and MPLAB C32 1.10B (lite) under Windows, with a custom linker script to place code in the boot flash memory. I noticed some differences between the linking results under MPLAB and Eclipse, and investigated the command lines used by each program.

Under Eclipse, the linking stage is called with

-Wl,--script="..\linkers\script.ld" -L"C:\Program Files\Microchip\MPLAB C32\lib" -L"C:\Program Files\Microchip\MPLAB C32\pic32mx\lib"

Under MPLAB, the linking stage is:

-Wl,--script="..\linkers\script.ld",-L"C:\Program Files\Microchip\MPLAB C32\lib",-L"C:\Program Files\Microchip\MPLAB C32\pic32mx\lib"

Note the commas in the second version. This seems to make a difference when using the "-mips16" option with the linker. I'm not sure why, to be honest. (In the lite version of C32, the "-mips16" option is ignored when compiling code, but I think it has some effect on linking...)

The major outcome of all of this was that under Eclipse, my code does not compile, since it doesn't fit in the boot flash. Under MPLAB, it does.

If I have time, I'll try to come up with an example.


  • Jason Heeris
    Jason Heeris


    I'm sorry. The problem was that I never needed to manually add those library paths in the first place. It all seems to work fine without them.

    Incidentally, I think you need to pass the "-mips16" option through to the linker, or at least add a checkbox for it to be set. It does seem to affect the output.

  • Jason Heeris
    Jason Heeris

    • status: open --> open-invalid
    • assigned_to: nobody --> ecdpalma
    • status: open-invalid --> open-remind
  • I'm verifying this. The manual doesn't include "-mips16" as an option to the linker. And the commas are really strange, as I couldn't find them in gcc usage.

    • status: open-remind --> open-fixed
  • I placed the option as requested (release 0.4.2). I hope it helps.

  • Jason Heeris
    Jason Heeris

    My educated guess is that the linking stage can select different libraries based on optimisation settings and the mips16/32 option even when the compiler ignores the optimisation flags. So no actual extra work is done by the compiler, per se, because the linker only selects from the different PREcompiled libraries shipped with Microchips runtime stuff.