0

My code works perfectly on my mac but does not compile on linux. I get the compile error

/tmp/ccWcFSEW.o: In function `main':
DroneMap.cpp:(.text.startup+0x22d): undefined reference to `pthread_create'
DroneMap.cpp:(.text.startup+0x262): undefined reference to `pthread_join'
collect2: error: ld returned 1 exit status

Does anyone have any idea what this error message means or why i am getting it because i cant figure it out.

CXX=g++
CXXFLAGS=-Wall -O3

all: DroneMap

clean:
    rm -rf DroneMap
  • Those are linker errors. It can't resolve calls to the pthread library. Check to make sure that the linker can find the pthread library (usually via the -L option). – Anon Mail Oct 09 '15 at 00:12
  • 1
    Try [this answer](http://stackoverflow.com/a/1665110/4440992). – Joe Oct 09 '15 at 00:15
  • 1
    Your code wants to link the `pthreads` library. Ensure you have `-pthread` specified when compiling and linking. – πάντα ῥεῖ Oct 09 '15 at 00:17

1 Answers1

3

You need to include the pthread library in your compilation command, i dont know how you compile it in MAC, but the correct compile command for linux will be like that.

CXX=g++
CXXFLAGS=-pthread -Wall -O3

all: DroneMap

clean:
    rm -rf DroneMap
Captain Wise
  • 480
  • 3
  • 13