Jump to content
Sign in to follow this  
BeanBrain

Bug? Linking Or Bad Installation?

Recommended Posts

I'm not sure if this is a bug or if I have done a bad installation (ie into wrong directory)

 

Although I can compile successully, I can not link this small piece of code (though I can link other projects, but I probably don't reference any libraries.

 

This code snippet references the string function strcmp.

 

#include <system.h>

char * pStrs[4]={"abc","def","ghi","jkl"};

void main()
{
 signed char i;
 signed char Element=-1;
 for(i=0;i<4;i++)
   if(!strcmp(pStrs[i],"ghi"))
    Element=i;
}

The following MPLAB output is produced, please note the unresolved externals in the link process.

Clean: Deleting intermediary and output files.
Clean: Done.
Executing: "I:\Program Files\SourceBoost\boostc.pic18.exe" stsizeerror.c -O0  -W2  -v  -t 18F4680
BoostC Optimizing C Compiler Version 6.32 (for PIC18 architecture)
[url=http://www.picant.com/c2c/c.html]http://www.picant.com/c2c/c.html[/url]
Copyright© 2004-2006 Pavel Baranov
Copyright© 2004-2006 David Hobday

Licensed to me under Single user Full License for 1 node(s)
Limitations: PIC18 max code size:Unlimited, max RAM banks:Unlimited, Non commercial use only

stsizeerror.c
Starting preprocessor: "I:\Program Files\SourceBoost\pp.exe" "I:\Documents and Settings\Darkroom\My Documents\Projects\Microchip\stsizeerror.c" -i "I:\Program Files\SourceBoost\include" -d _PIC18F4680 -la -c2 -o stsizeerror.pp -v -d _BOOSTC -d _PIC18 

stsizeerror.c success

success
Executing: "I:\Program Files\SourceBoost\boostlink.pic.exe"  "I:\Documents and Settings\Darkroom\My Documents\Projects\Microchip\stsizeerror.obj" -O0  -v  -p "struct size error" -t 18F4680
BoostLink Optimizing Linker Version 6.32
[url=http://www.picant.com/c2c/c.html]http://www.picant.com/c2c/c.html[/url]
Copyright© 2004-2006 Pavel Baranov
Copyright© 2004-2006 David Hobday

Optimisation level:0 - Off
Available Function List:
main(void)
delay_us(unsigned char)
delay_10us(unsigned char)
delay_100us(unsigned char)
delay_ms(unsigned char)
delay_s(unsigned char)
__rom_get(unsigned char,unsigned char)
_startup(void)

Error: Unresolved external function:'strcmp(unsigned char*,unsigned char*)'
Error: Unresolved external symbol, function:strcmp

Failure
BUILD SUCCEEDED: Fri Mar 10 11:54:18 2006

I attempted to force the linker to look at the Lib directory of SourceBoost (on my system this is I:\Program Files\SourceBoost\Lib ) by modifying the library search directory in MPLAB (it was blank). I notice there are two libc files, libc.pic16.lib and libc.pic18.lib , presumeably the file selected is determined by the PIC famaly type? Or is this a bug in the linker?

 

The MPLAB output after modifying the library search path:

Clean: Deleting intermediary and output files.
Clean: Done.
Executing: "I:\Program Files\SourceBoost\boostc.pic18.exe" stsizeerror.c -O0  -W2  -v  -t 18F4680
BoostC Optimizing C Compiler Version 6.32 (for PIC18 architecture)
[url=http://www.picant.com/c2c/c.html]http://www.picant.com/c2c/c.html[/url]
Copyright© 2004-2006 Pavel Baranov
Copyright© 2004-2006 David Hobday

Licensed to me under Single user Full License for 1 node(s)
Limitations: PIC18 max code size:Unlimited, max RAM banks:Unlimited, Non commercial use only

stsizeerror.c
Starting preprocessor: "I:\Program Files\SourceBoost\pp.exe" "I:\Documents and Settings\Darkroom\My Documents\Projects\Microchip\stsizeerror.c" -i "I:\Program Files\SourceBoost\include" -d _PIC18F4680 -la -c2 -o stsizeerror.pp -v -d _BOOSTC -d _PIC18 

stsizeerror.c success

success
Executing: "I:\Program Files\SourceBoost\boostlink.pic.exe"  "I:\Documents and Settings\Darkroom\My Documents\Projects\Microchip\stsizeerror.obj" -O0  -v  -p "struct size error" -t 18F4680 -ld I:\Program Files\SourceBoost\Lib
BoostLink Optimizing Linker Version 6.32
[url=http://www.picant.com/c2c/c.html]http://www.picant.com/c2c/c.html[/url]
Copyright© 2004-2006 Pavel Baranov
Copyright© 2004-2006 David Hobday

Optimisation level:0 - Off
Error: Failed to open:Lib.

Failure
BUILD SUCCEEDED: Fri Mar 10 11:45:17 2006

 

Is the fact that I'm using drive I: the problem?

Comments please.

Share this post


Link to post
Share on other sites

BeanBrain,

 

When you use BoostC in MPLABs you have to manually add the required libs or they won't get linked in.

 

How todo this is in the BoostC compiler help file under "Creating a project under MPLAB IDE" :).

 

Regards

Dave

Share this post


Link to post
Share on other sites

Dave,

When you use BoostC in MPLABs you have to manually add the required libs or they won't get linked in.

You are quite correct! (I need an embarrassed looking smiley here!) :)

I apologise for wasting your time and not RTFM and remembering it all. I obviously could not see the trees for the forest.

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...
Sign in to follow this  

×
×
  • Create New...