UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Contributor
Contributor
209 Views
Registered: ‎10-16-2018

Undefined Refernce to a function

Hi,

I tried to solve this error in my project: 

undefined reference to `DA3_WriteSPI' testperiph.c

I found a simlir topic here. But the solution it is not very clear to me. I tried to reflect the solution to my case with many possiblites, but no way.

It seems a common issue, that always happens even in other SDKs. 

Here is my Console output:

 

make all
'Building target: FH_TX_2.elf'
'Invoking: MicroBlaze gcc linker'
mb-gcc -L"D:\Users\dell\Vivado_projects\FHSS_Transmitter_2\FHSS_Transmitter_2.sdk\FH_TX_2_bsp\microblaze_0\libsrc" -Wl,-T -Wl,../src/lscript.ld -L"D:\Users\dell\Vivado_projects\FHSS_Transmitter_2\FHSS_Transmitter_2.sdk\FH_TX_2_bsp\microblaze_0\lib" -mlittle-endian -mcpu=v10.0 -mxl-soft-mul -Wl,--no-relax -Wl,--gc-sections -o "FH_TX_2.elf" ./src/testperiph.o ./src/xiomodule_selftest_example.o -Wl,--start-group,-lxil,-lgcc,-lc,--end-group
./src/testperiph.o: In function `main':
D:\Users\dell\Vivado_projects\FHSS_Transmitter_2\FHSS_Transmitter_2.sdk\FH_TX_2\Debug/../src/testperiph.c:68: undefined reference to `DA3_WriteSPI'
collect2.exe: error: ld returned 1 exit status
make: *** [FH_TX_2.elf] Error 1

02:02:39 Build Finished (took 284ms)

__________________________________________________________

I am looking forward your help,

Thanks in advance.

0 Kudos
5 Replies
Highlighted
Scholar watari
Scholar
187 Views
Registered: ‎06-16-2013

Re: Undefined Refernce to a function

Hi @ahmed_alfadhel

 

It seems linker issue.

Because linker, a part of gcc's compile flow tool, can't find "DA3_WriteSPI" function.

So, as you mentioned a similr topic, you need to add -l option and suitable library name.

 

Would you try it ?

 

Best regards,

 

Contributor
Contributor
165 Views
Registered: ‎10-16-2018

Re: Undefined Refernce to a function

Hi @watari ,

I added "-lPmodDA3" where PmodDA3 is a library (Header file), but another error existed :  cannot find -lPmodDA3

Here is my Consol output:

make all
'Building target: FH_TX_2.elf'
'Invoking: MicroBlaze gcc linker'
mb-gcc -L"D:\Users\dell\Vivado_projects\FHSS_Transmitter_2\FHSS_Transmitter_2.sdk\FH_TX_2_bsp\microblaze_0\libsrc" -Wl,-T -Wl,../src/lscript.ld -L"D:\Users\dell\Vivado_projects\FHSS_Transmitter_2\FHSS_Transmitter_2.sdk\FH_TX_2_bsp\microblaze_0\lib" -mlittle-endian -mcpu=v10.0 -mxl-soft-mul -Wl,--no-relax -Wl,--gc-sections -o "FH_TX_2.elf" ./src/testperiph.o ./src/xiomodule_selftest_example.o -Wl,--start-group,-lxil,-lgcc,-lc,--end-group -Wl,--start-group,-lPmodDA3,-lxil,-lgcc,-lc,--end-group
d:/xilinx/sdk/2018.2/gnu/microblaze/nt/bin/../lib/gcc/microblaze-xilinx-elf/7.2.0/../../../../microblaze-xilinx-elf/bin/ld.exe: cannot find -lPmodDA3
collect2.exe: error: ld returned 1 exit status
make: *** [FH_TX_2.elf] Error 1

__________________________________________________________________

Thanks in advance.

0 Kudos
Moderator
Moderator
115 Views
Registered: ‎10-06-2016

Re: Undefined Refernce to a function

Hi @ahmed_alfadhel

Are you sure the PmodDA3 is the library? I mean a header file is not a library per se, the header files are used to expose the library functions and variables to the application. Where is the library compiled? usually it should be in the BSP side and you should have a static library (<libraryname>.a) or a dynamic library (<libraryname>.so) file somewhere. You need to point the library name with -l option to the linker and also the location where it can find for libraries with -L option.

Regards


Ibai
Don’t forget to reply, kudo, and accept as solution.
Contributor
Contributor
94 Views
Registered: ‎10-16-2018

Re: Undefined Refernce to a function

Hi @ibaie , 

 PmodDA3.c is the required libaray, and its locatoin is :

 D:\Users\dell\Vivado_projects\FHSS_Transmitter_2\FHSS_Transmitter_2.sdk\FH_TX_2_bsp\microblaze_0\libsrc\PmodDA3_v1_0\src

But I don't have each of a static library (<libraryname>.a) or a dynamic library (<libraryname>.so) ! And I don't know what they are ?

I am looking forward your supports .

Thanks.

0 Kudos
Contributor
Contributor
86 Views
Registered: ‎10-16-2018

Re: Undefined Refernce to a function

 
5.jpg
0 Kudos