ESP-IDF linux 目标在 Apple/Darwin 上无法构建 (IDFGH-18330)
作者: andreaslundeen创建于 2026年9月23日更新于 2026年9月30日
标签Type: BugStatus: Opened
There are a number of issues when building on macOS for the Linux target. I am listing a few of them below: ** lwip disable wrap ** In components/lwip/CMakeLists.txt, add a guard around wrap:
if(NOT CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin")foreach(wrap ${WRAP_FUNCTIONS})target_link_libraries(${COMPONENT_LIB} INTERFACE "-Wl,--wrap=${wrap}")target_link_libraries(${COMPONENT_LIB} INTERFACE "-u __wrap_${wrap}")endforeach()endif()
** freertos_corefoundation_link ** In components/freertos/CMakeLists.txt add:
- if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin")
target_link_libraries(${COMPONENT_LIB} PRIVATE "-framework CoreFoundation")- endif()
** idf_port ** In components/freertos/FreeRTOS-Kernel/portable/linux/port_idf.c add/make configurable: +#if (defined(APPLE) && defined(MACH)) +#include <CoreFoundation/CoreFoundation.h> +#endif +#if (defined(APPLE) && defined(MACH)) +/* macOS: Cocoa (and therefore SDL's video backend) only works on the process's
- real main thread. Run the FreeRTOS scheduler on a dedicated pthread
- instead, so the real main thread is free to run a CFRunLoop (below) -
- which also drains the GCD main dispatch queue, letting
- dispatch_sync(dispatch_get_main_queue(), ...) calls made from FreeRTOS
- tasks actually execute on this thread. A bare dispatch_main() is NOT
- sufficient here: it drains the main queue but doesn't run an actual
- CFRunLoop, and SDL's Cocoa init still reports "No available video
- device" without one. */ +static void *apple_scheduler_thread(void *arg) +{
- (void)arg;
- vTaskStartScheduler();
- return NULL;
+} +#endif inside main() add: ESP_LOGI(TAG, "Starting scheduler."); +#if (defined(APPLE) && defined(MACH))
- pthread_t apple_sched_thread;
- int apple_sched_ret = pthread_create(&apple_sched_thread, NULL, apple_scheduler_thread, NULL);
- assert(apple_sched_ret == 0);
- (void)apple_sched_ret;
- /* CFRunLoopRun() can return on its own once it briefly has no sources
* scheduled (e.g. between dispatch_sync() calls from other threads),* despite being documented as running "indefinitely" - restart it* rather than falling through to the assert(false) below. */- for (;;)
- {
内容来源: espressif/esp-idf