I keep getting stuck implementing libraries on the beagle bone black. I want to use “pthread.h”, but I keep getting errors saying that the functions are undefined. I believe I do not have pthread linked to the gcc. Is this correct? How do I do this?
Compiling /var/lib/cloud9/BeagleBone/Black/Thread.c ...
cc Thread.c -o Thread
/usr/bin/ld: /tmp/ccX8byyR.o: in function `func1':
Thread.c:(.text+0x10): undefined reference to `pthread_detach'
/usr/bin/ld: /tmp/ccX8byyR.o: in function `func2':
Thread.c:(.text+0x3c): undefined reference to `pthread_detach'
/usr/bin/ld: /tmp/ccX8byyR.o: in function `testThread':
Thread.c:(.text+0x68): undefined reference to `pthread_create'
/usr/bin/ld: Thread.c:(.text+0x76): undefined reference to `pthread_create'
/usr/bin/ld: Thread.c:(.text+0x80): undefined reference to `pthread_join'
/usr/bin/ld: Thread.c:(.text+0x8a): undefined reference to `pthread_join'
collect2: error: ld returned 1 exit status
make: *** [<builtin>: Thread] Error 1
Cloud9 is no longer being maintained from what I heard. People are using some other type of instance at port 3000 w/ the newer images.
This could be the reason. Also, when using the already configured source, maybe building them using gcc has a particular way for it to be built.
gcc MyFile.c -o MyFile or if you have to link them, please link them first.
For instance, are you using a Static or Dynamic lib. when compiling?
This may be a precursor to finding out how to manage the compilation w/ gcc.
export LD_LIBRARY_PATH=$PWD:$LD_LIBRARY_PATH might help but w/out knowing what type of lib. you are using, I am in the dark.
Seth
P.S. Please let me know what compilation steps you have taken, if you are using a Static or Dynamic lib, and then please let me know about the exporting of the lib. using LD.
The issue was that I didn’t link the library properly. It worked immediately when I used the
gcc MyFile.c -o MyFile
structure. Is there a way that I can automatically choose the linker files that are attached?