Jump to content
joli

division error boostc/boostc++ under mplab x

Recommended Posts

#include <system.h>
typedef unsigned char uchar;
void main()
{
    uchar j=20;
    uchar i = (j/10);
}

Compiling the little snipet above under mplabx, it return errors like this:

Error: Unresolved external function:'__div_8_8(unsigned char,unsigned char)'

depending of the evaluated expression the error could be:

Error: Unresolved external function:'__div_16_16(unsigned char,unsigned char)'

Surprinsingly, the same not happens to 16/32 bit multiplications.

The solution is to include libc.pic16.lib or libc.pic18.lib, depending the pic family we are using.

This could be done, under mplabx/File/Project Properties. Now in the Project Properties Window, select Libraries and Add Library/Object File, choose <libc.pic1x.lib> and thats it.

Alternately, it can be done following the procedure above but picking Linker instead Libraries and add <libc.pic1x.lib> in the Additional Options.

P.S. the same procedure works with floats.

 

Edited by joli
to correct the P.S. statement

Share this post


Link to post
Share on other sites

Hi

 

The same solution works for all libs.

Also its valid to the old MPLab 8.xx as for MPLab X.

 

If memory is not tricking me, this is documented in the manuals.

 

Best regards

Jorge

 

Share this post


Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...