undefined reference

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

undefined reference

8,783 次查看
stefan_ivanov
Contributor I

I am working with MCUXpresso IDE and a project for IMXRT1052B MCU.

After Build phase I am receiving many messages "undefined reference".

0 项奖励
回复
29 回复数

1,663 次查看
stefan_ivanov
Contributor I

I am using managed linker scripts.

0 项奖励
回复

1,663 次查看
lpcxpresso_supp
NXP Employee
NXP Employee

So if you need further help, please copy the text from the build console showing the original "undefined reference" error messages and paste / attach them here.

Regards,

MCUXpresso IDE Support

0 项奖励
回复

1,663 次查看
stefan_ivanov
Contributor I

In previous e-mail option is NewlibNano(none), and now the same is with option NewlibNano(nohost):

…………………………………………………………………………………………...

D:\Projects\IRIS_IMXRT1052B\Release/../LCD/Lcd_Rtc/lcd_RTC.cpp:119: undefined reference to `f_UnsignedShortToUniCode(unsigned short, unsigned short*, int, bool, unsigned char)'
D:\Projects\IRIS_IMXRT1052B\Release/../LCD/Lcd_Rtc/lcd_RTC.cpp:120: undefined reference to `strcat_safe(unsigned short*, int, unsigned short const*)'
D:\Projects\IRIS_IMXRT1052B\Release/../LCD/Lcd_Rtc/lcd_RTC.cpp:132: undefined reference to `strcpy_safe(unsigned short*, int, unsigned short const*)'
D:\Projects\IRIS_IMXRT1052B\Release/../LCD/Lcd_Rtc/lcd_RTC.cpp:136: undefined reference to `str_0_59'
D:\Projects\IRIS_IMXRT1052B\Release/../LCD/Lcd_Rtc/lcd_RTC.cpp:136: undefined reference to `LanguageStrings'
./LCD/Lcd_Rtc/lcd_RTC.o: In function `f_UpdateAll()':
D:\Projects\IRIS_IMXRT1052B\Release/../LCD/Lcd_Rtc/lcd_RTC.cpp:144: undefined reference to `strcpy_safe(unsigned short*, int, unsigned short const*)'
D:\Projects\IRIS_IMXRT1052B\Release/../LCD/Lcd_Rtc/lcd_RTC.cpp:145: undefined reference to `strcat_safe(unsigned short*, int, unsigned short const*)'
D:\Projects\IRIS_IMXRT1052B\Release/../LCD/Lcd_Rtc/lcd_RTC.cpp:147: undefined reference to `strcat_safe(unsigned short*, int, unsigned short const*)'
D:\Projects\IRIS_IMXRT1052B\Release/../LCD/Lcd_Rtc/lcd_RTC.cpp:148: undefined reference to `strcat_safe(unsigned short*, int, unsigned short const*)'
D:\Projects\IRIS_IMXRT1052B\Release/../LCD/Lcd_Rtc/lcd_RTC.cpp:150: undefined reference to `strcat_safe(unsigned short*, int, unsigned short const*)'
D:\Projects\IRIS_IMXRT1052B\Release/../LCD/Lcd_Rtc/lcd_RTC.cpp:151: undefined reference to `strcat_safe(unsigned short*, int, unsigned short const*)'
D:\Projects\IRIS_IMXRT1052B\Release/../LCD/Lcd_Rtc/lcd_RTC.cpp:154: undefined reference to `strcpy_safe(unsigned short*, int, unsigned short const*)'
D:\Projects\IRIS_IMXRT1052B\Release/../LCD/Lcd_Rtc/lcd_RTC.cpp:155: undefined reference to `strcat_safe(unsigned short*, int, unsigned short const*)'
D:\Projects\IRIS_IMXRT1052B\Release/../LCD/Lcd_Rtc/lcd_RTC.cpp:157: undefined reference to `strcat_safe(unsigned short*, int, unsigned short const*)'
D:\Projects\IRIS_IMXRT1052B\Release/../LCD/Lcd_Rtc/lcd_RTC.cpp:158: undefined reference to `strcat_safe(unsigned short*, int, unsigned short const*)'
D:\Projects\IRIS_IMXRT1052B\Release/../LCD/Lcd_Rtc/lcd_RTC.cpp:160: undefined reference to `f_UnsignedShortToUniCode(unsigned short, unsigned short*, int, bool, unsigned char)'
D:\Projects\IRIS_IMXRT1052B\Release/../LCD/Lcd_Rtc/lcd_RTC.cpp:161: undefined reference to `strcat_safe(unsigned short*, int, unsigned short const*)'
D:\Projects\IRIS_IMXRT1052B\Release/../LCD/Lcd_Rtc/lcd_RTC.cpp:167: undefined reference to `strcpy_safe(unsigned short*, int, unsigned short const*)'
D:\Projects\IRIS_IMXRT1052B\Release/../LCD/Lcd_Rtc/lcd_RTC.cpp:167: undefined reference to `LanguageStrings'
D:\Projects\IRIS_IMXRT1052B\Release/../LCD/Lcd_Rtc/lcd_RTC.cpp:167: undefined reference to `str_0_59'
./LCD/Lcd_Rtc/lcd_RTC.o: In function `f_InitTimeStrings()':
D:\Projects\IRIS_IMXRT1052B\Release/../LCD/Lcd_Rtc/lcd_RTC.cpp:178: undefined reference to `strcpy_safe(unsigned short*, int, unsigned short const*)'
D:\Projects\IRIS_IMXRT1052B\Release/../LCD/Lcd_Rtc/lcd_RTC.cpp:179: undefined reference to `strcat_safe(unsigned short*, int, unsigned short const*)'
D:\Projects\IRIS_IMXRT1052B\Release/../LCD/Lcd_Rtc/lcd_RTC.cpp:181: undefined reference to `strcat_safe(unsigned short*, int, unsigned short const*)'
D:\Projects\IRIS_IMXRT1052B\Release/../LCD/Lcd_Rtc/lcd_RTC.cpp:182: undefined reference to `strcat_safe(unsigned short*, int, unsigned short const*)'
D:\Projects\IRIS_IMXRT1052B\Release/../LCD/Lcd_Rtc/lcd_RTC.cpp:184: undefined reference to `strcat_safe(unsigned short*, int, unsigned short const*)'
D:\Projects\IRIS_IMXRT1052B\Release/../LCD/Lcd_Rtc/lcd_RTC.cpp:185: undefined reference to `strcat_safe(unsigned short*, int, unsigned short const*)'
D:\Projects\IRIS_IMXRT1052B\Release/../LCD/Lcd_Rtc/lcd_RTC.cpp:188: undefined reference to `strcpy_safe(unsigned short*, int, unsigned short const*)'
D:\Projects\IRIS_IMXRT1052B\Release/../LCD/Lcd_Rtc/lcd_RTC.cpp:189: undefined reference to `strcat_safe(unsigned short*, int, unsigned short const*)'
D:\Projects\IRIS_IMXRT1052B\Release/../LCD/Lcd_Rtc/lcd_RTC.cpp:191: undefined reference to `strcat_safe(unsigned short*, int, unsigned short const*)'
D:\Projects\IRIS_IMXRT1052B\Release/../LCD/Lcd_Rtc/lcd_RTC.cpp:192: undefined reference to `strcat_safe(unsigned short*, int, unsigned short const*)'
D:\Projects\IRIS_IMXRT1052B\Release/../LCD/Lcd_Rtc/lcd_RTC.cpp:194: undefined reference to `f_UnsignedShortToUniCode(unsigned short, unsigned short*, int, bool, unsigned char)'
D:\Projects\IRIS_IMXRT1052B\Release/../LCD/Lcd_Rtc/lcd_RTC.cpp:195: undefined reference to `strcat_safe(unsigned short*, int, unsigned short const*)'
D:\Projects\IRIS_IMXRT1052B\Release/../LCD/Lcd_Rtc/lcd_RTC.cpp:201: undefined reference to `LanguageStrings'
D:\Projects\IRIS_IMXRT1052B\Release/../LCD/Lcd_Rtc/lcd_RTC.cpp:201: undefined reference to `str_0_59'
D:\Projects\IRIS_IMXRT1052B\Release/../LCD/Lcd_Rtc/lcd_RTC.cpp:201: undefined reference to `strcpy_safe(unsigned short*, int, unsigned short const*)'
./LCD/Lcd_Icons/lcd_icons.o: In function `f_UpdateCounters(unsigned short)':
D:\Projects\IRIS_IMXRT1052B\Release/../LCD/Lcd_Icons/lcd_icons.cpp:152: undefined reference to `f_UnsignedShortToUniCode(unsigned short, unsigned short*, int, bool, unsigned char)'
D:\Projects\IRIS_IMXRT1052B\Release/../LCD/Lcd_Icons/lcd_icons.cpp:185: undefined reference to `f_UnsignedShortToUniCode(unsigned short, unsigned short*, int, bool, unsigned char)'
D:\Projects\IRIS_IMXRT1052B\Release/../LCD/Lcd_Icons/lcd_icons.cpp:218: undefined reference to `f_UnsignedShortToUniCode(unsigned short, unsigned short*, int, bool, unsigned char)'
./LCD/Lcd_Icons/lcd_icons.o: In function `f_UpdateInfoIcon_SND(unsigned short)':
D:\Projects\IRIS_IMXRT1052B\Release/../LCD/Lcd_Icons/lcd_icons.cpp:287: undefined reference to `f_UnsignedShortToUniCode(unsigned short, unsigned short*, int, bool, unsigned char)'
./LCD/Lcd_Icons/lcd_icons.o: In function `f_UpdateInfoIcon_FB(unsigned short)':
D:\Projects\IRIS_IMXRT1052B\Release/../LCD/Lcd_Icons/lcd_icons.cpp:365: undefined reference to `f_UnsignedShortToUniCode(unsigned short, unsigned short*, int, bool, unsigned char)'
./LCD/Lcd_Icons/lcd_icons.o:D:\Projects\IRIS_IMXRT1052B\Release/../LCD/Lcd_Icons/lcd_icons.cpp:441: more undefined references to `f_UnsignedShortToUniCode(unsigned short, unsigned short*, int, bool, unsigned char)' follow
collect2.exe: error: ld returned 1 exit status
        SRAM_DTC:          0 GB       128 KB      0.00%
