Searching \ for '[PIC:] C18 linking' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/devices.htm?key=pic
Search entire site for: 'C18 linking'.

Exact match. Not showing close matches.
PICList Thread
'[PIC:] C18 linking'
2003\10\23@021453 by Wouter van Ooijen

face picon face
I swallowed some of my Jal-pride and installed the C18 compiler demo. I
can compile all right (command line mode, no MPLAB please), but the
compiler does not seem to have an option to create a .hex file, so that
leaves me with a .o file. I can't find a single line in the
documentation that tells me how to create a .hex file. Am I missing
something?

Wouter van Ooijen

-- -------------------------------------------
Van Ooijen Technische Informatica: http://www.voti.nl
consultancy, development, PICmicro products

--
http://www.piclist.com hint: To leave the PICList
spam_OUTpiclist-unsubscribe-requestTakeThisOuTspammitvma.mit.edu

2003\10\23@022943 by chta Bretislav

flavicon
face
> I swallowed some of my Jal-pride and installed the C18
> compiler demo. I
> can compile all right (command line mode, no MPLAB please), but the
> compiler does not seem to have an option to create a .hex
> file, so that
> leaves me with a .o file. I can't find a single line in the
> documentation that tells me how to create a .hex file. Am I missing
> something?

mplink.exe

--
http://www.piclist.com hint: To leave the PICList
.....piclist-unsubscribe-requestKILLspamspam@spam@mitvma.mit.edu

2003\10\23@024434 by Wouter van Ooijen

face picon face
> mplink.exe

Yeah, but where in the documentation is explained how exactly I use the
linker? The linker itself is supplied with the compiler installation,
and I suppose the way the linker must be called is at least partially
specific for the compiler, so I assume the infor must be somewhere in
the compiler docs. Or am I naive?

Wouter van Ooijen

-- -------------------------------------------
Van Ooijen Technische Informatica: http://www.voti.nl
consultancy, development, PICmicro products

--
http://www.piclist.com hint: To leave the PICList
piclist-unsubscribe-requestspamKILLspammitvma.mit.edu

2003\10\23@035610 by Hulatt, Jon

flavicon
face
you need a linker script to desribe the layout of your processor.

mplink.exe processor.lkr objectfile.o /o"output.cof"

Then you can use mp3hex to convert the resultant coff file to hex.

This may not be the only, or the best way, but it works :)

jon

> {Original Message removed}

2003\10\23@035818 by

picon face
Wouter van Ooijen wrote:

>> mplink.exe
>
> Yeah, but where in the documentation is explained how exactly I use the
> linker?


The online HELP file (that gets installed together with MPLAB)
has three parts, MPASM, MPLINK and MPLIB.
In the MPLINK part there is a number of sections such as
"user guide" and "reference". The "reference" part has a complete
listing of all command line switches and parameters.

Or, can you give a closer meaning of "use" in this context ?

Jan-Erik.

--
http://www.piclist.com hint: To leave the PICList
.....piclist-unsubscribe-requestKILLspamspam.....mitvma.mit.edu

2003\10\23@035818 by Hulatt, Jon

flavicon
face
furthermore, the mplink docs are the second half of the mpasm manual
(DS33014G I think.) You'll like chapter 3 - "using MPLINK with DOS" ;-)

> {Original Message removed}

2003\10\23@041310 by Wouter van Ooijen

face picon face
> you need a linker script to desribe the layout of your processor.
>
> mplink.exe processor.lkr objectfile.o /o"output.cof"
>
> Then you can use mp3hex to convert the resultant coff file to hex.
>
> This may not be the only, or the best way, but it works :)

Now that is usefull for a beginner! The C18 manual spells out the
command line use of the compiler, why doesn't it mention what you state
too?

Wouter van Ooijen

-- -------------------------------------------
Van Ooijen Technische Informatica: http://www.voti.nl
consultancy, development, PICmicro products

