0% completed
Devs, please fix! C++ code not compiling in the "Try it yourself" editor
ivanc11235
Nov 1, 2023
For all of the mult-threaded questions, if you code in C++, neither the Run or Submit buttons will be able to compile and run the code. I get the following compilation error, even when trying to run the official solution in the "Try it yourself" editor:
/usr/bin/ld: /tmp/cc2b5PvT.o: in function std::thread::thread<void (Solution::*)(TreeNodeT<int>*, int), Solution*, TreeNodeT<int>*&, int, void>(void (Solution::*&&)(TreeNodeT<int>*, int), Solution*&&, TreeNodeT<int>*&, int&&)': run.cpp:(.text._ZNSt6threadC2IM8SolutionFvP9TreeNodeTIiEiEJPS1_RS4_iEvEEOT_DpOT0_[_ZNSt6threadC5IM8SolutionFvP9TreeNodeTIiEiEJPS1_RS4_iEvEEOT_DpOT0_]+0x33): undefined reference to pthread_create' collect2: error: ld returned 1 exit status
A cursory online search for this error suggests that the proper fix is to add "-pthread" or "-lpthread" to the compile command.
0
0
Comments
On this page