make: *** [IRIS_IMXRT1052B.axf] Error 1
12:38:17 Build Finished (took 24s.590ms)
0 项奖励
回复

1,663 次查看
stefan_ivanov
Contributor I
Here they are so many messages:
…………………………………………………………………………………………………………………………………………
:\Projects\IRIS_IMXRT1052B\Release/../LCD/Lcd_Rtc/lcd_RTC.cpp:178: undefined reference to `strcpy_safe(unsigned short*, int, unsigned short const*)'
D:\Projects\IRIS_IMXRT1052B\Release/../LCD/Lcd_Rtc/lcd_RTC.cpp:179: undefined reference to `strcat_safe(unsigned short*, int, unsigned short const*)'
D:\Projects\IRIS_IMXRT1052B\Release/../LCD/Lcd_Rtc/lcd_RTC.cpp:181: undefined reference to `strcat_safe(unsigned short*, int, unsigned short const*)'
D:\Projects\IRIS_IMXRT1052B\Release/../LCD/Lcd_Rtc/lcd_RTC.cpp:182: undefined reference to `strcat_safe(unsigned short*, int, unsigned short const*)'
D:\Projects\IRIS_IMXRT1052B\Release/../LCD/Lcd_Rtc/lcd_RTC.cpp:184: undefined reference to `strcat_safe(unsigned short*, int, unsigned short const*)'
D:\Projects\IRIS_IMXRT1052B\Release/../LCD/Lcd_Rtc/lcd_RTC.cpp:185: undefined reference to `strcat_safe(unsigned short*, int, unsigned short const*)'
D:\Projects\IRIS_IMXRT1052B\Release/../LCD/Lcd_Rtc/lcd_RTC.cpp:188: undefined reference to `strcpy_safe(unsigned short*, int, unsigned short const*)'
D:\Projects\IRIS_IMXRT1052B\Release/../LCD/Lcd_Rtc/lcd_RTC.cpp:189: undefined reference to `strcat_safe(unsigned short*, int, unsigned short const*)'
D:\Projects\IRIS_IMXRT1052B\Release/../LCD/Lcd_Rtc/lcd_RTC.cpp:191: undefined reference to `strcat_safe(unsigned short*, int, unsigned short const*)'
D:\Projects\IRIS_IMXRT1052B\Release/../LCD/Lcd_Rtc/lcd_RTC.cpp:192: undefined reference to `strcat_safe(unsigned short*, int, unsigned short const*)'
D:\Projects\IRIS_IMXRT1052B\Release/../LCD/Lcd_Rtc/lcd_RTC.cpp:194: undefined reference to `f_UnsignedShortToUniCode(unsigned short, unsigned short*, int, bool, unsigned char)'
D:\Projects\IRIS_IMXRT1052B\Release/../LCD/Lcd_Rtc/lcd_RTC.cpp:195: undefined reference to `strcat_safe(unsigned short*, int, unsigned short const*)'
D:\Projects\IRIS_IMXRT1052B\Release/../LCD/Lcd_Rtc/lcd_RTC.cpp:201: undefined reference to `LanguageStrings'
D:\Projects\IRIS_IMXRT1052B\Release/../LCD/Lcd_Rtc/lcd_RTC.cpp:201: undefined reference to `str_0_59'
D:\Projects\IRIS_IMXRT1052B\Release/../LCD/Lcd_Rtc/lcd_RTC.cpp:201: undefined reference to `strcpy_safe(unsigned short*, int, unsigned short const*)'
./LCD/Lcd_Icons/lcd_icons.o: In function `f_UpdateCounters(unsigned short)':
D:\Projects\IRIS_IMXRT1052B\Release/../LCD/Lcd_Icons/lcd_icons.cpp:152: undefined reference to `f_UnsignedShortToUniCode(unsigned short, unsigned short*, int, bool, unsigned char)'
D:\Projects\IRIS_IMXRT1052B\Release/../LCD/Lcd_Icons/lcd_icons.cpp:185: undefined reference to `f_UnsignedShortToUniCode(unsigned short, unsigned short*, int, bool, unsigned char)'
D:\Projects\IRIS_IMXRT1052B\Release/../LCD/Lcd_Icons/lcd_icons.cpp:218: undefined reference to `f_UnsignedShortToUniCode(unsigned short, unsigned short*, int, bool, unsigned char)'
./LCD/Lcd_Icons/lcd_icons.o: In function `f_UpdateInfoIcon_SND(unsigned short)':
D:\Projects\IRIS_IMXRT1052B\Release/../LCD/Lcd_Icons/lcd_icons.cpp:287: undefined reference to `f_UnsignedShortToUniCode(unsigned short, unsigned short*, int, bool, unsigned char)'
./LCD/Lcd_Icons/lcd_icons.o: In function `f_UpdateInfoIcon_FB(unsigned short)':
D:\Projects\IRIS_IMXRT1052B\Release/../LCD/Lcd_Icons/lcd_icons.cpp:365: undefined reference to `f_UnsignedShortToUniCode(unsigned short, unsigned short*, int, bool, unsigned char)'
./LCD/Lcd_Icons/lcd_icons.o:D:\Projects\IRIS_IMXRT1052B\Release/../LCD/Lcd_Icons/lcd_icons.cpp:441: more undefined references to `f_UnsignedShortToUniCode(unsigned short, unsigned short*, int, bool, unsigned char)' follow
c:/nxp/mcuxpressoide_10.2.0_759/ide/tools/bin/../lib/gcc/arm-none-eabi/7.2.1/../../../../arm-none-eabi/lib/thumb/v7e-m/fpv4-sp/hard\libc_nano.a(lib_a-signalr.o): In function `_kill_r':
signalr.c:(.text._kill_r+0xe): undefined reference to `_kill'
c:/nxp/mcuxpressoide_10.2.0_759/ide/tools/bin/../lib/gcc/arm-none-eabi/7.2.1/../../../../arm-none-eabi/lib/thumb/v7e-m/fpv4-sp/hard\libc_nano.a(lib_a-signalr.o): In function `_getpid_r':
signalr.c:(.text._getpid_r+0x0): undefined reference to `_getpid'
c:/nxp/mcuxpressoide_10.2.0_759/ide/tools/bin/../lib/gcc/arm-none-eabi/7.2.1/../../../../arm-none-eabi/lib/thumb/v7e-m/fpv4-sp/hard\libc_nano.a(lib_a-writer.o): In function `_write_r':
writer.c:(.text._write_r+0x10): undefined reference to `_write'
c:/nxp/mcuxpressoide_10.2.0_759/ide/tools/bin/../lib/gcc/arm-none-eabi/7.2.1/../../../../arm-none-eabi/lib/thumb/v7e-m/fpv4-sp/hard\libc_nano.a(lib_a-closer.o): In function `_close_r':
closer.c:(.text._close_r+0xc): undefined reference to `_close'
c:/nxp/mcuxpressoide_10.2.0_759/ide/tools/bin/../lib/gcc/arm-none-eabi/7.2.1/../../../../arm-none-eabi/lib/thumb/v7e-m/fpv4-sp/hard\libc_nano.a(lib_a-lseekr.o): In function `_lseek_r':
lseekr.c:(.text._lseek_r+0x10): undefined reference to `_lseek'
c:/nxp/mcuxpressoide_10.2.0_759/ide/tools/bin/../lib/gcc/arm-none-eabi/7.2.1/../../../../arm-none-eabi/lib/thumb/v7e-m/fpv4-sp/hard\libc_nano.a(lib_a-readr.o): In function `_read_r':
readr.c:(.text._read_r+0x10): undefined reference to `_read'
c:/nxp/mcuxpressoide_10.2.0_759/ide/tools/bin/../lib/gcc/arm-none-eabi/7.2.1/../../../../arm-none-eabi/lib/thumb/v7e-m/fpv4-sp/hard\libc_nano.a(lib_a-fstatr.o): In function `_fstat_r':
fstatr.c:(.text._fstat_r+0xe): undefined reference to `_fstat'
c:/nxp/mcuxpressoide_10.2.0_759/ide/tools/bin/../lib/gcc/arm-none-eabi/7.2.1/../../../../arm-none-eabi/lib/thumb/v7e-m/fpv4-sp/hard\libc_nano.a(lib_a-isattyr.o): In function `_isatty_r':
isattyr.c:(.text._isatty_r+0xc): undefined reference to `_isatty'
c:/nxp/mcuxpressoide_10.2.0_759/ide/tools/bin/../lib/gcc/arm-none-eabi/7.2.1/../../../../arm-none-eabi/lib/thumb/v7e-m/fpv4-sp/hard\libc_nano.a(lib_a-abort.o): In function `abort':
abort.c:(.text.abort+0xa): undefined reference to `_exit'
collect2.exe: error: ld returned 1 exit status
        SRAM_DTC:          0 GB       128 KB      0.00%