--
http://www.piclist.com hint: To leave the PICList
EraseMEpiclist-unsubscribe-requestspam_OUTspamTakeThisOuTmitvma.mit.edu

2003\10\23@041311 by Wouter van Ooijen

face picon face
> furthermore, the mplink docs are the second half of the mpasm manual

Maybe I am naive, but I expected the compiler installation to be
'self-contained', that is: not needing any further software or
documentation (besides of course the PIC datasheet). And I think the
linking has some compiler-specific aspects (like the selected start-up
code), which I don't expect to find in the linker documentation!

I'll just have to dig some more...

Wouter van Ooijen

-- -------------------------------------------
Van Ooijen Technische Informatica: http://www.voti.nl
consultancy, development, PICmicro products

--
http://www.piclist.com hint: To leave the PICList
piclist-unsubscribe-requestspamspam_OUTmitvma.mit.edu

2003\10\23@050539 by Hulatt, Jon

flavicon
face
Do look at that doc; it talks about mplink with c18, and also coming asm and
C objects together.

> {Original Message removed}

2003\10\23@050955 by

picon face
Hulatt, Jon wrote:

> Do look at that doc;

What doc ? The MPASM/MPLINK/MPLIB manual ?

> it talks about mplink with c18,

Which is what Wouter needs to read about, not ?

> and also coming [combining ?] asm and
> C objects together.

And is that bad ?

Jan-Erik.

--
http://www.piclist.com hint: To leave the PICList
@spam@piclist-unsubscribe-requestKILLspamspammitvma.mit.edu

2003\10\23@051409 by

picon face
Wouter van Ooijen wrote:
> Maybe I am naive, but I expected the compiler installation to be
> 'self-contained', that is: not needing any further software or
> documentation (besides of course the PIC datasheet).

Note that almost *all* computer environments (from PICs to the
largest IBM MVS installations) makes a clear distinction
between "compiling" and "linking". That the PIC tools also works
in this way, is, IMHO, a good thing. Makes mixing different
languages simpler, the linker just "links" object files, no matter
what tool (C18/MPASM/whatever) produced them.

Now, MChip *could* have included the linker in the C18 kit, but that
doesn't change much. Even better had been if they made the linker
available as a separate downloadable kit, to better support non-
MPLAB/MPASM users. And, even MPASM should be made available separatly,
to support those using e.g. Olin's environment. Something like a
"MPLAB-free" toolkit !


> And I think the
> linking has some compiler-specific aspects (like the selected start-up
> code), which I don't expect to find in the linker documentation!

Well, I don't know C18 in detail, but in general, I'd expect *any*
linker to have as *few* compiler- or assembler-specific aspects
as possible. The linker don't have to "know" what tool created the
object file(s).

Shouldn't the C18 compiler "mark" some code as beeing the "start code",
and put a "hard" h'00' address there (i the object file) ? The linker
will then just put that specific code at address h'00' and then
continue spreading out the rest of the code.

Jan-Erik.

--
http://www.piclist.com hint: To leave the PICList
KILLspampiclist-unsubscribe-requestKILLspamspammitvma.mit.edu

2003\10\23@053906 by Hulatt, Jon

flavicon
face
sorry, the document I was referring to was mentioned earlier in the thread:-

>> furthermore, the mplink docs are the second half of the mpasm manual
(DS33014G I think.) You'll like chapter 3 - "using MPLINK with DOS" ;-)

> > it talks about mplink with c18,
>
> Which is what Wouter needs to read about, not ?

yep, that's why I said that,

> > and also coming [combining ?] asm and
> > C objects together.
>
> And is that bad ?

nope, not at all- something Wouter might well want to do.

jon

PS. sorry for my lazy typing full of typos :-)

> {Original Message removed}

2003\10\23@054940 by

picon face
Oh damn, I just re-read your post !
I missread "Do read" as "Don't read" !!

"Shame on you, mr Soderholm !"

