Jump to content
Sign in to follow this  
crash_n_burn

Building Libraries

Recommended Posts

Hello all, During the last weeks, or should i say months, I've been working on writing code for an application. This thing is bigger and bigger everyday. It's takes a hell of a time to compile and link this monster.

 

Most of my functions don't change and I should not need to compile them all the time. I know it is possible to compile some functions to build "libraries" and then link to my code. This way i would surely save a lot of time. But i have never done that. I don't know how to do it.

 

I know there is an option you can check in BoostC to build libraries. I tried to compile some of the functions as libraries and it worked. BoostC generated a .LIB file but i don't know what to do with it next.

 

I'm not asking for a complete explanation on this forum. I know it's a lot to ask for. But does anybody know a web page of a book that would have some sort of tutorial on the subject ? Or maybe some simple code examples to show how it's done ?

 

Thanks.

Share this post


Link to post
Share on other sites

crash_n_burn,

 

Creating a library will save compilation time, but the project will still take the same time to link.

 

How to build a library:

1) Create a new project.

2) Select Library output: Settings->Options select the Output type radio buttons to Library.

3) Select the target type: Settings ->Target select a specific target, or PIC18 or PIC16 for generic library (can't use any target specifc features).

4) Add the required source files to the project - make sure you don't have a main.

5) Build the library.

 

How to add a library to the project to be built:

1) Remove the source files now in the library from the project (header files will still be needed for function prototypes).

2) Add library to project: Project->Add File(s) locate the library and click OK.

3) Build the project.

 

 

Hope this helps

 

Regards

Dave

Share this post


Link to post
Share on other sites

I thought i would save time in the linking process. I'm a little disappointed.

 

The compile time is not soo bad. The linking is very long. I guess i'll start shopping for a replacement for my 1.6Ghz CPU. :)

 

Still, i'm going to follow your instructions to link the libraries to the project.

 

 

Thank you for the support.

 

 

Yves Belzile AKA Crash n burn :blink:

Share this post


Link to post
Share on other sites

crash_n_burn,

 

If you have a sample project that takes a long time to link, please send it to support@picant.com. We well take a look and maybe able to improve linkers performance in future releases.

 

Regards

Dave

Share this post


Link to post
Share on other sites

I followed the above for having a library file into my project (BoostC, 16f870).. The lib was some LCD routines that worked OK when in main file...However, it compiler OK but linker reports 4 errors for duplicate Global vars, eedata, eeaddr, eecon1, eecon2.........

 

My main program doesn't use (at present time) ANY of these....

Share this post


Link to post
Share on other sites

nikosxan,

 

I followed the above for having a library file into my project (BoostC, 16f870).. The lib was some LCD routines that worked OK when in main file...However, it compiler OK but linker reports 4 errors for duplicate Global vars, eedata, eeaddr, eecon1, eecon2.........

Sounds like you are multiply including your library header file that contains declarations for some global variables.

 

Its best to take these out of the header and put them in one of the library source files. Declare them as extern (if necessary) in the header file to allow compilation.

 

Hope that helps.

 

Regards

Dave

Share this post


Link to post
Share on other sites

Sounds like you are multiply including your library header file that contains declarations for some global variables.

 

Its best to take these out of the header and put them in one of the library source files. Declare them as extern (if necessary) in the header file to allow compilation.

 

 

Hi Dave

 

This was actually your lcd4lib.... I got the main{} out of the file an put it in another file.... Lib has ONLY

 

#include <system.h>

#include "lcd4bit.h"

 

header file has :

void LCD_Setup(void);

void LCD_FunctionMode(void);

void LCD_DataMode(void);

void LCD_RawWriteNibble(char);

void LCD_Write(char);

void LCD_RawWrite(char);

char LCD_Read();

void lprintf( const char *lcdptr ); //write string

void LCD_Clear();

void LCD_WaitForNotBusy();

 

////////////////////////////////////////////////////////////////////////////

// Control signal bit definitions

////////////////////////////////////////////////////////////////////////////

