Getting compilation error on Visual studio22 for my application using the Freertosv202112.00

I am using Freertosv202112.00. I tried to build the source(.c file) files along with headers and created the library(.lib). But while building my freertos application using the library, I am getting the compilation error as

1>freertos_lib.lib(queue.obj) : error LNK2001: unresolved external symbol _vPortFree
1>freertos_lib.lib(timers.obj) : error LNK2001: unresolved external symbol _vPortFree
1>cross_os.lib(os_deallocate_memory.obj) : error LNK2001: unresolved external symbol _vPortFree
1>cross_os.lib(os_delete_memory_pool.obj) : error LNK2001: unresolved external symbol _vPortFree
1>freertos_lib.lib(tasks.obj) : error LNK2001: unresolved external symbol _vPortFree
1>freertos_lib.lib(event_groups.obj) : error LNK2001: unresolved external symbol _vPortFree
1>freertos_lib.lib(queue.obj) : error LNK2001: unresolved external symbol _pvPortMalloc
1>freertos_lib.lib(timers.obj) : error LNK2001: unresolved external symbol _pvPortMalloc
1>cross_os.lib(os_allocate_memory.obj) : error LNK2001: unresolved external symbol _pvPortMalloc
1>cross_os.lib(int_os_config_allocate_system_config.obj) : error LNK2001: unresolved external symbol _pvPortMalloc
1>freertos_lib.lib(tasks.obj) : error LNK2001: unresolved external symbol _pvPortMalloc
1>freertos_lib.lib(event_groups.obj) : error LNK2001: unresolved external symbol _pvPortMalloc
1>MSVCRTD.lib(exe_main.obj) : error LNK2019: unresolved external symbol _main referenced in function "int __cdecl invoke_main(void)" (?invoke_main@@YAHXZ)
1>freertos_lib.lib(timers.obj) : error LNK2001: unresolved external symbol _vAssertCalled
1>freertos_lib.lib(tasks.obj) : error LNK2001: unresolved external symbol _vAssertCalled
1>freertos_lib.lib(port.obj) : error LNK2001: unresolved external symbol _vAssertCalled
1>freertos_lib.lib(event_groups.obj) : error LNK2001: unresolved external symbol _vAssertCalled
1>freertos_lib.lib(queue.obj) : error LNK2001: unresolved external symbol _vAssertCalled
1>freertos_lib.lib(tasks.obj) : error LNK2019: unresolved external symbol _ulGetRunTimeCounterValue referenced in function _uxTaskGetSystemState
1>freertos_lib.lib(tasks.obj) : error LNK2019: unresolved external symbol _vConfigureTimerForRunTimeStats referenced in function _vTaskStartScheduler
1>freertos_lib.lib(tasks.obj) : error LNK2019: unresolved external symbol _vApplicationGetIdleTaskMemory referenced in function _vTaskStartScheduler
1>freertos_lib.lib(timers.obj) : error LNK2019: unresolved external symbol _vApplicationGetTimerTaskMemory referenced in function _xTimerCreateTimerTask
1>D:\validation_freertos\demo_cross_os\specific\windows\x86\vsnet2015\Debug\demo_cross_os.exe : fatal error LNK1120: 8 unresolved externals
1>Done building project "windows_x86_vsnet2015_demo_cross_os.vcxproj" -- FAILED.
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
========== Elapsed 00:14.285 ==========

I need a demo application on MSVC which can take the use of freertos lib(lib created from these Freertosv202112.00 source files).

error LNK2001: unresolved external symbol _vPortFree
error LNK2001: unresolved external symbol _pvPortMalloc

Compile one of the FreeRTOS heaps - FreeRTOS-Kernel/portable/MemMang at main · FreeRTOS/FreeRTOS-Kernel · GitHub

error LNK2001: unresolved external symbol _vAssertCalled

I think you are calling this function in your configASSERT definition. Either add a definition of function or change your definition of configASSERT to something like the following - FreeRTOS/FreeRTOSConfig.h at main · FreeRTOS/FreeRTOS · GitHub

error LNK2019: unresolved external symbol _ulGetRunTimeCounterValue
error LNK2019: unresolved external symbol _vConfigureTimerForRunTimeStats

If you need run time stats, you need to supply these functions - FreeRTOS Run Time Stats. If you do not need, you can set configGENERATE_RUN_TIME_STATS to 0 in your FreeRTOSConfig.h

error LNK2019: unresolved external symbol _vApplicationGetIdleTaskMemory 
error LNK2019: unresolved external symbol _vApplicationGetTimerTaskMemory 

You need to supply these 2 functions. You can look at the following for reference -

Hi Gaurav,

Thank you for your support. I followed your things and the compilation error reduced.
Then I tried to build the source(.c file) files along with headers and created the library(.lib). But while building my freertos application using the library, I am getting the compilation error as

Console output :

