# Issue including igraph using CMake

**URL:** <https://igraph.discourse.group/t/issue-including-igraph-using-cmake/783>\
**Category:** Installation\
**Tags:** C\
**Created:** [16 June 2021 20:39 UTC](https://igraph.discourse.group/t/issue-including-igraph-using-cmake/783 "2021-06-16T20:39:01Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kaz](https://avatars.discourse-cdn.com/v4/letter/k/ecd19e/32.png) [@Kaz](https://igraph.discourse.group/u/Kaz)\
**Post date:** [16 June 2021 20:39 UTC](https://igraph.discourse.group/t/issue-including-igraph-using-cmake/783/1 "2021-06-16T20:39:01Z")

</div>

I’ve successfully compiled and installed igraph. I have the igraph library as part of my project tree in CLion for right now. My program compiles and even recognizes igraph, but when I type

```auto
#include "igraph.h" 

```

or

```auto
#include <igraph.h>

```

I get a very lengthy error:

```auto
C:\Users\Kyle\Downloads\Epi\NetworkModel\igraph-0.9.4\include\igraph_random.h(69): error C2065: ' __deprecated__': undeclared identifier
C:\Users\Kyle\Downloads\Epi\NetworkModel\igraph-0.9.4\include\igraph_random.h(69): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Users\Kyle\Downloads\Epi\NetworkModel\igraph-0.9.4\include\igraph_random.h(69): error C2062: type 'unsigned long' unexpected
C:\Users\Kyle\Downloads\Epi\NetworkModel\igraph-0.9.4\include\igraph_sparsemat.h(266): error C2065: ' __deprecated__': undeclared identifier
C:\Users\Kyle\Downloads\Epi\NetworkModel\igraph-0.9.4\include\igraph_sparsemat.h(266): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Users\Kyle\Downloads\Epi\NetworkModel\igraph-0.9.4\include\igraph_sparsemat.h(266): error C2374: ' __attribute__': redefinition; multiple initialization
C:\Users\Kyle\Downloads\Epi\NetworkModel\igraph-0.9.4\include\igraph_random.h(69): note: see declaration of ' __attribute__'
C:\Users\Kyle\Downloads\Epi\NetworkModel\igraph-0.9.4\include\igraph_sparsemat.h(266): error C2062: type 'int' unexpected
C:\Users\Kyle\Downloads\Epi\NetworkModel\igraph-0.9.4\include\igraph_graphicality.h(55): error C2065: ' __deprecated__': undeclared identifier
C:\Users\Kyle\Downloads\Epi\NetworkModel\igraph-0.9.4\include\igraph_graphicality.h(55): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Users\Kyle\Downloads\Epi\NetworkModel\igraph-0.9.4\include\igraph_graphicality.h(55): error C2374: ' __attribute__': redefinition; multiple initialization
C:\Users\Kyle\Downloads\Epi\NetworkModel\igraph-0.9.4\include\igraph_random.h(69): note: see declaration of ' __attribute__'
C:\Users\Kyle\Downloads\Epi\NetworkModel\igraph-0.9.4\include\igraph_graphicality.h(55): error C2062: type 'int' unexpected
C:\Users\Kyle\Downloads\Epi\NetworkModel\igraph-0.9.4\include\igraph_graphicality.h(59): error C2065: ' __deprecated__': undeclared identifier
C:\Users\Kyle\Downloads\Epi\NetworkModel\igraph-0.9.4\include\igraph_graphicality.h(59): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Users\Kyle\Downloads\Epi\NetworkModel\igraph-0.9.4\include\igraph_graphicality.h(59): error C2374: ' __attribute__': redefinition; multiple initialization
C:\Users\Kyle\Downloads\Epi\NetworkModel\igraph-0.9.4\include\igraph_random.h(69): note: see declaration of ' __attribute__'
C:\Users\Kyle\Downloads\Epi\NetworkModel\igraph-0.9.4\include\igraph_graphicality.h(59): error C2062: type 'int' unexpected
C:\Users\Kyle\Downloads\Epi\NetworkModel\igraph-0.9.4\include\igraph_centrality.h(188): error C2065: ' __deprecated__': undeclared identifier
C:\Users\Kyle\Downloads\Epi\NetworkModel\igraph-0.9.4\include\igraph_centrality.h(188): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Users\Kyle\Downloads\Epi\NetworkModel\igraph-0.9.4\include\igraph_centrality.h(188): error C2374: ' __attribute__': redefinition; multiple initialization
C:\Users\Kyle\Downloads\Epi\NetworkModel\igraph-0.9.4\include\igraph_random.h(69): note: see declaration of ' __attribute__'
C:\Users\Kyle\Downloads\Epi\NetworkModel\igraph-0.9.4\include\igraph_centrality.h(188): error C2062: type 'int' unexpected
C:\Users\Kyle\Downloads\Epi\NetworkModel\igraph-0.9.4\include\igraph_centrality.h(194): error C2065: ' __deprecated__': undeclared identifier
C:\Users\Kyle\Downloads\Epi\NetworkModel\igraph-0.9.4\include\igraph_centrality.h(194): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Users\Kyle\Downloads\Epi\NetworkModel\igraph-0.9.4\include\igraph_centrality.h(194): error C2374: ' __attribute__': redefinition; multiple initialization
C:\Users\Kyle\Downloads\Epi\NetworkModel\igraph-0.9.4\include\igraph_random.h(69): note: see declaration of ' __attribute__'
C:\Users\Kyle\Downloads\Epi\NetworkModel\igraph-0.9.4\include\igraph_centrality.h(194): error C2062: type 'int' unexpected
C:\Users\Kyle\Downloads\Epi\NetworkModel\igraph-0.9.4\include\igraph_centrality.h(198): error C2065: ' __deprecated__': undeclared identifier
C:\Users\Kyle\Downloads\Epi\NetworkModel\igraph-0.9.4\include\igraph_centrality.h(198): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Users\Kyle\Downloads\Epi\NetworkModel\igraph-0.9.4\include\igraph_centrality.h(198): error C2374: ' __attribute__': redefinition; multiple initialization
C:\Users\Kyle\Downloads\Epi\NetworkModel\igraph-0.9.4\include\igraph_random.h(69): note: see declaration of ' __attribute__'
C:\Users\Kyle\Downloads\Epi\NetworkModel\igraph-0.9.4\include\igraph_centrality.h(198): error C2062: type 'int' unexpected
C:\Users\Kyle\Downloads\Epi\NetworkModel\igraph-0.9.4\include\igraph_attributes.h(334): error C2065: ' __deprecated__': undeclared identifier
C:\Users\Kyle\Downloads\Epi\NetworkModel\igraph-0.9.4\include\igraph_attributes.h(334): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Users\Kyle\Downloads\Epi\NetworkModel\igraph-0.9.4\include\igraph_attributes.h(334): error C2374: ' __attribute__': redefinition; multiple initialization
C:\Users\Kyle\Downloads\Epi\NetworkModel\igraph-0.9.4\include\igraph_random.h(69): note: see declaration of ' __attribute__'
C:\Users\Kyle\Downloads\Epi\NetworkModel\igraph-0.9.4\include\igraph_attributes.h(334): error C2146: syntax error: missing ';' before identifier 'igraph_attribute_table_t'
C:\Users\Kyle\Downloads\Epi\NetworkModel\igraph-0.9.4\include\igraph_adjlist.h(52): error C2065: ' __deprecated__': undeclared identifier
C:\Users\Kyle\Downloads\Epi\NetworkModel\igraph-0.9.4\include\igraph_adjlist.h(52): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Users\Kyle\Downloads\Epi\NetworkModel\igraph-0.9.4\include\igraph_adjlist.h(52): error C2374: ' __attribute__': redefinition; multiple initialization
C:\Users\Kyle\Downloads\Epi\NetworkModel\igraph-0.9.4\include\igraph_random.h(69): note: see declaration of ' __attribute__'
C:\Users\Kyle\Downloads\Epi\NetworkModel\igraph-0.9.4\include\igraph_adjlist.h(52): error C2062: type 'int' unexpected
C:\Users\Kyle\Downloads\Epi\NetworkModel\igraph-0.9.4\include\igraph_adjlist.h(89): error C2065: ' __deprecated__': undeclared identifier
C:\Users\Kyle\Downloads\Epi\NetworkModel\igraph-0.9.4\include\igraph_adjlist.h(89): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Users\Kyle\Downloads\Epi\NetworkModel\igraph-0.9.4\include\igraph_adjlist.h(89): error C2374: ' __attribute__': redefinition; multiple initialization
C:\Users\Kyle\Downloads\Epi\NetworkModel\igraph-0.9.4\include\igraph_random.h(69): note: see declaration of ' __attribute__'
C:\Users\Kyle\Downloads\Epi\NetworkModel\igraph-0.9.4\include\igraph_adjlist.h(89): error C2062: type 'int' unexpected
NMAKE : fatal error U1077: 'C:\PROGRA~2\MICROS~2\2019\ENTERP~1\VC\Tools\MSVC\1429~1.300\bin\Hostx86\x86\cl.exe' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.29.30037\bin\HostX86\x86\nmake.exe"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.29.30037\bin\HostX86\x86\nmake.exe"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.29.30037\bin\HostX86\x86\nmake.exe"' : return code '0x2'
Stop.

```

I suspect that there might be a problem with my `CMakeLists.txt` file, but I haven’t been able to figure it out. Thank you!

---

<div class="post-metadata">

**Author:** ![szhorvat](https://yyz2.discourse-cdn.com/free1/user_avatar/igraph.discourse.group/szhorvat/32/3_2.png) [@szhorvat](https://igraph.discourse.group/u/szhorvat)\
**Post date:** [17 June 2021 10:48 UTC](https://igraph.discourse.group/t/issue-including-igraph-using-cmake/783/2 "2021-06-17T10:48:59Z")

</div>

Can you give a _complete_ but _minimal_ example that reproduces the problem? See [http://sscce.org/](http://sscce.org/) for guidance.

---

<div class="post-metadata">

**Author:** ![szhorvat](https://yyz2.discourse-cdn.com/free1/user_avatar/igraph.discourse.group/szhorvat/32/3_2.png) [@szhorvat](https://igraph.discourse.group/u/szhorvat)\
**Post date:** [17 June 2021 11:05 UTC](https://igraph.discourse.group/t/issue-including-igraph-using-cmake/783/3 "2021-06-17T11:05:20Z")

</div>

Also:

What compiler did you use to _install_ igraph? When compiling igraph, you must use the same compiler that you plan to use for your own program.

It looks like you might have used GCC to compile igraph, but you are trying to use it with MSVC.

---

<div class="post-metadata">

**Author:** ![Kaz](https://avatars.discourse-cdn.com/v4/letter/k/ecd19e/32.png) [@Kaz](https://igraph.discourse.group/u/Kaz)\
**Post date:** [17 June 2021 17:33 UTC](https://igraph.discourse.group/t/issue-including-igraph-using-cmake/783/4 "2021-06-17T17:33:08Z")

</div>

I did a fresh install and made sure I was using GCC for compiling and using igraph and I think this fixed my problem. Thank you so much!!

---

<div class="post-metadata">

**Author:** ![szhorvat](https://yyz2.discourse-cdn.com/free1/user_avatar/igraph.discourse.group/szhorvat/32/3_2.png) [@szhorvat](https://igraph.discourse.group/u/szhorvat)\
**Post date:** [17 June 2021 19:26 UTC](https://igraph.discourse.group/t/issue-including-igraph-using-cmake/783/5 "2021-06-17T19:26:23Z")

</div>

To be clear, igraph does work with MSVC, and I do recommend using MSVC on Windows.

However, if you prefer GCC for some reason, that works too. In fact, igraph is already included in MSYS2:

[https://packages.msys2.org/package/mingw-w64-x86\_64-igraph?repo=mingw64](https://packages.msys2.org/package/mingw-w64-x86_64-igraph?repo=mingw64)

What is important is to use the same compiler both for igraph and your program.