make: *** [IRIS_IMXRT1052B.axf] Error 1
12:46:04 Build Finished (took 4s.687ms)
0 项奖励
回复

1,663 次查看
lpcxpresso_supp
NXP Employee
NXP Employee

Why are you trying to specify the -specs option? There should be no need to do this. MCUXpresso IDE will generally handle C library linkage automatically, based on the selected C library settings (in the Managed Linker Script page of the Linker Settings).

Anyway, the following LPCXpresso IDE FAQ may give you some clues as to the cause of your original error:

https://community.nxp.com/message/630711 

But if not please post the original "undefined reference" message in full.

Regards,

MCUXpresso IDE Support.

0 项奖励
回复

1,663 次查看
stefan_ivanov
Contributor I

Hi,

I am working with MCUXpresso IDE and a project for IMXRT1052B MCU.

I am using C++ default and C default compilers. I've been tried al combinations

of Newlib, NewlibNano. Also tried extern "C",...and so on and:

After Build phase I am receiving many messages "undefined reference".

Only I've after used --specs=nosys.specs there are no usch messages,

but there are unrecognized option --specs=nosys.specs which you may

see above.

Regards,

Stefan 

0 项奖励
回复

1,663 次查看
BlackNight
NXP Employee
NXP Employee

Hi Stefan,

