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

**URL:** <https://forums.freertos.org/t/getting-compilation-error-on-visual-studio22-for-my-application-using-the-freertosv202112-00/16444>\
**Category:** Libraries\
**Created:** [December 22, 2022, 10:12am UTC](https://forums.freertos.org/t/getting-compilation-error-on-visual-studio22-for-my-application-using-the-freertosv202112-00/16444 "2022-12-22T10:12:28Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![soumyaims](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/soumyaims/32/3069_2.png) [@soumyaims](https://forums.freertos.org/u/soumyaims)\
**Post date:** [December 22, 2022, 10:12am UTC](https://forums.freertos.org/t/getting-compilation-error-on-visual-studio22-for-my-application-using-the-freertosv202112-00/16444/1 "2022-12-22T10:12:28Z")

</div>

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

```auto
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).

---

<div class="post-metadata">

**Author:** ![aggarg](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/aggarg/32/4245_2.png) [@aggarg](https://forums.freertos.org/u/aggarg)\
**Post date:** [December 22, 2022, 10:50am UTC](https://forums.freertos.org/t/getting-compilation-error-on-visual-studio22-for-my-application-using-the-freertosv202112-00/16444/2 "2022-12-22T10:50:56Z")

</div>

```auto
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](https://github.com/FreeRTOS/FreeRTOS-Kernel/tree/main/portable/MemMang)

```auto
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](https://github.com/FreeRTOS/FreeRTOS/blob/main/FreeRTOS/Demo/CORTEX_MPU_M7_NUCLEO_H743ZI2_GCC_IAR_Keil/Config/FreeRTOSConfig.h#L122)

```auto
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](https://www.freertos.org/rtos-run-time-stats.html). If you do not need, you can set configGENERATE\_RUN\_TIME\_STATS to 0 in your FreeRTOSConfig.h

```auto
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 -

- [FreeRTOS/app\_main.c at main · FreeRTOS/FreeRTOS · GitHub](https://github.com/FreeRTOS/FreeRTOS/blob/main/FreeRTOS/Demo/CORTEX_MPU_M7_NUCLEO_H743ZI2_GCC_IAR_Keil/Demo/app_main.c#L71)
- [FreeRTOS/app\_main.c at main · FreeRTOS/FreeRTOS · GitHub](https://github.com/FreeRTOS/FreeRTOS/blob/main/FreeRTOS/Demo/CORTEX_MPU_M7_NUCLEO_H743ZI2_GCC_IAR_Keil/Demo/app_main.c#L96)

---

<div class="post-metadata">

**Author:** ![soumyaims](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/soumyaims/32/3069_2.png) [@soumyaims](https://forums.freertos.org/u/soumyaims)\
**Post date:** [December 26, 2022, 9:03am UTC](https://forums.freertos.org/t/getting-compilation-error-on-visual-studio22-for-my-application-using-the-freertosv202112-00/16444/3 "2022-12-26T09:03:15Z")

</div>

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 :

```auto
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 ==========

```

---

<div class="post-metadata">

**Author:** ![aggarg](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/aggarg/32/4245_2.png) [@aggarg](https://forums.freertos.org/u/aggarg)\
**Post date:** [December 26, 2022, 9:24am UTC](https://forums.freertos.org/t/getting-compilation-error-on-visual-studio22-for-my-application-using-the-freertosv202112-00/16444/4 "2022-12-26T09:24:27Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![soumyaims](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/soumyaims/32/3069_2.png) [@soumyaims](https://forums.freertos.org/u/soumyaims)\
**Post date:** [December 26, 2022, 12:00pm UTC](https://forums.freertos.org/t/getting-compilation-error-on-visual-studio22-for-my-application-using-the-freertosv202112-00/16444/5 "2022-12-26T12:00:07Z")

</div>

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 ==========

---

<div class="post-metadata">

**Author:** ![soumyaims](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/soumyaims/32/3069_2.png) [@soumyaims](https://forums.freertos.org/u/soumyaims)\
**Post date:** [December 26, 2022, 12:17pm UTC](https://forums.freertos.org/t/getting-compilation-error-on-visual-studio22-for-my-application-using-the-freertosv202112-00/16444/6 "2022-12-26T12:17:17Z")

</div>

Hi Gaurav,

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

- [FreeRTOS/app\_main.c at main · FreeRTOS/FreeRTOS · GitHub](https://github.com/FreeRTOS/FreeRTOS/blob/main/FreeRTOS/Demo/CORTEX_MPU_M7_NUCLEO_H743ZI2_GCC_IAR_Keil/Demo/app_main.c#L71)
- [FreeRTOS/app\_main.c at main · FreeRTOS/FreeRTOS · GitHub](https://github.com/FreeRTOS/FreeRTOS/blob/main/FreeRTOS/Demo/CORTEX_MPU_M7_NUCLEO_H743ZI2_GCC_IAR_Keil/Demo/app_main.c#L96)

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

---

<div class="post-metadata">

**Author:** ![soumyaims](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/soumyaims/32/3069_2.png) [@soumyaims](https://forums.freertos.org/u/soumyaims)\
**Post date:** [December 26, 2022, 12:38pm UTC](https://forums.freertos.org/t/getting-compilation-error-on-visual-studio22-for-my-application-using-the-freertosv202112-00/16444/7 "2022-12-26T12:38:56Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![soumyaims](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/soumyaims/32/3069_2.png) [@soumyaims](https://forums.freertos.org/u/soumyaims)\
**Post date:** [December 26, 2022, 3:25pm UTC](https://forums.freertos.org/t/getting-compilation-error-on-visual-studio22-for-my-application-using-the-freertosv202112-00/16444/8 "2022-12-26T15:25:14Z")

</div>

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

```auto
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 ==========

```

---

<div class="post-metadata">

**Author:** ![rtel](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/rtel/32/31_2.png) [@rtel](https://forums.freertos.org/u/rtel)\
**Post date:** [December 26, 2022, 5:12pm UTC](https://forums.freertos.org/t/getting-compilation-error-on-visual-studio22-for-my-application-using-the-freertosv202112-00/16444/9 "2022-12-26T17:12:47Z")

</div>

Continued here: [Need to configure the FreeRtosConfig.h for my application - #2 by richard-damon](https://forums.freertos.org/t/need-to-configure-the-freertosconfig-h-for-my-application/16454/2)

---

<div class="post-metadata">

**Author:** ![soumyaims](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/soumyaims/32/3069_2.png) [@soumyaims](https://forums.freertos.org/u/soumyaims)\
**Post date:** [December 28, 2022, 1:48pm UTC](https://forums.freertos.org/t/getting-compilation-error-on-visual-studio22-for-my-application-using-the-freertosv202112-00/16444/10 "2022-12-28T13:48:47Z")

</div>

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
