I am using Visual Studio to remotely build and debug code for my BeagleBoneBlack (BBB). I have connected to it using remote connection session using SHH as in this image –
When I build the code, all the files get copied to my BBB as expected. But when I build the code, I get a bunch of linker errors, particularly for the pthread
library.
1>Linking objects
1>/usr/bin/ld : error : /home/debian/projects/BM_II/obj/ARM/Debug/BoxMapperII.o: in function `GetNextVial(_VIAL_TAG_&)':
1>C:UsersColdSIGHT IIOneDrivemDocumentsBM_IIBM_IIBM_IIBoxMapperII.cpp(2529): error : undefined reference to `pthread_mutex_trylock'
1>/usr/bin/ld : error : /home/debian/projects/BM_II/obj/ARM/Debug/BoxMapperII.o: in function `SetNextVial(_VIAL_TAG_)':
1>C:UsersColdSIGHT IIOneDrivemDocumentsBM_IIBM_IIBM_IIBoxMapperII.cpp(2551): error : undefined reference to `pthread_mutex_trylock'
1>/usr/bin/ld : error : /home/debian/projects/BM_II/obj/ARM/Debug/Hardware.o: in function `CHardware::ShutDownMon()':
1>C:UsersColdSIGHT IIOneDrivemDocumentsBM_IIBM_IIBM_IIHardware.cpp(333): error : undefined reference to `pthread_create'
1>/usr/bin/ld : error : /home/debian/projects/BM_II/obj/ARM/Debug/LED_Control.o: in function `CLED_Control::InitLED_Control()':
1>C:UsersColdSIGHT IIOneDrivemDocumentsBM_IIBM_IIBM_IILED_Control.cpp(44): error : undefined reference to `pthread_create'
1>/usr/bin/ld : error : /home/debian/projects/BM_II/obj/ARM/Debug/ListenSocket.o: in function `CListenSocket::Close()':
1>C:UsersColdSIGHT IIOneDrivemDocumentsBM_IIBM_IIBM_IIListenSocket.cpp(64): error : undefined reference to `pthread_cancel'
1>/usr/bin/ld : error : /home/debian/projects/BM_II/ListenSocket.cpp:66: undefined reference to `pthread_join'
1>/usr/bin/ld : error : /home/debian/projects/BM_II/obj/ARM/Debug/ListenSocket.o: in function `CListenSocket::Init(_SERVICE_CONFIG const&)':
1>C:UsersColdSIGHT IIOneDrivemDocumentsBM_IIBM_IIBM_IIListenSocket.cpp(186): error : undefined reference to `pthread_create'
1>/usr/bin/ld : error : /home/debian/projects/BM_II/obj/ARM/Debug/ServerSocket.o: in function `CServerSocket::Close()':
1>C:UsersColdSIGHT IIOneDrivemDocumentsBM_IIBM_IIBM_IIServerSocket.cpp(84): error : undefined reference to `pthread_cancel'
1>/usr/bin/ld : error : /home/debian/projects/BM_II/ServerSocket.cpp:87: undefined reference to `pthread_join'
1>/usr/bin/ld : error : /home/debian/projects/BM_II/obj/ARM/Debug/ServerSocket.o: in function `CServerSocket::Init(unsigned int)':
1>C:UsersColdSIGHT IIOneDrivemDocumentsBM_IIBM_IIBM_IIServerSocket.cpp(101): error : undefined reference to `pthread_create'
1>/usr/bin/ld : error : /home/debian/projects/BM_II/obj/ARM/Debug/UARTCommunication.o: in function `CUARTCommunication::InitUART(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, unsigned int)':
1>C:UsersColdSIGHT IIOneDrivemDocumentsBM_IIBM_IIBM_IIUARTCommunication.cpp(59): error : undefined reference to `pthread_create'
1>/usr/bin/ld : error : /home/debian/projects/BM_II/obj/ARM/Debug/UARTCommunication.o: in function `boost::asio::detail::posix_event::posix_event()':
1>C:UsersColdSIGHT IIOneDrivemDocumentsBM_IIBM_IIBM_IIboostasiodetailimplposix_event.ipp(44): error : undefined reference to `pthread_condattr_setclock'
1>/usr/bin/ld : error : /home/debian/projects/BM_II/obj/ARM/Debug/UARTCommunication.o: in function `boost::asio::detail::posix_thread::~posix_thread()':
1>C:UsersColdSIGHT IIOneDrivemDocumentsBM_IIBM_IIBM_IIboostasiodetailimplposix_thread.ipp(35): error : undefined reference to `pthread_detach'
1>/usr/bin/ld : error : /home/debian/projects/BM_II/obj/ARM/Debug/UARTCommunication.o: in function `boost::asio::detail::posix_thread::join()':
1>C:UsersColdSIGHT IIOneDrivemDocumentsBM_IIBM_IIBM_IIboostasiodetailimplposix_thread.ipp(42): error : undefined reference to `pthread_join'
1>/usr/bin/ld : error : /home/debian/projects/BM_II/obj/ARM/Debug/UARTCommunication.o: in function `boost::asio::detail::posix_thread::start_thread(boost::asio::detail::posix_thread::func_base*)':
1>C:UsersColdSIGHT IIOneDrivemDocumentsBM_IIBM_IIBM_IIboostasiodetailimplposix_thread.ipp(59): error : undefined reference to `pthread_create'
1>/usr/bin/ld : error : /home/debian/projects/BM_II/obj/ARM/Debug/UARTCommunication.o: in function `boost::asio::detail::posix_signal_blocker::posix_signal_blocker()':
1>C:UsersColdSIGHT IIOneDrivemDocumentsBM_IIBM_IIBM_IIboostasiodetailposix_signal_blocker.hpp(43): error : undefined reference to `pthread_sigmask'
1>/usr/bin/ld : error : /home/debian/projects/BM_II/obj/ARM/Debug/UARTCommunication.o: in function `boost::asio::detail::posix_signal_blocker::~posix_signal_blocker()':
1>C:UsersColdSIGHT IIOneDrivemDocumentsBM_IIBM_IIBM_IIboostasiodetailposix_signal_blocker.hpp(50): error : undefined reference to `pthread_sigmask'
1>collect2 : error : ld returned 1 exit status
1>Done building project "BM_II.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
========== Build started at 5:13 PM and took 04:56.379 minutes ==========
========== Deploy: 0 succeeded, 0 failed, 0 skipped ==========
========== Deploy started at 5:13 PM and took 04:56.379 minutes ==========
I see that my pthread.h
is located in the local folder – C:UsersColdSIGHTIIAppDataLocalMicrosoftLinuxHeaderCache1.0-689744971usrincludelinux
. I don’t understand why pthead.h
is the only library that is not linked. There are other libraries such as stdio.h
that my source code uses and they are located in the same folder as well.But they do not give the linker errors. Please let me know what I am doing wrong. Thank you.