Jump to content
Sign in to follow this  
hollie

Linking Project Fails

Recommended Posts

Hello,

 

I encounter a strange problem when I try to compile a project that I created in a previous version of SourceBoost/BoostC.

 

When I load the old project file, or I create a new project and add all the source files at once, I get the following error at link time:

 

Linking...

C:\usr\local\SourceBoost\linker.exe /ld C:\usr\local\SourceBoost\lib libc.pic16.lib serial.obj solar.obj adc.obj /t 16F876A /d D:\home\xxxxx\projects\pic\test2 /p test2

BoostLink Optimizing Linker Version 1.9 Beta
http://www.picant.com/c2c/c.html
Copyright(C) 2004-2005 Pavel Baranov
Copyright(C) 2004-2005 David Hobday
Error: .obj/.lib different clock frequencies specified
Error: Failed to process:solar.obj
Error: .obj/.lib different clock frequencies specified
Error: Failed to process:adc.obj
Warning: Unable to successfully create 'delay_us' for target with clock freq 4000000 Hz
Warning: argument of 'delay_10us' calls must have a value of 1 or more

Failed
Done

 

There are 2 errors here: firstly the clock rate is only declared once, so it is strange that the linker tells me that different clock frequencies are specified. And secondly, the clock rate is declared to be 10MHz (both in the source file and in the IDE), while the linker tells me it is only 4MHz.

 

What I did to solve this: I created a second new project, added the source files one by one (first the main file and then the 'libs'), and started a compilation between every addition of a file to the project (the compilations failed of course...). Once all files are added, the final project compiles and links properly.

 

Steps to reproduce:

Open the old project, or create a new project and add all the source files at once. Try to build the project. It fails.

 

Expected behaviour: the project should build properly.

 

Reproducible: 100%, I can send you 2 example projects that contain the same source code. One fails and one doesn't.

 

IDE version : 5.8

Compiler : BoostC 1.9.1

Linker : 1.9

Target device : PIC16F876A

OS : W2K

Share this post


Link to post
Share on other sites

Hello,

 

in the mean time I have figured out that the only difference between the project that works and the one that doesn't is in the project file.

 

The version that doesn't link contains:

 

[Files]
File0=solar.h
Count=6
File1=adc.h
File2=serial.c
File3=serial.h
File4=solar.c
File5=adc.c

 

The one that does link contains:

 

[Files]
File0=solar.h
Count=6
File1=serial.h
File2=solar.c
File3=adc.h
File4=serial.c
File5=adc.c

 

The clock frequency pragma is located in 'solar.h', so I think that the new linker assumes that the clock frequency is 4 MHz until it encounters the pragma statement (this statement is only encountered in the file 'solar.c', since 'solar.h' is included there). This would explain why it complains about the multiple clock frequency definitions.

 

Did this behaviour change from the previous version? With the v1.8 compiler, I did not encounter this problem.

 

Kind regards.

Share this post


Link to post
Share on other sites

Hollie,

 

Yes this functionality changed between BoostC V1.8 and V1.9

 

What is meant to happen is this:

If no clock frequcency is specified in source file, then compiler should put no clock frequency in .obj file.

 

If two .obj files contain different clock frequcency settings, then this is any error, because linker has no idea which to use.

 

This all looks like it is working correctly with compiler V1.9.1

 

Regards

Dave

Edited by Dave

Share this post


Link to post
Share on other sites

Hello Dave,

 

I have 2 remarks on this:

 

Firstly, it seems to me that if there is no clock frequency is specified in a source file, a 4 MHz clock is assumed (see the error log in my first post, "Unable to successfully create 'delay_us' for target with clock freq 4000000 Hz". I really didn't specify anything like that in my source files).

 

Secondly, if what I describe is the intended behaviour (as you tell in your reply), then you mean that one has to specify the clock frequency in all the source files of the project, since there is no way to predict the order in which they will be included in a project? This looks a bit strange to me.

 

If you state that it is working correctly with compiler v1.9.1, then I think you need to add that it only works correctly if one first loads the main project file separately and then all the other source files of a project in a second step. This ensures that in the <project.__c> file, the main source file is mentioned first. Hence, it will be compiled first and the clock frequency will be known for compiling all subsequent source files. I think this should be stated in the documentation.

 

Of course, when building a project from scratch, the user will normally first create the main file and will only later on add additional source files. But if one wants to make a new project starting from an existing project, I think it is not so strange if the user creates an empty project and includes all the source files of the other project in one step. In this case the problem I described can/will occur.

 

Maybe another solution would be that the user can select one file to be the 'top of the design' and that this file is always compiled first? Or the compiler could compile the file that contains the 'main' function first?

 

Kind regards,

Hollie.

Share this post


Link to post
Share on other sites

Hollie,

 

This was a bug in the BoostC compiler and is now fixed in V1.9.2

 

Only one source file needs to specify the clock frequency.

More than one source file can specify the clock frequency, but they must then all match, otherwise its an error.

 

Regards

Dave

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