Previous in Forum: Can Not Download Files From Internet   Next in Forum: Personal Finance Software Wanted
Close
Close
Close
16 comments
Rate Comments: Nested
Guru
Popular Science - Weaponology - New Member United Kingdom - Member - New Member

Join Date: May 2007
Location: Harlow England
Posts: 16512
Good Answers: 670

Good Software Won't Link

12/09/2014 8:37 AM

I started getting weird messages from my development system, so I uninstalled and downloaded the latest version.
My previously good software is now giving "unresolved external" messages.

I've cut it down to the bare minimum of 2 ridiculously simple modules.
Main which calls the functions "levels" which loads 4 numbers into memory and that's it.
I get "unresolved external 'levels' "...

Can anyone see why?
I've tried sprinkling void levels(void); just about everywhere but got no luck.

How come assembler is n times easier than C?

Here are the two modules.

/**************************************************************

Main program body

*************************************************************/

uint16_t eeprom level[4];

void main(void)

{

// Load Level arrays

levels();

while (1)

{

}

}

/******************* *****END OF FILE****/

/************************************************************
* @file Levels.c
***********************************************************/

extern uint16_t eeprom level[4];

void levels(void)

{

level[0]= 10;

level[1]= 53;

level[2]= 56;

level[3]= 57;

}

/************************END OF FILE****/

Maybe there is some weird set up in some obscure configuration file... but I just can't see why the heck main can't see the function "levels" .

I've submitted a query to the support desk... (yeah we all know what that means ).

Of course if I put levels into the same module as main it works fine, but that rather looses the purpose of "high level" languages, and for the real program it would become unwieldy.

Del

BTW This editor removes all the indentation.... wonder if it would do that on car body panels?

__________________
health warning: These posts may contain traces of nut.
Register to Reply
Interested in this topic? By joining CR4 you can "subscribe" to
this discussion and receive notification when new comments are added.
Guru

Join Date: Feb 2011
Posts: 1119
Good Answers: 11
#1

Re: Good Software Won't Link

12/09/2014 9:41 AM

Last hands-on with C++ and Java was 2001, what's the function while (1) suppose to mean?

__________________
" To infinity and beyond" - Buzz Lightyear
Register to Reply
Guru
Popular Science - Weaponology - New Member United Kingdom - Member - New Member

Join Date: May 2007
Location: Harlow England
Posts: 16512
Good Answers: 670
#2
In reply to #1

Re: Good Software Won't Link

12/09/2014 10:07 AM

That just sits doing now't for ever.

I'm beginning to suspect I've got some of the configuration files wrong... I'm trying to tease it back to some simple known working state. It makes no sense at the moment.

How on earth it can't recognise a function in another module is beyond me.

In assembler you'd just have to say the function was external and where it's written you'd say it was global.... easy.... C is too clever by half, complicated to the point of uselessness.

Del

__________________
health warning: These posts may contain traces of nut.
Register to Reply
Guru

Join Date: Feb 2011
Posts: 1119
Good Answers: 11
#3
In reply to #2

Re: Good Software Won't Link

12/09/2014 10:13 AM

would it not be possible to write it on single file? of course with out external.

__________________
" To infinity and beyond" - Buzz Lightyear
Register to Reply
Guru
Popular Science - Weaponology - New Member United Kingdom - Member - New Member

Join Date: May 2007
Location: Harlow England
Posts: 16512
Good Answers: 670
#4
In reply to #3

Re: Good Software Won't Link

12/09/2014 10:57 AM

Yes indeed, as I said in the original post.
This is just a cut down tiny portion to show there is a problem. The real software is large and complex (not just putting numbers into memory locations). I'm just struggling to get to the root of what should be a trivial problem.

'main' should be able to use the function 'levels' but for some reason the compiler is not resolving the names.

Del

__________________
health warning: These posts may contain traces of nut.
Register to Reply
Guru

Join Date: Feb 2011
Posts: 1119
Good Answers: 11
#5
In reply to #4

Re: Good Software Won't Link

12/09/2014 11:02 AM

Yes, probably compiler problem. Sorry, I haven't noticed in your post so well, like I passively read sometimes.

__________________
" To infinity and beyond" - Buzz Lightyear
Register to Reply
Guru
Canada - Member - If there is a way to screw someting up, there is someone to do so! Safety - Hazmat - New Member

Join Date: Mar 2007
Location: Iqaluit, NU. Canada
Posts: 1854
Good Answers: 140
#6

Re: Good Software Won't Link

12/09/2014 12:29 PM

Sounds to me like you are now missing some data from a library file that the compiler needs. Have you added or updated any other software that might overwrite library files held in the dreaded DLLs?

Microsoft has done that to me in the past. Update a MSC MFC DLL and loose a required routine not in the updated DLL, took days to find, then had to go back to an earlier version to get the compiler happy again.

__________________
Joe Contractor to Electrical Inspector, "What do you mean you are going to make me follow the code?".
Register to Reply
Guru
Popular Science - Weaponology - New Member United Kingdom - Member - New Member

Join Date: May 2007
Location: Harlow England
Posts: 16512
Good Answers: 670
#7
In reply to #6

Re: Good Software Won't Link

12/09/2014 3:13 PM