Double-sorry !!!

Jan-Erik.



Hulatt, Jon wrote:
> >
> > Which is what Wouter needs to read about, not ?
>
> yep, that's why I said that,

--
http://www.piclist.com hint: To leave the PICList
RemoveMEpiclist-unsubscribe-requestTakeThisOuTspammitvma.mit.edu

2003\10\23@055148 by Alan B. Pearce

face picon face
>Now, MChip *could* have included the linker in the C18 kit, but that
>doesn't change much. Even better had been if they made the linker
>available as a separate downloadable kit, to better support non-
>MPLAB/MPASM users. And, even MPASM should be made available separatly,
>to support those using e.g. Olin's environment. Something like a
>"MPLAB-free" toolkit !

Do note that there are options in the MPLAB install that allow you to
install only portions of the package so that it is possible to do things
this way. It would just be a pain to have to download the whole package to
get the bit you want. What is it these days, something like 23MB IIRC, an
awful lot if you just want the linker and its help file, or the DOS
assembler.

--
http://www.piclist.com hint: To leave the PICList
spamBeGonepiclist-unsubscribe-requestspamBeGonespammitvma.mit.edu

2003\10\23@071244 by Wouter van Ooijen

face picon face
> Note that almost *all* computer environments (from PICs to the
> largest IBM MVS installations) makes a clear distinction
> between "compiling" and "linking".

Yes, but all tools I have used so far also have an option (or better
yet, a default!) to generate an executable (for a microccontroller: an
image, hex or other format) without a separate merge, relocate, link or
other step.

> Now, MChip *could* have included the linker in the C18 kit, but that

Actually they *do* include in mplink.exe and _mplink.exe. But no info
(as far as I can see) on how to use them. Nor does the compiler have an
option to hide this use from me, as most 'decent' compilers have.

Wouter van Ooijen

-- -------------------------------------------
Van Ooijen Technische Informatica: http://www.voti.nl
consultancy, development, PICmicro products

--
http://www.piclist.com hint: To leave the PICList
TakeThisOuTpiclist-unsubscribe-requestEraseMEspamspam_OUTmitvma.mit.edu

2003\10\23@075259 by

picon face
Wouter van Ooijen wrote:


> > Now, MChip *could* have included the linker in the C18 kit, but that
>
> Actually they *do* include in mplink.exe and _mplink.exe.

Yes, I saw that later, but from your posts I thought that it wasn't...

> But no info (as far as I can see) on how to use them.

Well, how to configure them un MPLAB is included in the docs, but I *do*
miss an example of a MPLINK command-line command with all rellevant
libraries included and so on, yes. But I think it's more or less
the same info as is entered in the link-config forms in MPLAB anyway...

> Nor does the compiler have an
> option to hide this use from me, as most 'decent' compilers have.

I could very well think of a compiler doing that, but I wouldn't
call it an "decent" compiler :-) YMMV...

Anyway, MPLAB is the "glue" to integrate the compile and link phases.
Or just use some plain DOS/BAT/Command files...

Now, I think we *can* agree on that this doesn't lead any further, right ? :-)

In fact, I'm just going to startup a new project using a 18-series PIC
(I think), and I'm just going to take a look at C18 myself. Who knows,
in a couple of days I might be in 100% agreement with you :-)

Jan-Erik.

--
http://www.piclist.com hint: To leave the PICList
RemoveMEpiclist-unsubscribe-requestspamTakeThisOuTmitvma.mit.edu

2003\10\23@084138 by Wouter van Ooijen

face picon face
Jon Hulatt's answer was short and put me in the right direction. Below
is the batch file I now use. Use at your own risk :)

Wouter van Ooijen

-- -------------------------------------------
Van Ooijen Technische Informatica: http://www.voti.nl
consultancy, development, PICmicro products

@echo off

