Refresh SDK Components breaks SDK Example - "undefined reference to 'main' "

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

Refresh SDK Components breaks SDK Example - "undefined reference to 'main' "

跳至解决方案
1,077 次查看
SynchroEng
Contributor II

Hello,

I have a problem refreshing SDK components with LWIP - MQTT SDK example project.

Using the LPCXpresso54628 development board, I import the SDK example project: "lpcxpresso54628_lwip_mqtt_freertos".
Installed the latest MCUXpresso 11.6.1 IDE and 2.12.0 SDK for LPCXpresso54628. 

I right click project -> SDK Management -> Refresh SDK Components -> OK.

I keep the default FreeRTOS configuration with memory management option 3.
I fix the "heap_3.c" source file to be included in the build and delete the rest of the "heap_x.c" files.

After building the project I get the error:

c:/nxp/mcuxpressoide_11.6.1_8255/ide/plugins/com.nxp.mcuxpresso.tools.win32_11.6.1.202207200623/tools/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld.exe: c:/nxp/mcuxpressoide_11.6.1_8255/ide/plugins/com.nxp.mcuxpresso.tools.win32_11.6.1.202207200623/tools/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-noneeabi/lib/thumb/v7em+fp
/hard\libcr_nohost_nf.a(_cr__main.o): in function `__main':
_cr__main.c:(.text.__main+0xa): undefined reference to `main'


Memory region Used Size Region Size %age Used
PROGRAM_FLASH: 10120 B 512 KB 1.93%
BOARD_FLASH: 0 GB 16 MB 0.00%
SRAM_UPPER: 27308 B 160 KB 16.67%
SRAMX: 0 GB 32 KB 0.00%
USB_RAM: 0 GB 8 KB 0.00%
BOARD_SDRAM: 0 GB 16 MB 0.00%


collect2.exe: error: ld returned 1 exit status
make[1]: *** [makefile:69: lpcxpresso54628_lwip_mqtt_freertos.axf] Error 1
make: *** [makefile:60: all] Error 2
"make -r -j12 all" terminated with exit code 2. Build might be incomplete.

09:45:54 Build Failed. 4 errors, 0 warnings. (took 5s.536ms)

This can be reproduced with the above minimal steps 

I cannot seem to find any outstanding issues in the code itself, I've gone through comparing the libraries and source files to catch any differences but they are the same.

What could be the issue? Any help would be much appreciated!


Regards,

Adam

 

0 项奖励
回复
1 解答
1,067 次查看
SynchroEng
Contributor II

Hi Erich,

The source folders are all blue, no change there.

After more investigation I found the solution. In the beginning of the main source file there is a pre-compile condition:

#include "lwip/opt.h"

#if LWIP_IPV4 && LWIP_RAW && LWIP_NETCONN && LWIP_DHCP && LWIP_DNS
...
Entire example program
...

#endif

LWIP_RAW and LWIP_DNS are both defined as 0 after refreshing the SDK.
This means my entire main source file is ignored and greyed out.
I had to re-build the index in order to catch this. 

In the original working example (before refreshing SDK) these are defined in "...source/lwipopts.h" as '1'.
After refreshing the SDK, these are defined in "lwip/opt.h" as '0' and "lwipopts.h" doesn't override them.

Further investigating project properties->Build Settings->Includes, the list of include paths was re-organized during the Refresh SDK step.

The solution was that I moved "...\source" folder (containing "lwipopts.h") up on the list. This will override the default definition in "lwip/opt.h":

#if !defined LWIP_RAW || defined __DOXYGEN__
#define LWIP_RAW 0
#endif

with: 

/* ---------- RAW options ---------- */
#if !defined LWIP_RAW
#define LWIP_RAW 1
#endif

in "lwipopts.h

This was rather annoying as I have no idea why Refreshing the SDK would mess up the include paths order...

I hope this helps someone out because the solution might seem trivial but it took about 3hrs of looking, updating IDE/SDK, head scratching, going back and forth reproducing..

 

More information about this bug in a new discussion here.

 


Regards,

Adam



在原帖中查看解决方案

2 回复数
1,070 次查看
ErichStyger
Specialist I

Hi Adam,

can you check if your source folders are not excluded from the build?

They should have a 'blue C' like the ones below:

ErichStyger_0-1669044559180.png

 

I hope this helps,

Erich

0 项奖励
回复
1,068 次查看
SynchroEng
Contributor II

Hi Erich,

The source folders are all blue, no change there.

After more investigation I found the solution. In the beginning of the main source file there is a pre-compile condition:

#include "lwip/opt.h"

#if LWIP_IPV4 && LWIP_RAW && LWIP_NETCONN && LWIP_DHCP && LWIP_DNS
...
Entire example program
...

#endif

LWIP_RAW and LWIP_DNS are both defined as 0 after refreshing the SDK.
This means my entire main source file is ignored and greyed out.
I had to re-build the index in order to catch this. 

In the original working example (before refreshing SDK) these are defined in "...source/lwipopts.h" as '1'.
After refreshing the SDK, these are defined in "lwip/opt.h" as '0' and "lwipopts.h" doesn't override them.

Further investigating project properties->Build Settings->Includes, the list of include paths was re-organized during the Refresh SDK step.

The solution was that I moved "...\source" folder (containing "lwipopts.h") up on the list. This will override the default definition in "lwip/opt.h":

#if !defined LWIP_RAW || defined __DOXYGEN__
#define LWIP_RAW 0
#endif

with: 

/* ---------- RAW options ---------- */
#if !defined LWIP_RAW
#define LWIP_RAW 1
#endif

in "lwipopts.h

This was rather annoying as I have no idea why Refreshing the SDK would mess up the include paths order...

I hope this helps someone out because the solution might seem trivial but it took about 3hrs of looking, updating IDE/SDK, head scratching, going back and forth reproducing..

 

More information about this bug in a new discussion here.

 


Regards,

Adam