Issue including igraph using CMake

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

#include "igraph.h" 

or

#include <igraph.h>

I get a very lengthy error:

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!

Can you give a complete but minimal example that reproduces the problem? See http://sscce.org/ for guidance.

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.

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!!

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

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

1 Like