Steve Visser Messages: 2 Registered: February 2012
Junior Member
Hi,
This seems like a simple problem, but after trying for 2 days I still can't seem to get this to work, so any help will be greatly appreciated!
I am using codesourcery to program stellaris uc's and I cannot seem to build any projects that link with static libraries that are more than one library deep.
To try and solve the problem I have re-created my scenario in it's simplest form.
I have created a static library "AAASubLibrary". In this library is a source and header file with only one function "subLibInc()" which increments an integer.
I have created another static library "AAMainLibrary". In this library is a source and header file with only one function "mainLibInc()" which increments an integer by calling subLibInc.
Finally I have created a main program in a project called AAMainProgram. The program is a infinite loop that increments a number by calling mainLibInc();
I can build the AAASublibrary Project and the AAMainLibrary projects with no errors.
But if I call mainLibInc(); in the main program then I get a linker error.
'Building target: AAMainProgram'
'Invoking: Sourcery CodeBench C Linker'
arm-stellaris-eabi-gcc -L"C:\Users\Stevo\workspace\AAASubLibrary\Debug" -L"C:\Users\Stevo\workspace\AAMainLibrary\Debug" -Xlinker -Map="AAMainProgram.map" -T lm3s9b92-ram-hosted.ld -o "AAMainProgram" "@objs.rsp" "@user_objs.rsp" "@libs.rsp"
C:\Users\Stevo\workspace\AAMainLibrary\Debug\libAAMainLibrary.a(AAMainLibrary.o): In function `mainLibInc':
C:\Users\Stevo\workspace\AAMainLibrary\Debug/../AAMainLibrary/AAMainLibrary.c:13: undefined reference to `subLibInc'
collect2: ld returned 1 exit status
cs-make: *** [AAMainProgram] Error 1
what's wierd for me is if I replace mainLibInc(); in the main program with subLibInc(); then everything compiles fine.
Attached is a screen shot showing the results from my build.
Also attached are the source and headerfiles.
Any tips on how I can get the linker to see the sublibrary?