-->
Page 1 of 1

Linker error Linking CXX Executable

PostPosted: Thu Feb 23, 2023 1:58 pm
by rcjk9590
Hello,

I have started to explore ESP2886 and ran into a snag trying to learn setting up a project. I am using the RTOS SDK and so far I have successfully build and flash the hello world and an example ds18X20 from this repository
https://github.com/UncleRus/esp-idf-lib

I am using the idf.py wrapper to build

If all files below are placed in main, I can compile fine. Once I try to make a project as on the build system on the ESP wiki, I run into the below linker error. I am not familiar with cmake, I only have experience with PIC XC8 compiler so I think I am just missing something. Any help and feedback on how to structure projects to build is appreciated!

I am using the ds18X20 multi files and created a project like so:
(spaces didn't work for formatting)
Temperature_Sensor (project folder)
---- CMakeLists.txt
Code: Select allcmake_minimum_required(VERSION 3.5)
      include($ENV{IDF_PATH}/tools/cmake/project.cmake)
      project(example-ds18x20)

---- sdconfig
---- main
-------- CMakeLists.txt
Code: Select allidf_component_register(SRCS "main.c"
                    INCLUDE_DIRS "."
                    REQUIRES ds18b20 onewire)

-------- main.c
-------- Kconfig.projbuild
---- components
-------- ds18b20
------------ CMakeLists.txt
Code: Select allidf_component_register(SRCS "ds18x20.c"
                    INCLUDE_DIRS "include"
                    PRIV_REQUIRES helper onewire)

------------ ds18x20.c
------------ include
---------------- ds18x20.h
------------ helper
---------------- CMakeLists.txt
Code: Select allidf_component_register(INCLUDE_DIRS ".")

---------------- esp_idf_lib_helpers.h
---------------- etc_sys.h
------------ onewire
---------------- CMakeLists.tx
Code: Select allidf_component_register(SRCS "onewire.c"
                    INCLUDE_DIRS "include"
                    PRIV_REQUIRES helper)

---------------- onewire.c
------------ include
---------------- onewire.h


Code: Select all[ 98%] Linking CXX executable example-ds18x20.elf
/home/rcjk/esp/xtensa-lx106-elf/bin/../lib/gcc/xtensa-lx106-elf/8.4.0/../../../../xtensa-lx106-elf/bin/ld: /home/rcjk/esp/xtensa-lx106-elf/bin/../lib/gcc/xtensa-lx106-elf/8.4.0/../../../../xtensa-lx106-elf/lib/libstdc++.a(guard.o):(.literal._ZN12_GLOBAL__N_1L16init_static_condEv+0x8): undefined reference to `pthread_cond_init'
/home/rcjk/esp/xtensa-lx106-elf/bin/../lib/gcc/xtensa-lx106-elf/8.4.0/../../../../xtensa-lx106-elf/bin/ld: /home/rcjk/esp/xtensa-lx106-elf/bin/../lib/gcc/xtensa-lx106-elf/8.4.0/../../../../xtensa-lx106-elf/lib/libstdc++.a(guard.o):(.literal._ZN9__gnu_cxx6__cond9broadcastEv[__gnu_cxx::__cond::broadcast()]+0x8): undefined reference to `pthread_cond_broadcast'
/home/rcjk/esp/xtensa-lx106-elf/bin/../lib/gcc/xtensa-lx106-elf/8.4.0/../../../../xtensa-lx106-elf/bin/ld: /home/rcjk/esp/xtensa-lx106-elf/bin/../lib/gcc/xtensa-lx106-elf/8.4.0/../../../../xtensa-lx106-elf/lib/libstdc++.a(guard.o):(.literal.__cxa_guard_acquire+0x8): undefined reference to `pthread_cond_wait'
/home/rcjk/esp/xtensa-lx106-elf/bin/../lib/gcc/xtensa-lx106-elf/8.4.0/../../../../xtensa-lx106-elf/bin/ld: /home/rcjk/esp/xtensa-lx106-elf/bin/../lib/gcc/xtensa-lx106-elf/8.4.0/../../../../xtensa-lx106-elf/lib/libstdc++.a(guard.o): in function `__gthread_cond_init_function':
/builds/idf/crosstool-NG/.build/xtensa-lx106-elf/build/build-cc-gcc-final/xtensa-lx106-elf/libstdc++-v3/include/xtensa-lx106-elf/bits/gthr-default.h:858: undefined reference to `pthread_cond_init'
/home/rcjk/esp/xtensa-lx106-elf/bin/../lib/gcc/xtensa-lx106-elf/8.4.0/../../../../xtensa-lx106-elf/bin/ld: /home/rcjk/esp/xtensa-lx106-elf/bin/../lib/gcc/xtensa-lx106-elf/8.4.0/../../../../xtensa-lx106-elf/lib/libstdc++.a(guard.o): in function `__gnu_cxx::__cond::broadcast()':
/builds/idf/crosstool-NG/.build/xtensa-lx106-elf/build/build-cc-gcc-final/xtensa-lx106-elf/libstdc++-v3/include/ext/concurrence.h:280: undefined reference to `pthread_cond_broadcast'
/home/rcjk/esp/xtensa-lx106-elf/bin/../lib/gcc/xtensa-lx106-elf/8.4.0/../../../../xtensa-lx106-elf/bin/ld: /home/rcjk/esp/xtensa-lx106-elf/bin/../lib/gcc/xtensa-lx106-elf/8.4.0/../../../../xtensa-lx106-elf/lib/libstdc++.a(guard.o): in function `__gthread_cond_wait':
/builds/idf/crosstool-NG/.build/xtensa-lx106-elf/build/build-cc-gcc-final/xtensa-lx106-elf/libstdc++-v3/include/xtensa-lx106-elf/bits/gthr-default.h:877: undefined reference to `pthread_cond_wait'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/example-ds18x20.elf.dir/build.make:219: example-ds18x20.elf] Error 1
make[1]: *** [CMakeFiles/Makefile2:1322: CMakeFiles/example-ds18x20.elf.dir/all] Error 2
make: *** [Makefile:149: all] Error 2
make failed with exit code 2