rem makefile for a C18 single-source program
rem (c) 2003 Wouter van Ooijen
rem provided under GPL license
rem    but the standard text is much too long to repeat here

set c18path=c:\mcc18

rem help
if not "%1" == "" goto no_help
echo -
echo This is a build script for a C18 single-source program.
echo usage:
echo    build main_file [script]
echo The main file must be main_file.c
echo If a script is specified it is used as linker script.
echo If not main_file.lkr is used.
echo The result file (if all goed well) is main_file.hex
echo -
goto done
:no_help

rem compile
if exist %1.o del %1.o
if exist %1.lst del %1.lst
c18demo %1
if exist %1.o goto compilation_ok
echo compilation failed
goto done
:compilation_ok

rem determine link script file name
set script=%2.lkr
if not "%2" == "" goto script_specified
set script=%1.lkr
:script_specified

rem link etc.
if exist %1.cod del %1.cod
if exist %1.hex del %1.hex
mplink /l %c18path%\lib /k %c18path%\lkr /o %1 %script% %1.o >link.log
if exist %1.hex goto cleanup
echo linking failed
goto done

:cleanup
rem cleanup junk
if exist %1.cod del %1.cod
if exist %1.o del %1.o
if exist link.log del link.log
if exist %1.c if exist %1 del %1
echo OK

:done

--
http://www.piclist.com hint: To leave the PICList
piclist-unsubscribe-requestEraseMEspam.....mitvma.mit.edu

2003\10\23@112726 by Olin Lathrop

face picon face
Wouter van Ooijen wrote:
> Actually they *do* include in mplink.exe and _mplink.exe. But no info
> (as far as I can see) on how to use them.

The MPLINK command line is fully documented in "MPASM User's Guide with
MPLINK and MPLIB", DS33014G.


*****************************************************************
Embed Inc, embedded system specialists in Littleton Massachusetts
(978) 742-9014, http://www.embedinc.com

--
http://www.piclist.com hint: To leave the PICList
EraseMEpiclist-unsubscribe-requestspammitvma.mit.edu

2003\10\23@115015 by Wouter van Ooijen

face picon face
> Wouter van Ooijen wrote:
> > Actually they *do* include in mplink.exe and _mplink.exe.
> But no info
> > (as far as I can see) on how to use them.
>
> The MPLINK command line is fully documented in "MPASM User's
> Guide with
> MPLINK and MPLIB", DS33014G.

Of course, but the linker *is* part of the compiler distribution, and a
single line of explanation (or example) about how it is invoked would
have been sufficient. Why require a user to download yet another tool
and browse its manual? Note that (simple) linker scripts *are* provided
with the compiler, but no hint on ho to use them.

Of course I have found out by now how to use the linker (that is, hide
its use from me :). I just call a batch file that compiles, links and
downloads.

Now I just have to figure out a way to specify the linker file content
from within the C source. Probably inside a comment and using fgrep or
something like that. I like a fully self-contained source...

Wouter van Ooijen

-- -------------------------------------------
Van Ooijen Technische Informatica: http://www.voti.nl
consultancy, development, PICmicro products

--
http://www.piclist.com hint: To leave the PICList
RemoveMEpiclist-unsubscribe-requestEraseMEspamEraseMEmitvma.mit.edu

2003\10\23@123959 by

picon face
Just a note...

The linker included in MPLAB 6.30 is MPLINK V3.50.
The linker included in the current C18 demo kit is MPLINK V3.40.

The readme file for MPLINK V3.50 says :

"MPLINK Linker v3.50 supports the linking of modules whose source
contains local variables of the 'overlay' storage class.
Such source must be compiled with MPLAB C18 C Compiler v2.00 or later.
See 'README.C18' for details on
the semantics of the 'overlay' storage class."

I'v no idea if this is significant, but...

On the other hand, the readme file for the current C18 demo kit says :

"MPLAB C18 requires the use of MPLINK(tm), Microchip's object linker.
In particular, object files built with MPLAB C18 v2.20.04 require
MPLINK v3.20.00 or greater, which is included in this installation."

