Linker can't find libs when it seems like they are specified properly...

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Linker can't find libs when it seems like they are specified properly...

Jump to solution
2,336 Views
dave408
Senior Contributor II

I've been jumping lots of hurdles lately when trying to get a new project off of the ground using KDS 2.0.0 and KSDK 1.1.0.  The current project I am working on involved building something like the httpsrv example from scratch, because the current demo included in KSDK 1.1.0 does not provide G++ tool settings.

 

I have been slowly working through all of the configuration errors that come up along the way, and I think I'm in the home stretch.  However, I'm getting an annoying linker error that I have so far been unable to resolve.

 

When I build, here's the output:

 

14:28:19 **** Incremental Build of configuration Debug for project InstrumentController ****

make all

'Building target: InstrumentController.elf'

'Invoking: Cross ARM C++ Linker'

arm-none-eabi-g++ -mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16 -O0 -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections  -g3 -T "MK64FN1M0xxx12_flash.ld" -Xlinker --gc-sections -L"C:/Code/trunk/embedded/gcs4000/InstrumentController\Project_Settings\Linker_Files" -L"C:\Freescale\KSDK_1.1.0\rtos\mqx\lib\frdmk64f.kds\debug\mqx_stdlib" -L"C:\Freescale\KSDK_1.1.0\rtos\mqx\lib\frdmk64f.kds\debug\mqx" -L"C:\Freescale\KSDK_1.1.0\rtos\mqx\lib\frdmk64f.kds\debug\nshell" -L"C:\Freescale\KSDK_1.1.0\tcpip\rtcs\lib\frdmk64f.kds\debug\rtcs" -L"C:\Freescale\KSDK_1.1.0\lib\ksdk_mqx_lib\kds\K64F12\Debug" -Wl,-Map,"InstrumentController.map" -nanolibc -o "InstrumentController.elf"  ./frdmk64f/gpio_pins.o ./frdmk64f/hardware_init.o ./frdmk64f/pin_mux.o  ./Sources/I2C_Files/BlinkmTest_task.o ./Sources/I2C_Files/I2CKds.o ./Sources/I2C_Files/I2cManager.o ./Sources/I2C_Files/fsl_debug_console.o ./Sources/I2C_Files/fsl_misc_utilities.o ./Sources/I2C_Files/print_scan.o  ./Sources/app_mqx.o ./Sources/cgi.o ./Sources/example_plugins.o ./Sources/httpsrv_main.o ./Sources/nio_tfs_data.o  ./Project_Settings/Startup_Code/startup.o ./Project_Settings/Startup_Code/startup_MK64F12.o ./Project_Settings/Startup_Code/system_MK64F12.o  ./BSP_Files/init_bsp.o ./BSP_Files/mqx_main.o   -llib_mqx_stdlib.a -llibksdk_platform_mqx.a -llib_rtcs.a -llib_nshell.a -llib_mqx.a

c:/freescale/kds_2.0.0/toolchain/bin/../lib/gcc/arm-none-eabi/4.8.0/../../../../arm-none-eabi/bin/ld.exe: cannot find -llib_mqx_stdlib.a

c:/freescale/kds_2.0.0/toolchain/bin/../lib/gcc/arm-none-eabi/4.8.0/../../../../arm-none-eabi/bin/ld.exe: cannot find -llibksdk_platform_mqx.a

c:/freescale/kds_2.0.0/toolchain/bin/../lib/gcc/arm-none-eabi/4.8.0/../../../../arm-none-eabi/bin/ld.exe: cannot find -llib_rtcs.a

c:/freescale/kds_2.0.0/toolchain/bin/../lib/gcc/arm-none-eabi/4.8.0/../../../../arm-none-eabi/bin/ld.exe: cannot find -llib_nshell.a

c:/freescale/kds_2.0.0/toolchain/bin/../lib/gcc/arm-none-eabi/4.8.0/../../../../arm-none-eabi/bin/ld.exe: cannot find -llib_mqx.a

collect2.exe: error: ld returned 1 exit status

make: *** [InstrumentController.elf] Error 1

 

14:28:20 Build Finished (took 532ms)

 

As you can see, I specify the library paths with the -L arguments (green), and the libraries themselves with the -l arguments (blue).

 

Can anyone tell me what I'm doing wrong here?  It seems like I'm doing everything properly.

 

Thanks!

Labels (1)
Tags (3)
1 Solution
1,927 Views
dave408
Senior Contributor II

I figured out the problem, but I can't believe this is the reason -- hopefully, someone here can shed some light on this.

It turns out that the way I specified the libraries in Tool Settings was incorrect.  I wanted to add the following libraries, as you could see from my original post:

lib_mqx_stdlib.a

libksdk_platform_mqx.a

lib_rtcs.a

lib_nshell.a

lib_mqx.a

I ended up using processmon to figure out what ld.exe was doing, and I found that it was prepending "lib" and appending ".a" to every filename.  I ended up fixing the problem by changing the specified filenames to:

_mqx_stdlib

ksdk_platform_mqx

_rtcs

_nshell

_mqx

After this, it worked!  Now I have other errors, but that's for another question down the road if I can't figure it out on my own.  Hopefully, this helped someone else out there that might run into the same problem.  I'd like to know if this is "by design" or if this is some weird KDS/GCC bug.

View solution in original post

0 Kudos
2 Replies
1,928 Views
dave408
Senior Contributor II

I figured out the problem, but I can't believe this is the reason -- hopefully, someone here can shed some light on this.

It turns out that the way I specified the libraries in Tool Settings was incorrect.  I wanted to add the following libraries, as you could see from my original post:

lib_mqx_stdlib.a

libksdk_platform_mqx.a

lib_rtcs.a

lib_nshell.a

lib_mqx.a

I ended up using processmon to figure out what ld.exe was doing, and I found that it was prepending "lib" and appending ".a" to every filename.  I ended up fixing the problem by changing the specified filenames to:

_mqx_stdlib

ksdk_platform_mqx

_rtcs

_nshell

_mqx

After this, it worked!  Now I have other errors, but that's for another question down the road if I can't figure it out on my own.  Hopefully, this helped someone else out there that might run into the same problem.  I'd like to know if this is "by design" or if this is some weird KDS/GCC bug.

0 Kudos
1,927 Views
dave408
Senior Contributor II

Umm... ok, it's by design.

Options that control libraries

   -lx This option tells the linker to search for libx.dylib or libx.a in the library

search path. If string x is of the form y.o, then that file is searched for in

the same places, but without prepending `lib' or appending `.a' or `.dylib' to

the filename.

0 Kudos