#define LCD_E 3

#define LCD_RW 2

 

etc.....................

 

also, my main program has

 

#include <system.h>

 

#include "lcd4bit.h"

 

once again, i dont; use any of the eeadr, aadata, etc vars..........

 

Nick

Share this post


Link to post
Share on other sites

Nick,

 

I can't explain why this is happening.

Without seeing the two projects its difficult to know whats wrong.

 

If you zip them up and send them to support@picant.com I'll take a quick peep at the code.

 

Regards

Dave

Share this post


Link to post
Share on other sites
Nick,

 

I can't explain why this is happening.

Without seeing the two projects its difficult to know whats wrong.

 

If you zip them up and send them to support@picant.com I'll take a quick peep at the code.

 

Regards

Dave

 

Hi again....

 

I consider it to be a bug (i think in the linker...)...

 

I did the following : Changed the target from f870 (this is my H/W) to f628A...(using it for another project......).... Of course i took out a couple of statements related to portc which 628 doesn;t have... SUCCESS !!!!!!!!!!!!!!

 

Exactly the same when target back to 870 Linker ERROR with eeadr, etc...

 

So, is it a bug or not ????

Share this post


Link to post
Share on other sites
Nick,

 

I can't explain why this is happening.

Without seeing the two projects its difficult to know whats wrong.

 

If you zip them up and send them to support@picant.com I'll take a quick peep at the code.

 

Regards

Dave

 

 

Hello again.

 

I did some more work and think it's a linker bug...

 

I changed the targer from f870 (this is my actual H/W) to f628 and of course took out some portc related statements (since for 628 only porta, portb)...SUCCESS...

 

Exactly the same code when the target back to 870 ERROR during link........

 

All changes ONLY to main program....

 

In my opinion this is some kind of linker bug........(or compiler bug)

Edited by nikosxan

Share this post


Link to post
Share on other sites

Nick,

 

I didn't know what target you used, so I selected the PIC16F877.

 

If you use the same, change the following in you library code:

 

#include <system.h>

to:

#include <BOOSTC.h>
#include <PIC16F877A.h>

 

That will fix it.

 

The problem (a minor one really) is actually is in the compiler, it assumes a target when non is specified. Unless this target corresponds with or has the same registers the one you want to use, clashes then occur, ie the lib file and the main project both have register declarations in them with potentially different addresses.

 

This is why for a generic library you should only include BOOTC.h and forget including a specific header file - compiler should make this happen when you are building a library and include system.h, but it doesn't at the moment.

 

Regards

Dave

Share this post


Link to post
Share on other sites
Nick,

 

I didn't know what target you used, so I selected the PIC16F877.

 

If you use the same, change the following in you library code:

 

#include <system.h>

to:

#include <BOOSTC.h>
#include <PIC16F877A.h>

 

That will fix it.

 

The problem (a minor one really) is actually is in the compiler, it assumes a target when non is specified. Unless this target corresponds with or has the same registers the one you want to use, clashes then occur, ie the lib file and the main project both have register declarations in them with potentially different addresses.

 

This is why for a generic library you should only include BOOTC.h and forget including a specific header file - compiler should make this happen when you are building a library and include system.h, but it doesn't at the moment.

 

Regards

Dave

 

 

OK, it works fine now !

THANKS for all the help....... Now i can go on with the actuall project..... :unsure:

 

PS : Hope you fix the problem in newer version..... :rolleyes:

 

BYE!

Nick

Share this post


Link to post
Share on other sites
Guest JoeB

Will the long compile times be addressed any time soon? I think this is a very annoying problem with the compiler and it needs some serious work to resolve.

 

Im about 25% through a project and its taking 2 and a half minuites to compile 8 files. This is totally unacceptable. Visual studio compiles a project of mine (c++) containing over a hundred source files in under 20 seconds, and that includes linking.

 

Pull your finger out and sort it, im tired of sitting around doing nothing waiting for this compiler to do what ever its doing ( checking copyright dates? )

Edited by JoeB

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...