• AVR Freaks

Library creation with XC8 compiler

Author
carlo_87
New Member
  • Total Posts : 6
  • Reward points : 0
  • Joined: 2017/05/22 14:29:29
  • Location: 0
  • Status: offline
2018/10/26 07:38:36 (permalink)
0

Library creation with XC8 compiler

Hello,
 
I am stuck on a topic and I hope that someone can help me :)
 
Summarizing, I have a project for a PIC16F18876 microcontroller and I want to update it replacing some sources with a library.
 
What I have done:
- creation of a new library project with the sources that I want to add in the library (basically the whole driver layer);
- updating of the project, removing all the sources already integrated in the library and adding of the .lpp library file in the project. 
 
At this point I have built the new project with the library, the building process is successfully terminated, but the hex file is different from the original project (without the library).
 
I've checked the outputs of the build process (.p1, ecc) and they are the same. 
 
Where is the problem? The Linker?
What I have to do to get the same .hex?
 
Thanks in advance.
 
Carlo
 
 
#1

7 Replies Related Threads

    jack@kksound
    code tags!
    • Total Posts : 3213
    • Reward points : 0
    • Joined: 2014/05/14 10:03:19
    • Location: 0
    • Status: offline
    Re: Library creation with XC8 compiler 2018/10/26 09:02:20 (permalink)
    +1 (1)
    What I have to do to get the same .hex?

    You have changed the code and rearranged things, the compiler may not always place each piece of code in exactly the same memory locations. Did you also change compiler versions?
    #2
    crosland
    Super Member
    • Total Posts : 1674
    • Reward points : 0
    • Joined: 2005/05/10 10:55:05
    • Location: Warks, UK
    • Status: offline
    Re: Library creation with XC8 compiler 2018/10/26 11:55:43 (permalink)
    +3 (3)
    carlo_87At this point I have built the new project with the library, the building process is successfully terminated, but the hex file is different from the original project (without the library).

     
    Why are you surprised by that? You have changed the structure of the code.
     
    I've checked the outputs of the build process (.p1, ecc) and they are the same. 
     
    Where is the problem?

     
    There is no problem so far.
     
    The Linker?
    What I have to do to get the same .hex?

     
    Almost impossible.
     
    Have you thought to actually try running the new .hex in hardware?
     
    #3
    carlo_87
    New Member
    • Total Posts : 6
    • Reward points : 0
    • Joined: 2017/05/22 14:29:29
    • Location: 0
    • Status: offline
    Re: Library creation with XC8 compiler 2018/10/28 07:30:34 (permalink)
    0
    Thanks for the answers...
     
    Anyway same compiler version, no changes of the code  and I've not tested yet on the hardware. 
    Basically the "same .hex" was a request from the customer, my job was only to create the new project with the library and obtain the same .hex, nothing more.
    Probably I won't get the same hex, but I have to provide an analysis that explain the reason...
     
    I'll keep you posted and thanks again.
     
    Bye
     
    Carlo
     
    #4
    mpgmike
    Super Member
    • Total Posts : 326
    • Reward points : 0
    • Joined: 2014/01/23 17:27:06
    • Location: NJ
    • Status: online
    Re: Library creation with XC8 compiler 2018/10/29 01:08:21 (permalink)
    +1 (1)
    If that was a mandatory outcome, I would never said yes to that job.  Get the same functionality?  That is a "can do". Match the hex???????????
    #5
    qhb
    Superb Member
    • Total Posts : 9999
    • Reward points : 0
    • Joined: 2016/06/05 14:55:32
    • Location: One step ahead...
    • Status: offline
    Re: Library creation with XC8 compiler 2018/10/29 02:33:07 (permalink)
    +1 (1)
    Anyone who insists that a compiler always produce the same hex just doesn't understand how compilers work.
     

    Nearly there...
    #6
    crosland
    Super Member
    • Total Posts : 1674
    • Reward points : 0
    • Joined: 2005/05/10 10:55:05
    • Location: Warks, UK
    • Status: offline
    Re: Library creation with XC8 compiler 2018/10/29 03:01:51 (permalink)
    +1 (1)
    carlo_87
    Anyway same compiler version, no changes of the code 



     
    You HAVE changed the code.
     
    All the right op-codes, but in the wrong order. With apologies to the late Eric Morecambe,
    #7
    carlo_87
    New Member
    • Total Posts : 6
    • Reward points : 0
    • Joined: 2017/05/22 14:29:29
    • Location: 0
    • Status: offline
    Re: Library creation with XC8 compiler 2018/10/29 07:32:02 (permalink)
    0
    "If that was a mandatory outcome, I would never said yes to that job."
     
    Unfortunately I am not the one that talk with the customer...anyway I've talked with by boss and explained to him the situation. The customer will accept these deviations...
     
    Just to inform you, I have done further tests and actually if the project is not too complex, two different projects, one with all the sources and the other one with sources and a library, will produce the same .hex file (you have to be sure that inside the makefiles the order of the objects files and the "linker command" have the same order).
     
    Thanks to all for the support.
     
    Carlo
    #8
    Jump to:
    © 2019 APG vNext Commercial Version 4.5