It's a little unclear what version one *should* use, but it
could be good to know this anyway...

Jan-Erik.

--
http://www.piclist.com hint: To leave the PICList
RemoveMEpiclist-unsubscribe-requestspam_OUTspamKILLspammitvma.mit.edu

2003\10\23@145459 by Wouter van Ooijen

face picon face
>  "MPLINK Linker v3.50 supports the linking of modules whose source
>  contains local variables of the 'overlay' storage class.
>  Such source must be compiled with MPLAB C18 C Compiler v2.00
> or later.
>  See 'README.C18' for details on
>  the semantics of the 'overlay' storage class."
>
> I'v no idea if this is significant, but...

Without the 'overlay' storage class all local variables are allocated
unique locations. I can not believe this (unique locations) is the
default used by a serious compiler!

Wouter van Ooijen

-- -------------------------------------------
Van Ooijen Technische Informatica: http://www.voti.nl
consultancy, development, PICmicro products

--
http://www.piclist.com hint: To leave the PICList
RemoveMEpiclist-unsubscribe-requestTakeThisOuTspamspammitvma.mit.edu

2003\10\23@145914 by

picon face
Wouter van Ooijen wrote:

> >  "MPLINK Linker v3.50 supports the linking of modules whose source
> >  contains local variables of the 'overlay' storage class.
> >  Such source must be compiled with MPLAB C18 C Compiler v2.00
> > or later.
> >  See 'README.C18' for details on
> >  the semantics of the 'overlay' storage class."
> >
> > I'v no idea if this is significant, but...
>
> Without the 'overlay' storage class all local variables are allocated
> unique locations. I can not believe this (unique locations) is the
> default used by a serious compiler!

Fine, I'm not a C-guy, but I read this as you
normaly want to use the 'overlay' storage class. And
then, also the V3.50 linker, or ?

Jan-Erik.

--
http://www.piclist.com hint: To leave the PICList
EraseMEpiclist-unsubscribe-requestspamspamspamBeGonemitvma.mit.edu

2003\10\23@202201 by John Ferrell

face picon face
While you are looking at the C18 demo, be sure to read the part about string
constants.
So far, I have not found anyone else the shares my feeling that this is
strange...

John Ferrell
6241 Phillippi Rd
Julian NC 27283
Phone: (336)685-9606
RemoveMEjohnferrellKILLspamspamearthlink.net
Dixie Competition Products
NSRCA 479 AMA 4190  W8CCW
"My Competition is Not My Enemy"


{Original Message removed}

2003\10\24@031315 by Wouter van Ooijen

face picon face
> While you are looking at the C18 demo, be sure to read the
> part about string
> constants.
> So far, I have not found anyone else the shares my feeling
> that this is
> strange...

That was solved quite quickly, the error message at least gave a hint in
the right direction.

Another problem: The sequence

#include <p18f242.h>
#include <delays.h>

gives an error because delays.h includes p18cxxx.h, which conflicts with
p18f242.h! My solution is to fake that p18cxxx is already included:

