It is a GCC linker thing, not just mspgcc. I don't remember how I learned this, 
probably by asking just like you did.

The only official mention of it I can find is here:

http://gcc.gnu.org/onlinedocs/gcc-3.3.6/gcc/Link-Options.html#Link-Options


It is a very brief mention though. I am unclear myself what happens when 
library A needs library B - does it then not matter what order they appear in? 
I am guessing so.


- Wayne
Sent via BlackBerry® from Vodafone

-----Original Message-----
From: "Douglass, Woodrow" <[email protected]>

Date: Tue, 2 Jun 2009 08:35:21 
To: GCC for MSP430 - http://mspgcc.sf.net<[email protected]>
Subject: Re: [Mspgcc-users] internal error: out of range error


Thanks a lot, it links now. One question though, is this somewhere in
the documentation that I missed? Should it be added? It seems like this
would be a common mistake...

Thanks again!
-Woodrow



-----Original Message-----
From: Wayne Uroda [mailto:[email protected]]
Sent: Monday, June 01, 2009 9:03 PM
To: GCC for MSP430 - http://mspgcc.sf.net
Subject: Re: [Mspgcc-users] internal error: out of range error

Hi Woodrow,

The linker will only bring in an object if it contains an undefined
symbol when it is read on the command line (it reads files left to
right).

The Symbol main gets referenced in libgcc.a(__jump_to_main.o). Unless
you specify otherwise, libgcc.a is linked last by the linker. This means
when you asked it to link libs/libmain.a it did nothing because that
wasn't required at the time.

You can change the link order like this:

msp430-gcc -mmcu=msp430xG4618 -Wl,-Map=./main.map,--cref --output
main.elf newmodule.o libs/libkernel.a libs/libmail.a libs/libversion.a
-lgcc libs/libmain.a

The -lgcc just tells the linker to pull in libgcc.a from its library
path. It will then see that `main' is undefined, and so will link it
next when it sees libmain.a.

I did a small experiment here like this:

#### This has an error:
> msp430-gcc -mmcu= msp430xG4618 main.a
..../libgcc.a(_reset_vector__.o): In function `_reset_vector__':
config/msp430/libgcc.S:(.init+0x38): undefined reference to `main'

#### But this builds fine:
> msp430-gcc -mmcu= msp430xG4618 -lgcc main.a

I am not a guru on this but I think it should work. I am sure if it
doesn't somebody else here will know the answer.

- Wayne

-----Original Message-----
From: Douglass, Woodrow [mailto:[email protected]]
Sent: Tuesday, 2 June 2009 2:54 AM
To: [email protected]
Subject: [Mspgcc-users] internal error: out of range error

My program compiles fine, but when I try to link it together, I get this
error:

c:\mspgcc\bin\..\lib\gcc-lib\msp430\3.2.3\libgcc.a(__jump_to_main.o): In
function `__jump_to_main':
(.init9+0x2): undefined reference to `main'
make[1]: *** [main.elf] Error 1
make: *** [newmodule] Error 2

I'm invoking the compiler this way:

msp430-gcc -mmcu=msp430xG4618 -Wl,-Map=./main.map,--cref  --output
main.elf newmodule.o   libs/libmain.a    libs/libkernel.a
libs/libmail.a libs/libversion.a

the archive libmain.a contains a function with the signature "int
main(void)". Is there something else I need to do to get this to link
properly?

Thanks for any insight you can provide!!!

-Woodrow Douglass



------------------------------------------------------------------------
------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers & brand creativity professionals.
Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, &
iPhoneDevCamp as they present alongside digital heavyweights like
Barbarian
Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com
_______________________________________________
Mspgcc-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mspgcc-users

------------------------------------------------------------------------
------
OpenSolaris 2009.06 is a cutting edge operating system for enterprises
looking to deploy the next generation of Solaris that includes the
latest
innovations from Sun and the OpenSource community. Download a copy and
enjoy capabilities such as Networking, Storage and Virtualization.
Go to: http://p.sf.net/sfu/opensolaris-get
_______________________________________________
Mspgcc-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mspgcc-users

------------------------------------------------------------------------------
OpenSolaris 2009.06 is a cutting edge operating system for enterprises
looking to deploy the next generation of Solaris that includes the latest
innovations from Sun and the OpenSource community. Download a copy and
enjoy capabilities such as Networking, Storage and Virtualization.
Go to: http://p.sf.net/sfu/opensolaris-get
_______________________________________________
Mspgcc-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mspgcc-users

Reply via email to