Actually, I was think that problem is related to Raspberry Pi but it wasn't.
Somehow, OpenCV doesn't recognize GStreamer library when building OpenCV with cmake and make. Also when I use OpenCV in C++ code stack, OpenCV didn't throw exception when it couldn't find gstreamer support.
I added -D WITH_GSTREAMER=ON flag when I'm using cmake command. You can ...
The problem is the order of linking. You have to compile your code first (or specify your object files first), and then specify the libraries you want to link to.
g++ main.cpp -lboost_system -o test
Using this command, and after fixing a small bug in your code (st::cout → std::cout), everything compiles and links correctly.
You can simplify the build ...
Here is some working code which waits for a sysfs interrupt.
Please note the preconditions assumed by the code which are noted in the comments.
As an aside please note that the sysfs interface is deprecated and has been removed from some Linux kernels. If you are writing a new library I suggest you use the /dev/gpiochip interface instead.