Linker command failed using igraph

Hi,
I am new in igraph and C++ at all and I have a problem with linker. Igraph was installed successfully using Homebrew but when I tried to run the tutorial code tutorial1.c from examples tutorial1 on github I had an error:
ld: Undefined symbols: _igraph_destroy, referenced from: _main in tutorial1-b341c6.o _igraph_diameter, referenced from: _main in tutorial1-b341c6.o _igraph_ecount, referenced from: _main in tutorial1-b341c6.o _igraph_erdos_renyi_game_gnm, referenced from: _main in tutorial1-b341c6.o _igraph_rng_default, referenced from: _main in tutorial1-b341c6.o _igraph_rng_seed, referenced from: _main in tutorial1-b341c6.o _igraph_vcount, referenced from: _main in tutorial1-b341c6.o clang: error: linker command failed with exit code 1 (use -v to see invocation)

I found the topic with similar problem similar problem and I have tried to use solutions from it:

  1. I have tried to generate both of static and shared libraries
  2. I have tried to change flags in igraph.pc file (-lc++ to -lstdc++)

Despite my attempts, errors occurred again.
Could anyone tells me what I did wrong?

You did not link to igraph. It is not possible to tell why this happens without knowing how you compile your program. The tutorial presents two options: manual linking guided by pkg-config (more error prone) and CMake (more work to set up, but it won’t fail).

First, just try adding -ligraph to the linking line. If this is not enough, follow the instructions in the tutorial carefully, and if you still can’t get it working, describe what you did in full detail.