librt

undefined reference to `shm_open' using CMake

余生长醉 提交于 2020-01-03 17:41:07
问题 I am using CMake under Ubuntu 14.04 to configure my project. I need to use a 3rd party library (say stuff.so). In the CMakeLists.txt, I use TARGET_LINK_LIBRARIES to link the stuff library. However, I got an error: DIR_TO_LIB/stuff.so:-1: error: undefined reference to `shm_open' I tried to put these flag in the CMakeLists.txt but it didn't work: set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lrt") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -lrt") A post (link) saying that -lrt should be

Why does linking to librt swap performance between g++ and clang?

倖福魔咒の 提交于 2019-12-21 17:02:46
问题 I just found this answer from @tony-d with a bench code to test virtual function call overhead. I checked is benchmark using g++ : $ g++ -O2 -o vdt vdt.cpp -lrt $ ./vdt virtual dispatch: 150000000 0.128562 switched: 150000000 0.0803207 overheads: 150000000 0.0543323 ... I got better performance that his (ratio is about 2), but then I checked with clang : $ clang++-3.7 -O2 -o vdt vdt.cpp -lrt $ ./vdt virtual dispatch: 150000000 0.462368 switched: 150000000 0.0569544 overheads: 150000000 0

Why does linking to librt swap performance between g++ and clang?

末鹿安然 提交于 2019-12-21 17:01:11
问题 I just found this answer from @tony-d with a bench code to test virtual function call overhead. I checked is benchmark using g++ : $ g++ -O2 -o vdt vdt.cpp -lrt $ ./vdt virtual dispatch: 150000000 0.128562 switched: 150000000 0.0803207 overheads: 150000000 0.0543323 ... I got better performance that his (ratio is about 2), but then I checked with clang : $ clang++-3.7 -O2 -o vdt vdt.cpp -lrt $ ./vdt virtual dispatch: 150000000 0.462368 switched: 150000000 0.0569544 overheads: 150000000 0

Makefile g++ lrt problem. Cannot find lrt

陌路散爱 提交于 2019-12-11 15:51:28
问题 Here is my makefile. # The intuitive "all" target will be our default. .DEFAULT_GOAL := all # Component dir's to search and invoke make. # (Try preserving the order of directories) COM := src_dir1 src_dir2 src_dir3 PROJ_DIR = $(shell pwd) EXEC := anonymousforconfidentiality CC := g++ CFLAGS := -g3 LIBS = `pkg-config --cflags --libs glib-2.0 gio-unix-2.0 bluez protobuf lrt` .PHONY : clean compile link all all: | clean compile link link: $(eval $@_ALLOBJECTS := $(shell find . -name '*.o')) $(CC

Why does linking to librt swap performance between g++ and clang?

亡梦爱人 提交于 2019-12-04 07:41:04
I just found this answer from @tony-d with a bench code to test virtual function call overhead. I checked is benchmark using g++ : $ g++ -O2 -o vdt vdt.cpp -lrt $ ./vdt virtual dispatch: 150000000 0.128562 switched: 150000000 0.0803207 overheads: 150000000 0.0543323 ... I got better performance that his (ratio is about 2), but then I checked with clang : $ clang++-3.7 -O2 -o vdt vdt.cpp -lrt $ ./vdt virtual dispatch: 150000000 0.462368 switched: 150000000 0.0569544 overheads: 150000000 0.0509332 ... Now the ratio goes up to about 70! I then noticed the -lrt command line argument, and after a