1>MSVCRTD.lib(exe_main.obj) : error LNK2019: unresolved external symbol _main referenced in function "int __cdecl invoke_main(void)" (?invoke_main@@YAHXZ)
1>freertos_lib.lib(tasks.obj) : error LNK2019: unresolved external symbol _vApplicationStackOverflowHook referenced in function _vTaskSwitchContext
1>freertos_lib.lib(tasks.obj) : error LNK2019: unresolved external symbol _vApplicationGetIdleTaskMemory referenced in function _vTaskStartScheduler
1>freertos_lib.lib(timers.obj) : error LNK2019: unresolved external symbol _vApplicationGetTimerTaskMemory referenced in function _xTimerCreateTimerTask
1>freertos_lib.lib(heap.obj) : error LNK2019: unresolved external symbol _vApplicationMallocFailedHook referenced in function _pvPortMalloc
1>D:\validation_freertos\demo_cross_os\specific\windows\x86\vsnet2015\Debug\demo_cross_os.exe : fatal error LNK1120: 5 unresolved externals
1>Done building project "windows_x86_vsnet2015_demo_cross_os.vcxproj" -- FAILED.
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
========== Elapsed 00:13.500 ==========

Most likely you are defining these functions in a C++ file which will result different name mangling. There are two ways you can handle these:

  1. Either move these definitions to a C file so that these are compiled using a C compiler.
  2. Or move these functions to extern "C" block.

Hi Gaurav,

Its all C files. I have not used any C++ files. I am working on Visual Studio 2022.

Once again sharing my console output

MSVCRTD.lib(exe_main.obj) : error LNK2019: unresolved external symbol _main referenced in function “int __cdecl invoke_main(void)” (?invoke_main@@YAHXZ)
1>freertos_lib.lib(tasks.obj) : error LNK2019: unresolved external symbol _vApplicationStackOverflowHook referenced in function _vTaskSwitchContext
1>freertos_lib.lib(tasks.obj) : error LNK2019: unresolved external symbol _vApplicationGetIdleTaskMemory referenced in function _vTaskStartScheduler
1>freertos_lib.lib(timers.obj) : error LNK2019: unresolved external symbol _vApplicationGetTimerTaskMemory referenced in function _xTimerCreateTimerTask
1>freertos_lib.lib(heap.obj) : error LNK2019: unresolved external symbol _vApplicationMallocFailedHook referenced in function _pvPortMalloc
1>D:\validation_freertos\demo_cross_os\specific\windows\x86\vsnet2015\Debug\demo_cross_os.exe : fatal error LNK1120: 5 unresolved externals
1>Done building project “windows_x86_vsnet2015_demo_cross_os.vcxproj” – FAILED.
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
========== Elapsed 00:13.500 ==========

Hi Gaurav,

Once again I followed the step : You need to supply these 2 functions. You can look at the following for reference -

I am missing with app_main.h. See my console output :slight_smile:
fatal error C1083: Cannot open include file: ‘app_main.h’: No such file or directory

Hi Gaurav,

I found the app_main.h file along with mpu_demo.h file. I can able to build the freertos using the source file and header file and created the library. But while compiling my application on MSVC 2022, I am getting the compilation error as

freertos_lib.lib(app_main.obj) : error LNK2019: unresolved external symbol _vStartMPUDemo referenced in function _app_main

Hi Gaurav,

We found our configured main() entry function of our sample application. Hence app_main.c, app_main.h and mpu_demo.h files are not needed. Right now I am facing the compilation error which is more likely to configure the FreeRTOSConfig.h. The compilation error as

1>freertos_lib.lib(tasks.obj) : error LNK2019: unresolved external symbol _vApplicationStackOverflowHook referenced in function _vTaskSwitchContext
1>freertos_lib.lib(tasks.obj) : error LNK2019: unresolved external symbol _vApplicationGetIdleTaskMemory referenced in function _vTaskStartScheduler
1>freertos_lib.lib(heap.obj) : error LNK2019: unresolved external symbol _vApplicationMallocFailedHook referenced in function _pvPortMalloc
1>freertos_lib.lib(timers.obj) : error LNK2019: unresolved external symbol _vApplicationGetTimerTaskMemory referenced in function _xTimerCreateTimerTask
1>D:\validation_freertos\demo_cross_os\specific\windows\x86\vsnet2015\Debug\demo_cross_os.exe : fatal error LNK1120: 4 unresolved externals
1>Done building project "windows_x86_vsnet2015_demo_cross_os.vcxproj" -- FAILED.
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
========== Elapsed 00:24.338 ==========

Continued here: Need to configure the FreeRtosConfig.h for my application - #2 by richard-damon

Hi Richard ,

Thank you for your support. As per your suggestions, I fixed the compilation error of my freertos application. Now able to compile the application using the FreeRTOS lib.

Thanks,
Soumya