Hi there,
I hope you'll be able to help me on this one again because it's making me crazy !
So, I have a lib and a game
Lib calls severals function of SGDK
game call severals function of Lib and SGDK
Let's say Lib call
- VDP_setHorizontalScroll() from vdp_bg.c/.h, into a scroll function
- VDP_setVerticalScroll() from vdp_bg.c/.h, into a scroll function
- JOY_init() from joy.c, into a joy_start() function
Let's say game call
- JOY_init() from joy.c/.h
- Joy_start() from lib
- scroll() from lin
My problem ?
Joy_start() perfectly works
scroll() produce a "undefined reference to VDP_setHorizontalScroll()/VDP_setVerticalScroll()"
From what I understood, for scroll() to work, I must make reference somewhere (in my game) to vdp_bg.c/.h to game link to sgdk.vdp_bg and lib could so use sgdk.vdp_bg function.
I'm very poor on linking and library stuff so does someone could help me to find the right way to compile Lib.a or/and to link Link.a without undefined reference errors ?
thanks a lot !
Fighting with lib linking
Moderator: Stef
-
- Very interested
- Posts: 2984
- Joined: Fri Aug 17, 2007 9:33 pm
Gcc tries to minimize the code copied from objects/libraries by only linking in functions that have been used at the time the object/library is linked. So if an object/library is linked before an object/library that uses the object/library, the used functions will not have been copied and give errors. Always link objects/libraries after objects/libraries that use said objects/libraries. In a few rare cases, you might have to have a library in the link list twice - both before and after another object/library.
-
- Very interested
- Posts: 2984
- Joined: Fri Aug 17, 2007 9:33 pm
Very. I ran into that a few times on the PSP in particular. Something about some of the libraries on that meant you needed them linked in twice.KanedaFr wrote:Thanks for this
Crazy!In a few rare cases, you might have to have a library in the link list twice - both before and after another object/library.