Linker creates incorrect order of commands to link library

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

I am using the Project/Build Settings dialog to try to add an additional library to my project.  Using the "Additional Libraries" and the "Additional Libraries Directories" tabs does add the items to the linker command but since the directories is added after the library is added it appears as though the library can't be found.  The linker command becomes:

   

-mcpu=cortex-m0 -mthumb -g -ffunction-sections -O0 -l m -l ..\..\..\Documents\MotionDriver\Arm_Source\libmplmpu -L Generated_Source\PSoC4 -L ..\..\..\Documents\MotionDriver\MPL_Libraries -Wl,-Map,${OutputDir}/${ProjectShortName}.map -T Generated_Source\PSoC4\cm0gcc.ld -specs=nano.specs -Wl,--gc-sections

   

​But seemingly:  -l ..\..\..\Documents\MotionDriver\Arm_Source\libmplmpu

   

isn't found because the directory to look in: -L Generated_Source\PSoC4 -L ..\..\..\Documents\MotionDriver\MPL_Libraries

   

hasn't been added to the path yet.  That's speculation on my part and I'd welcome any feedback on how to accomplish this.  The error that is thrown looks like:

   

arm-none-eabi-ar.exe: creating .\CortexM0\ARM_GCC_493\Debug\PSoC_4_BLE_MPU_9150.a

   

arm-none-eabi-gcc.exe -Wl,--start-group -o .\CortexM0\ARM_GCC_493\Debug\PSoC_4_BLE_MPU_9150.elf .\CortexM0\ARM_GCC_493\Debug\data_builder.o .\CortexM0\ARM_GCC_493\Debug\eMPL_outputs.o .\CortexM0\ARM_GCC_493\Debug\hal_outputs.o .\CortexM0\ARM_GCC_493\Debug\inv_mpu.o .\CortexM0\ARM_GCC_493\Debug\inv_mpu_dmp_motion_driver.o .\CortexM0\ARM_GCC_493\Debug\log_stm32.o .\CortexM0\ARM_GCC_493\Debug\message_layer.o .\CortexM0\ARM_GCC_493\Debug\ml_math_func.o .\CortexM0\ARM_GCC_493\Debug\mlmath.o .\CortexM0\ARM_GCC_493\Debug\mpl.o .\CortexM0\ARM_GCC_493\Debug\results_holder.o .\CortexM0\ARM_GCC_493\Debug\start_manager.o .\CortexM0\ARM_GCC_493\Debug\storage_manager.o .\CortexM0\ARM_GCC_493\Debug\uart.o .\CortexM0\ARM_GCC_493\Debug\mpu9150.o .\CortexM0\ARM_GCC_493\Debug\BLEApplication.o .\CortexM0\ARM_GCC_493\Debug\main_original.o .\CortexM0\ARM_GCC_493\Debug\motion_driver_main.o .\CortexM0\ARM_GCC_493\Debug\cymetadata.o .\CortexM0\ARM_GCC_493\Debug\Cm0Start.o .\CortexM0\ARM_GCC_493\Debug\PSoC_4_BLE_MPU_9150.a "C:\Program Files (x86)\Cypress\PSoC Creator\3.3\PSoC Creator\psoc\content\cycomponentlibrary\CyComponentLibrary.cylib\BLE_v1_10\Library\gccCyBLEStack_BLE_SOC_PERIPHERAL.a" "C:\Program Files (x86)\Cypress\PSoC Creator\3.3\PSoC Creator\psoc\content\cycomponentlibrary\CyComponentLibrary.cylib\CortexM0\ARM_GCC_493\Debug\CyComponentLibrary.a" -mcpu=cortex-m0 -mthumb -g -ffunction-sections -O0 -l m -l C:\Users\raypa\Documents\MotionDriver\Arm_Source\liblibmplmpu.a -L Generated_Source\PSoC4 -Wl,-Map,.\CortexM0\ARM_GCC_493\Debug/PSoC_4_BLE_MPU_9150.map -T Generated_Source\PSoC4\cm0gcc.ld -specs=nano.specs -Wl,--gc-sections -Wl,--end-group

   

ERROR: cannot find -lC:\Users\raypa\Documents\MotionDriver\Arm_Source\liblibmplmpu.a

   

collect2.exe: error: ld returned 1 exit status

   

The command 'arm-none-eabi-gcc.exe' failed with exit code '1'.

0 Likes
1 Solution
ScottA_91
Employee
Employee
10 solutions authored 100 replies posted 50 replies posted

Ray,

   

Would you please post a simple example (including the libraries) so I can attempt to reproduce the behavior?

   

Scott

View solution in original post

0 Likes
10 Replies
Anonymous
Not applicable

I'm wondering if I could get around this by placing my library file in the same directory as the libm.a file that is linked properly (I assume due to some default path).  Any idea where that is on a PSOC installation?

0 Likes
ScottA_91
Employee
Employee
10 solutions authored 100 replies posted 50 replies posted

Ray,

   

Would you please post a simple example (including the libraries) so I can attempt to reproduce the behavior?

   

Scott

0 Likes
Anonymous
Not applicable

Scott,  Thanks for the reply.  I believe I have resolved this.  I needed to add the include path also.  In my defense I would have thought the -l and -L commands should have sufficed 🙂

Anonymous
Not applicable

@ray.parker_1412866 can you please explain, how you made it work? 
I'm facing a similar problem. 
Build error: cannot find -l.\libEZPSoC5.a

   

   

 

   

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Welcome in the forum!

   

Afaik libraries have to be named yourlibrarilib.a in the dialog you only need to enter "yourlibrary"

   

as an example: to include mlib.a (the math library) you enter just "m".

   

 

   

Bob

0 Likes
Anonymous
Not applicable

thank you bob. i had a similar problem. "libyourlibrary.a" should have been "yourlibrary"

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Welcome in the forum.

   

Oh yes, can it be that the "lib" is preceded and not trailing.

   

 

   

Bob

0 Likes
Anonymous
Not applicable

Hi, I'm facing the same problem. How do I solve this? I have tried removing the .a and lib extensions to no avail

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Welcome in the forum, Jack.

   

What do you set exactly where (in which dialog?)

   

 

   

Bob

0 Likes
Anonymous
Not applicable

Im facing the same problem...Ok i get you must remove the lib and the .a but do i have to remove it directly from the file name too???

0 Likes