Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error Compiling azure-iot-sdk-c from Ubuntu host to Rasperry Pi 4: _dl_stack_flags not found #1093

Closed
z466chen opened this issue Aug 2, 2019 · 8 comments · Fixed by #1760

Comments

@z466chen
Copy link

z466chen commented Aug 2, 2019

OS: 18.04.2 LTS
azure-iot-c-sdk: latest

I am following the tutorial of cross compiling azure-iot-sdk-c on my Rpi 4 device.
It is success fully built using command:


sudo ./build.sh --toolchain-file toolchain-rpi.cmake -cl --sysroot=<work_dir>/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-64/arm-linux-gnueabihf


And makefiles are generated for all samples. However, when making these samples, I got the following error:


/home/z466chen/raspberry/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-64/arm-linux-gnueabihf/usr/lib/arm-linux-gnueabihf/libpthread.a(pthread_create.o): In function __pthread_create_2_1': /build/glibc-FUvrFr/glibc-2.28/nptl/pthread_create.c:697: undefined reference to _dl_stack_flags'
/home/z466chen/raspberry/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-64/arm-linux-gnueabihf/usr/lib/arm-linux-gnueabihf/libpthread.a(unwind.o): In function unwind_stop': /build/glibc-FUvrFr/glibc-2.28/nptl/unwind.c:72: undefined reference to __pointer_chk_guard_local'
/home/z466chen/raspberry/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-64/arm-linux-gnueabihf/usr/lib/arm-linux-gnueabihf/libpthread.a(nptl-init.o): In function __pthread_initialize_minimal_internal': /build/glibc-FUvrFr/glibc-2.28/nptl/nptl-init.c:434: undefined reference to _dl_pagesize'
/build/glibc-FUvrFr/glibc-2.28/nptl/nptl-init.c:434: undefined reference to _dl_init_static_tls' /build/glibc-FUvrFr/glibc-2.28/nptl/nptl-init.c:434: undefined reference to _dl_wait_lookup_done'
/home/z466chen/raspberry/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-64/arm-linux-gnueabihf/usr/lib/arm-linux-gnueabihf/libpthread.a(nptl-init.o): In function __pthread_get_minstack': /build/glibc-FUvrFr/glibc-2.28/nptl/nptl-init.c:443: undefined reference to _dl_pagesize'
collect2: error: ld returned 1 exit status
/home/z466chen/raspberry/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-64/arm-linux-gnueabihf/usr/lib/arm-linux-gnueabihf/libpthread.a(pthread_create.o): In function __pthread_create_2_1': /build/glibc-FUvrFr/glibc-2.28/nptl/pthread_create.c:697: undefined reference to _dl_stack_flags'
/home/z466chen/raspberry/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-64/arm-linux-gnueabihf/usr/lib/arm-linux-gnueabihf/libpthread.a(unwind.o): In function unwind_stop': /build/glibc-FUvrFr/glibc-2.28/nptl/unwind.c:72: undefined reference to __pointer_chk_guard_local'
/home/z466chen/raspberry/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-64/arm-linux-gnueabihf/usr/lib/arm-linux-gnueabihf/libpthread.a(nptl-init.o): In function __pthread_initialize_minimal_internal': /build/glibc-FUvrFr/glibc-2.28/nptl/nptl-init.c:434: undefined reference to _dl_pagesize'
/build/glibc-FUvrFr/glibc-2.28/nptl/nptl-init.c:434: undefined reference to _dl_init_static_tls' /build/glibc-FUvrFr/glibc-2.28/nptl/nptl-init.c:434: undefined reference to _dl_wait_lookup_doneiothub_client/samples/iothub_ll_client_x509_sample/CMakeFiles/iothub_ll_client_x509_sample.dir/build.make:113: recipe for target 'iothub_client/samples/iothub_ll_client_x509_sample/iothub_ll_client_x509_sample' failed
'make[2]: *** [iothub_client/samples/iothub_ll_client_x509_sample/iothub_ll_client_x509_sample] Error 1