it would be helpful if you could share some details? What project you are using, what error messages, etc.

Best if you could post your project.

Erich

0 项奖励
回复

1,663 次查看
stefan_ivanov
Contributor I

Hi Erich,

Thank you for your answer.

I've added 'specs=nosys.specs'

The result is:

…………………………………………………………

Building target: IRIS_IMXRT1052B.axf

Invoking: MCU C++ Linker

…………………………………………………………..

c:/nxp/mcuxpressoide_10.2.0_759/ide/tools/bin/../lib/gcc/arm-none-eabi/7.2.1/../../../../arm-none-eabi/bin/ld.exe: unrecognized option '--specs=nosys.specs'
c:/nxp/mcuxpressoide_10.2.0_759/ide/tools/bin/../lib/gcc/arm-none-eabi/7.2.1/../../../../arm-none-eabi/bin/ld.exe: use the --help option for usage information
collect2.exe: error: ld returned 1 exit status
make: *** [IRIS_IMXRT1052B.axf] Error 1

Thank you in advance !

Regards,

Stefan

0 项奖励
回复

1,663 次查看
stefan_ivanov
Contributor I

Hi Erich,

Thank you for your answer.

I've added 'specs=nosys.specs' but it is received:

Building target: IRIS_IMXRT1052B.axf
Invoking: MCU C++ Linker

……………………………………………………………...

c:/nxp/mcuxpressoide_10.2.0_759/ide/tools/bin/../lib/gcc/arm-none-eabi/7.2.1/../../../../arm-none-eabi/bin/ld.exe: unrecognized option '--specs=nosys.specs'
c:/nxp/mcuxpressoide_10.2.0_759/ide/tools/bin/../lib/gcc/arm-none-eabi/7.2.1/../../../../arm-none-eabi/bin/ld.exe: use the --help option for usage information

Regards,

Stefan

0 项奖励
回复