#include <p18f242.h>
#define _P18CXXX_H /* otherwise p18cxxx will be included which conflicts
with p18f242 :( */
#include <delays.h>

Wouter van Ooijen

-- -------------------------------------------
Van Ooijen Technische Informatica: http://www.voti.nl
consultancy, development, PICmicro products

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads

2003\10\24@211952 by Michael Davidson

flavicon
face
On 2003-10-24 at 17:13:33 [+1000], Wouter van Ooijen wrote:
> Another problem: The sequence
>
> #include <p18f242.h>
> #include <delays.h>
>
> gives an error because delays.h includes p18cxxx.h, which conflicts with
> p18f242.h! My solution is to fake that p18cxxx is already included:
>
> #include <p18f242.h>
> #define _P18CXXX_H /* otherwise p18cxxx will be included which conflicts
> with p18f242 :( */
> #include <delays.h>

Why don't you just #include <p18cxxx.h> rather than p18f242.h? p18cxxx.h
will include p18f242.h for you based on your processor directive.

--
Michael Davidson
Fortune:
It's not that I'm afraid to die.  I just don't want to be there when it
happens.
               -- Woody Allen

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads

2003\10\25@020430 by Wouter van Ooijen

face picon face
> Why don't you just #include <p18cxxx.h> rather than
> p18f242.h? p18cxxx.h
> will include p18f242.h for you based on your processor directive.

Which processor directive? I have a .c file that I want to compile with
a 'c18demo main.c' command. It already hurts me that the linker script
is not in the source file, I am not gona have yet another part of the
project outside the source file! Or can I put the processor directive in
the source file?

Wouter van Ooijen

-- -------------------------------------------
Van Ooijen Technische Informatica: http://www.voti.nl
consultancy, development, PICmicro products

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics

2003\10\25@065558 by

picon face
Wouter van Ooijen wrote:

> > Why don't you just #include <p18cxxx.h> rather than
> > p18f242.h? p18cxxx.h
> > will include p18f242.h for you based on your processor directive.
>
> Which processor directive? I have a .c file that I want to compile with
> a 'c18demo main.c' command. It already hurts me that the linker script
> is not in the source file, I am not gona have yet another part of the
> project outside the source file! Or can I put the processor directive in
> the source file?Wouter van Ooijen wrote:

The '-p' command-line option.

See Page 7, section 1.2.4 of the C18 User Guide.

And a quote from page 32, section 2.10 of the same doc:

 "Alternatively, #include <p18cxxx.h> will include
  the proper processor-specific header file based
  on the processor selected on the command line via
  the -p command-line option."

Jan-Erik.

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics

2003\10\25@083711 by Olin Lathrop

face picon face
Wouter van Ooijen wrote:
> It already hurts me that the linker script
> is not in the source file,

Maybe you should think of the linker control file in a different way.  I
try to set up my linker files to describe the PIC hardware details without
any project specific information.  The various linker control files do
this in a common way using the same conventions as much as possible.

In this view it's actually advantages to separate the linker file and the
source code.  If you you need to change PICs, you change the processor
selection in one include file and reference a different linker file in the
build script.  Lots of different projects on the same PIC use the same
linker file.


*****************************************************************
Embed Inc, embedded system specialists in Littleton Massachusetts
(978) 742-9014, http://www.embedinc.com

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics

2003\10\25@084126 by Wouter van Ooijen

face picon face
> Maybe you should think of the linker control file in a
> different way.  I
> try to set up my linker files to describe the PIC hardware
> details without
> any project specific information.  The various linker control files do
> this in a common way using the same conventions as much as possible.

That is one way to look at it, but unfortunately the linker files also
contain details like the start-up code (for instance: are globals
initialised to 0 as per ANSI-C or left uninitialised?) and debugger
things.

Wouter van Ooijen

-- -------------------------------------------
Van Ooijen Technische Informatica: http://www.voti.nl
consultancy, development, PICmicro products

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics

2003\10\25@143945 by Olin Lathrop

face picon face
Wouter van Ooijen wrote:
> That is one way to look at it, but unfortunately the linker files also
> contain details like the start-up code (for instance: are globals
> initialised to 0 as per ANSI-C or left uninitialised?) and debugger
> things.

I guess these are compiler specific things.  Can't all this stuff be
specified by referencing the appropriate externals?  It seems to me
decisions about how to deal with static variables should be specified with
compiler options, not at link time.


*****************************************************************
Embed Inc, embedded system specialists in Littleton Massachusetts
(978) 742-9014, http://www.embedinc.com

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics

More... (looser matching)
- Last day of these posts
- In 2003 , 2004 only
- Today
- New search...