Anyone knows how to solve this problem on WSL2 when I use VS Studio to compile and work with RTOS.
Expecially with this FreeRTOS/Lab-Project-FreeRTOS-Tutorials repo
Anyone knows how to solve this problem on WSL2 when I use VS Studio to compile and work with RTOS.
Expecially with this FreeRTOS/Lab-Project-FreeRTOS-Tutorials repo
Did you try linking with pthread explicitly?
git diff
diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt
index 6b59bf4..13d1365 100644
--- a/source/CMakeLists.txt
+++ b/source/CMakeLists.txt
@@ -33,4 +33,4 @@ add_subdirectory( ${FREERTOS_KERNEL_PATH} ${CMAKE_CURRENT_BINARY_DIR}/FreeRTOS-K
add_executable( freertos_example
${FREERTOS_TUTORIAL_SOURCES} )
-target_link_libraries( freertos_example freertos_kernel freertos_config )
+target_link_libraries( freertos_example freertos_kernel freertos_config pthread )
Can you share the compiler output or build logs, when you execute the build steps:
- Execute the following commands from the root of the repository to build:
rm -rf build
mkdir build
cd build
cmake -B . -S ../source/ -DTUTORIAL=10
make
of course
cmake -B . -S ../source/ -DTUTORIAL=10
-- The C compiler identification is GNU 13.3.0
-- The CXX compiler identification is GNU 13.3.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
-- Configuring done (3.4s)
-- Generating done (0.0s)
-- Build files have been written to: /home/roelof/rtos/Lab-Project-FreeRTOS-Tutorials/build
roelof@DESKTOP-577VVFT:~/rtos/Lab-Project-FreeRTOS-Tutorials/build$ make
[ 7%] Building C object FreeRTOS-Kernel/portable/CMakeFiles/freertos_kernel_port.dir/ThirdParty/GCC/Posix/port.c.o
[ 15%] Building C object FreeRTOS-Kernel/portable/CMakeFiles/freertos_kernel_port.dir/ThirdParty/GCC/Posix/utils/wait_for_event.c.o
[ 15%] Built target freertos_kernel_port
[ 23%] Building C object FreeRTOS-Kernel/CMakeFiles/freertos_kernel.dir/croutine.c.o
[ 30%] Building C object FreeRTOS-Kernel/CMakeFiles/freertos_kernel.dir/event_groups.c.o
[ 38%] Building C object FreeRTOS-Kernel/CMakeFiles/freertos_kernel.dir/list.c.o
[ 46%] Building C object FreeRTOS-Kernel/CMakeFiles/freertos_kernel.dir/queue.c.o
[ 53%] Building C object FreeRTOS-Kernel/CMakeFiles/freertos_kernel.dir/stream_buffer.c.o
[ 61%] Building C object FreeRTOS-Kernel/CMakeFiles/freertos_kernel.dir/tasks.c.o
[ 69%] Building C object FreeRTOS-Kernel/CMakeFiles/freertos_kernel.dir/timers.c.o
[ 76%] Building C object FreeRTOS-Kernel/CMakeFiles/freertos_kernel.dir/portable/MemMang/heap_3.c.o
[ 84%] Linking C static library libfreertos_kernel.a
[ 84%] Built target freertos_kernel
[ 92%] Building C object CMakeFiles/freertos_example.dir/tutorials/tutorial_10/source/tutorial_10.c.o
/home/roelof/rtos/Lab-Project-FreeRTOS-Tutorials/source/tutorials/tutorial_10/source/tutorial_10.c: In function âprvReceiverTaskâ:
/home/roelof/rtos/Lab-Project-FreeRTOS-Tutorials/source/tutorials/tutorial_10/source/tutorial_10.c:110:9: warning: âuxReceivedValueâ is used uninitialized [-Wuninitialized]
110 | fprintf( stderr, "Value received from the queue: %lu\r\n", uxReceivedValue );
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/roelof/rtos/Lab-Project-FreeRTOS-Tutorials/source/tutorials/tutorial_10/source/tutorial_10.c:94:17: note: âuxReceivedValueâ was declared here
94 | UBaseType_t uxReceivedValue;
| ^~~~~~~~~~~~~~~
[100%] Linking C executable freertos_example
[100%] Built target freertos_example
roelof@DESKTOP-577VVFT:~/rtos/Lab-Project-FreeRTOS-Tutorials/build$
[100%] Built target freertos_example
It seems like you are able to build the tutorials fine.
The error you see in Problems tab of VS code should be probably because the VS code couldnât resolve the path to the pthread sources correctly, and it shouldnât have an impact on the purpose of this tutorial.
oke
Still it is a annoying problem
is there then a âbetterâ ide to use then vsCode to code for freeRTOS ?
Since VS code is just an editor rather than an IDE you might have to configure the C_Cpp: IntelliSense Engine settings correctly inorder to get that issue resolved.
I would suggest reaching out to VS code support for that.