Platform and tools
- Operating System: Windows 10 Home (64bit)
- Project setup: Microsoft Visual Studio 2019 community edition
- Compiler: Microsoft ® C/C++ Optimizing Compiler Version 19.25.28614
- Compilation option: Microsoft Visual C++ (not msys2)
- Build architecture: x64
Note: Following the steps available here results in an error-free build of igraph as a
Static Library, and
igraphtest works. The issues mentioned below concern only building and using igraph as a
Dynamic Library (.dll).
Note: I generally only develop for Linux and MacOS, and so there is a good chance I missed something crucial. If that is the case, you have my sincerest apologies for taking your time.
1. Linker errors when building igraph as a .dll
The Visual Studio project was setup as recommended. Then in project properties, the Configuration Type was changed to “Dynamic Library (.dll)”.
Building the project resulted in the following linker errors:
a) Error LNK2019 unresolved external symbol _plfit_fmin referenced in function plfit_rbinom igraph-0.8.1-msvc\rbinom.obj
b) Error LNK2019 unresolved external symbol _plfit_round referenced in function plfit_rzeta igraph-0.8.1-msvc\sampling.obj
c) Error LNK2005 expm1 already defined in random.obj igraph-0.8.1-msvc\ucrt.lib(api-ms-win-crt-math-l1-1-0.dll)
Errors (a) and (b) were resolved by commenting out declarations of functions
src/plfit/platform.h. These definitions are enclosed in
#ifdef _MSC_VER, which is expected to be true when using MSVC. In this case however, it is MSVC where including these results in this issue. Perhaps this check requires review?
Error (c ) was resolved by explicitly adding
HAVE_EXPM1 as a preprocessor definition. The code defining the
expm1() function is enclosed in
#ifndef HAVE_EXPM1. Therefore, defining
HAVE_EXPM1 disables the definition.
Resolution of all three issues results in a successful build. The
igraphtest project, after re-configuring it to use the
dll, also runs successfully.
2. Error while linking igraph to a custom C++ application
In my own application, I use
igraph_i_set_attribute_table(&igraph_cattribute_table). Building my application results in the following linker error:
Error LNK2001 unresolved external symbol igraph_cattribute_table
Please note that by adding
igraph_i_set_attribute_table(&igraph_cattribute_table) to the
igraphtest project results in the same error.
In the igraph source,
igraph_cattribute_table as follows:
extern const igraph_attribute_table_t igraph_cattribute_table;
DECLDIR and rebuilding igraph resolves the linker error, as
DECLDIR enables the declaration to be included in the public interface of
Would it be feasible for you to recommend how the entire igraph test suite can be run on Windows with Visual Studio 2019? As the
igraphtestproject lacks coverage, perhaps running the entire test suite would be helpful in highlighting issues such as those mentioned above?
Do the above mentioned issues need to be resolved by updating the igraph code base, or did I simply configure the project incorrectly?
It would be great to have igraph work on Windows 10 just as it does on MacOS and Linux. I’d very much appreciate your thoughts and feedback on this issue.
Thanks & Regards,