Hi. I've cloned the repository and tried compiling it with:
.../.../px/examples$ make
g++ -std=c++11 -pedantic -g -O2 -Wall -Wcast-align -Wcast-qual -Wctor-dtor-privacy -Wdisabled-optimization -Wdouble-promotion -Werror -Wextra -Wformat=2 -Winit-self -Wmissing-include-dirs -Wno-unused -Wold-style-cast -Woverloaded-virtual -Wredundant-decls -Wshadow -Wsign-conversion -Wsign-promo -Wstrict-overflow=5 -Wswitch-default -Wundef -o px_sched_example1 -lpthread -lpthread px_sched_example1.cpp
/tmp/cce6YjPP.o: In function `std::thread::thread<void (&)(px_sched::Scheduler*, px_sched::Scheduler::Worker*), px_sched::Scheduler*, px_sched::Scheduler::Worker*>(void (&)(px_sched::Scheduler*, px_sched::Scheduler::Worker*), px_sched::Scheduler*&&, px_sched::Scheduler::Worker*&&)':
/usr/include/c++/5/thread:137: undefined reference to `pthread_create'
collect2: error: ld returned 1 exit status
Makefile:42: recipe for target 'px_sched_example1' failed
make: *** [px_sched_example1] Error 1
Then, based on these links link1 link2 (that seem to contradict each other :smiley: ), I thought that -lpthread
must be put after the source files, whereas -pthread
only can be used before the source files.
I've tried the latter and simply replaced -lpthread
with -pthread
in the Makefile.
I don't know if this is the right solution, but it worked:
.../.../px/examples$ make clean
rm -f px_sched_example1 px_sched_example2 px_sched_example3 px_sched_example4 px_sched_example5 px_sched_example6 px_sched_example7
.../...//px/examples$ make
g++ -std=c++11 -pedantic -g -O2 -Wall -Wcast-align -Wcast-qual -Wctor-dtor-privacy -Wdisabled-optimization -Wdouble-promotion -Werror -Wextra -Wformat=2 -Winit-self -Wmissing-include-dirs -Wno-unused -Wold-style-cast -Woverloaded-virtual -Wredundant-decls -Wshadow -Wsign-conversion -Wsign-promo -Wstrict-overflow=5 -Wswitch-default -Wundef -o px_sched_example1 -pthread px_sched_example1.cpp
g++ -std=c++11 -pedantic -g -O2 -Wall -Wcast-align -Wcast-qual -Wctor-dtor-privacy -Wdisabled-optimization -Wdouble-promotion -Werror -Wextra -Wformat=2 -Winit-self -Wmissing-include-dirs -Wno-unused -Wold-style-cast -Woverloaded-virtual -Wredundant-decls -Wshadow -Wsign-conversion -Wsign-promo -Wstrict-overflow=5 -Wswitch-default -Wundef -o px_sched_example2 -pthread px_sched_example2.cpp
g++ -std=c++11 -pedantic -g -O2 -Wall -Wcast-align -Wcast-qual -Wctor-dtor-privacy -Wdisabled-optimization -Wdouble-promotion -Werror -Wextra -Wformat=2 -Winit-self -Wmissing-include-dirs -Wno-unused -Wold-style-cast -Woverloaded-virtual -Wredundant-decls -Wshadow -Wsign-conversion -Wsign-promo -Wstrict-overflow=5 -Wswitch-default -Wundef -o px_sched_example3 -pthread px_sched_example3.cpp
g++ -std=c++11 -pedantic -g -O2 -Wall -Wcast-align -Wcast-qual -Wctor-dtor-privacy -Wdisabled-optimization -Wdouble-promotion -Werror -Wextra -Wformat=2 -Winit-self -Wmissing-include-dirs -Wno-unused -Wold-style-cast -Woverloaded-virtual -Wredundant-decls -Wshadow -Wsign-conversion -Wsign-promo -Wstrict-overflow=5 -Wswitch-default -Wundef -o px_sched_example4 -pthread px_sched_example4.cpp
g++ -std=c++11 -pedantic -g -O2 -Wall -Wcast-align -Wcast-qual -Wctor-dtor-privacy -Wdisabled-optimization -Wdouble-promotion -Werror -Wextra -Wformat=2 -Winit-self -Wmissing-include-dirs -Wno-unused -Wold-style-cast -Woverloaded-virtual -Wredundant-decls -Wshadow -Wsign-conversion -Wsign-promo -Wstrict-overflow=5 -Wswitch-default -Wundef -o px_sched_example5 -pthread px_sched_example5.cpp
g++ -std=c++11 -pedantic -g -O2 -Wall -Wcast-align -Wcast-qual -Wctor-dtor-privacy -Wdisabled-optimization -Wdouble-promotion -Werror -Wextra -Wformat=2 -Winit-self -Wmissing-include-dirs -Wno-unused -Wold-style-cast -Woverloaded-virtual -Wredundant-decls -Wshadow -Wsign-conversion -Wsign-promo -Wstrict-overflow=5 -Wswitch-default -Wundef -o px_sched_example6 -pthread px_sched_example6.cpp
g++ -std=c++11 -pedantic -g -O2 -Wall -Wcast-align -Wcast-qual -Wctor-dtor-privacy -Wdisabled-optimization -Wdouble-promotion -Werror -Wextra -Wformat=2 -Winit-self -Wmissing-include-dirs -Wno-unused -Wold-style-cast -Woverloaded-virtual -Wredundant-decls -Wshadow -Wsign-conversion -Wsign-promo -Wstrict-overflow=5 -Wswitch-default -Wundef -o px_sched_example7 -pthread px_sched_example7.cpp
Hope it helps other Linux users having the same problems :smile: .