Cheers I'm going to have to try and rebuild it all from the floor I think.
Might even have to resort to trying to read the documentation (all damn pdfs of course)... the development system is a nightamre... all shiny font end and you have no idea where the files come from or go to.

Gimme old school any time.

Del

__________________
health warning: These posts may contain traces of nut.
Register to Reply
Guru

Join Date: Sep 2009
Posts: 1056
Good Answers: 88
#8

Re: Good Software Won't Link

12/09/2014 3:56 PM

Just declare "levels" function as "extern" into header file to make sure it is read first, and put the actual definition in c file. Header guards to prevent re-including is also good idea. S.M.

__________________
Life is complex. It has a real part and an imaginary part.
Register to Reply
Guru
Popular Science - Weaponology - New Member United Kingdom - Member - New Member

Join Date: May 2007
Location: Harlow England
Posts: 16512
Good Answers: 670
#11
In reply to #8

Re: Good Software Won't Link

12/10/2014 3:10 AM

Can you give and example of exactly what I should put in?

I've tried sticking the word extern in front of the void levels(void);

maybe there is maybe some daft syntax I'm missing?

Del

__________________
health warning: These posts may contain traces of nut.
Register to Reply
Power-User

Join Date: Aug 2008
Location: Melbourne, Australia
Posts: 476
Good Answers: 32
#9

Re: Good Software Won't Link

12/10/2014 1:53 AM

You need to tell main that levels is available and what arguments it has. Place this in main after the uint16 declaration. void levels(void);

__________________
johny451
Register to Reply
Guru
Popular Science - Weaponology - New Member United Kingdom - Member - New Member

Join Date: May 2007
Location: Harlow England
Posts: 16512
Good Answers: 670
#10
In reply to #9

Re: Good Software Won't Link

12/10/2014 3:06 AM

Yeah, I've tried all that...

like I said I've sprinkled void levels(void); all over the place...

Del

__________________
health warning: These posts may contain traces of nut.
Register to Reply
Guru
Popular Science - Weaponology - New Member United Kingdom - Member - New Member

Join Date: May 2007
Location: Harlow England
Posts: 16512
Good Answers: 670
#12

Re: Good Software Won't Link

12/10/2014 3:21 AM

It's probably an RTFM problem in clause 1d10t.

Like most projects it was done in a blazing hurry, piggybacked on the suppliers example and now I need to tease it into some sort of order.

No thanks for getting done on time just long faces and mumbling now I need to spend time house keeping. T'was ever thus.

I'm printing out the several manuals that come with the dev't kit so I can pough through them in detail... oh joy!

The tech support works like most tech support... they do nothing in the knowledge that given enough time you'll fix it (or retire and go make bows )

Del

__________________
health warning: These posts may contain traces of nut.
Register to Reply
Guru

Join Date: Oct 2009
Posts: 1460
Good Answers: 30
#13

Re: Good Software Won't Link

12/10/2014 4:52 AM

I'm surprised your compiler has not generated even more error messages. The main() program in C has a very specific form, which is
int // Specifies that type of variable the function returns.
// main() must return an integer
main ( int argc, char **argv ) {
// code
return 0; // Indicates that everything vent well.
}
The format of the parameters for main is fixed, but the use of the parameters is optional, i.e. you need not give values when running a program unless you want to. You should also be making use of header files (.h) for your declarations, e.g.
//levels.h
void levels(void);
and your main file would include the declaration at the top
#include "levels.h"
In general, the .h files would include all the declarations and the .c files the code. In that way you can achieve the aim of modules of reusable code.

Register to Reply
Guru
Popular Science - Weaponology - New Member United Kingdom - Member - New Member

Join Date: May 2007
Location: Harlow England
Posts: 16512
Good Answers: 670
#14

Re: Good Software Won't Link

12/10/2014 6:43 AM

Fixed it!

It was now't to do with functions, declarations etc.

Once I studied the linker output files I spotted some extra stuff in there.
The "project" had some how got a second load of files from another demo project mixed in with it. The project structure is shown as a tree and this extra stuff had some how got dragged in at the root.
The poor thing was getting confused.

Anyhow I've taken a screen shot of the working set up for future reference.

Thanks for putting up with my rantings...

Del

__________________
health warning: These posts may contain traces of nut.
Register to Reply
Guru

Join Date: Mar 2007
Location: Etherville
Posts: 12362
Good Answers: 115
#15
In reply to #14

Re: Good Software Won't Link

12/10/2014 7:30 AM

Phew - now you can go out with the spangly dress !

__________________
For sale - Signature space. Apply on self addressed postcard..
Register to Reply Off Topic (Score 5)
Guru
Popular Science - Weaponology - New Member United Kingdom - Member - New Member

Join Date: May 2007
Location: Harlow England
Posts: 16512
Good Answers: 670
#16
In reply to #15

Re: Good Software Won't Link

12/10/2014 8:06 AM

How did you know we were having a cross dressing Christmas party in the office?

Del

__________________
health warning: These posts may contain traces of nut.
Register to Reply Off Topic (Score 5)
Register to Reply 16 comments
Copy to Clipboard

Users who posted comments:

Johny451 (1); Kris (1); North of 60 (1); Noudge79 (3); phph001 (1); SimpleMind (1); user-deleted-1105 (8)

Previous in Forum: Can Not Download Files From Internet   Next in Forum: Personal Finance Software Wanted

Advertisement