/home/z466chen/raspberry/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-64/arm-linux-gnueabihf/usr/lib/arm-linux-gnueabihf/libpthread.a(nptl-init.o): In function __pthread_get_minstack': /build/glibc-FUvrFr/glibcCMakeFiles/Makefile2:1817: recipe for target 'iothub_client/samples/iothub_ll_client_x509_sample/CMakeFiles/iothub_ll_client_x509_sample.dir/all' failed -make[1]: *** [iothub_client/samples/iothub_ll_client_x509_sample/CMakeFiles/iothub_ll_client_x509_sample.dir/all] Error 2 2.28/nptl/nptl-make[1]: *** Waiting for unfinished jobs.... init.c:443: undefined reference to _dl_pagesize'
collect2: error: ld returned 1 exit status
iothub_client/samples/iothub_ll_c2d_sample/CMakeFiles/iothub_ll_c2d_sample.dir/build.make:140: recipe for target 'iothub_client/samples/iothub_ll_c2d_sample/iothub_ll_c2d_sample' failed
make[2]: *** [iothub_client/samples/iothub_ll_c2d_sample/iothub_ll_c2d_sample] Error 1
CMakeFiles/Makefile2:1753: recipe for target 'iothub_client/samples/iothub_ll_c2d_sample/CMakeFiles/iothub_ll_c2d_sample.dir/all' failed
make[1]: *** [iothub_client/samples/iothub_ll_c2d_sample/CMakeFiles/iothub_ll_c2d_sample.dir/all] Error 2


After research, it seems that it related to pthread not dynamically linked but other libraries like libc are dynamically linked. Is that the right way to investigate this issue? If so, what should I do to overcome this issue?

@rafilho rafilho self-assigned this Aug 15, 2019
@rafilho
Copy link
Contributor

rafilho commented Aug 28, 2019

Correct. I arrived to a similar conclusion based on those links below:

https://stackoverflow.com/questions/5738000/undefined-reference-error-dl-stack-flags-with-gcc-and-pthreads

https://askubuntu.com/questions/36211/undefined-reference-error-dl-stack-flags-with-gcc-and-pthreads

That should be the right path of investigation. Were you able to fix the issue based on this investigation? Thanks.

@rafilho
Copy link
Contributor

rafilho commented Aug 28, 2019

Can you please also post here the full output from make? Thanks.

@campellcl
Copy link

@z466chen Were you able to figure out what modifications to make to the toolchain file to have pthread statically link? I am having the same issue as you.

@campellcl
Copy link

@rafilho I am having the same issue. Do you have any idea how to modify the azure-iot-sdk-c build process to statically link pthread?

@ewertons
Copy link
Contributor

ewertons commented Aug 4, 2020

Hi @z466chen

We apologize for the long delay, but we were assigned to work on new code development and that affected our github response time.

Is this still an issue for you?

@bbpaulvanharen
Copy link

bbpaulvanharen commented Aug 13, 2020

I had the same issue. Quick hack:
In the directory $RPI_ROOT/usr/lib/arm-linux-gnueabihf create a symbolic link to ../../../lib/arm-linux-gnueabihf/libpthread.so.0.

Just run
cd $RPI_ROOT/usr/lib/arm-linux-gnueabihf; ln -s ../../../lib/arm-linux-gnueabihf/libpthread.so.0 libpthread.so

@ewertons
Copy link
Contributor

We were able to (re)confirm the issue and the workaround. Thanks @bbpaulvanharen . We will update the docs with the workaround information.

@ewertons ewertons self-assigned this Nov 24, 2020
ewertons added a commit that referenced this issue Nov 25, 2020
@ewertons ewertons linked a pull request Nov 25, 2020 that will close this issue
6 tasks
ewertons added a commit that referenced this issue Dec 1, 2020
Update cross-compilation docs for Raspberry Pi 4 (gh #1093)
@az-iot-builder-01
Copy link
Collaborator

@z466chen, @campellcl, @bbpaulvanharen, thank you for your contribution to our open-sourced project! Please help us improve by filling out this 2-minute customer satisfaction survey

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants