Compiling Igraph_test.c

Hi
Igraph Libraries was built from visual studio 2019 using (igraph-0.8.1-msvc version )
I tried to compile it with mingw64, by using this command:

gcc igraph_test.c -I/include/igraph -L/Release -ligraph -o igraph_test

I got this message:

C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -ligraph
collect2.exe: error: ld returned 1 exit status

I have tried to issue this command:

pkg-config --libs --cflags igraph

but it shows me the following message:

Package igraph was not found in the pkg-config search path.
Perhaps you should add the directory containing `igraph.pc'
to the PKG_CONFIG_PATH environment variable
No package 'igraph' found

Could you help me with that please? I really appreciate it

It look like you have not yet compiled the actual igraph library itself. Could you perhaps provide some details how you compiled the igraph library itself? The general instructions can be found here.

Thank you Traag for the quick reply.

I followed these steps:
1- downloaded igraph-0.8.1-msvc
2- Uncompress the file into C:\Visual Studio 2019\Projects
3- Open the igraph.sln solution file in igraph-0.8.1-msvc\igraph-0.8.1-msvc directory from Visual Studio 2019.
4- Visual Studio asked me to convert the solution files (igraph.sln AND igraph.vcproj) to the current format
5- Just click on Next, Next and Finish.
6- On the toolbar, change ‘Debug’ to ‘Release’.
7- Right click on igraph project from Solution Explorer -> Build solution
8- waiting until the library is built successfully.
9- on the toolbar, choose Tools -> Command Line -> Developer PowerShell
10- run the previous commands ( at the main question)
gcc igraph_test.c -I/include/igraph -L/Release -ligraph -o igraph_test

Thanks for the additional details. Is there any particular reason why you want to compile the igraph DLL with MSVC, yet try to link it using MinGW? It is possible I believe, but you should probably read this to make sure how to do this, I have not tried to do so myself. It would probably be simpler if you would simple compile igraph also with MinGW.

I’ll second that you really should not mix compilers. igraph can be compiled with MinGW. If you are going to use it with MinGW, compile it with MinGW.

You use the compiler flag -L/Release. The directory /Release, with the leading /, refers to C:/Release. It is an absolute path. If that is not where the library was placed, then this is one reason why it didn’t work.

The mismatch in library formats between the different compilers could be (likely is) another reason, but I am not sufficiently experienced with Windows to say for sure. Doesn’t MSVC produce igraph.lib while gcc will be looking for libigraph.a?

Thank you for your comments:

I had followed your guidelines. after I did configure which works fine and then use “make” command, I got the following errors:

libtool: link: (cd .libs/libigraph.lax/libf2c.a && ar x "/c/igraph-0.8.1/src/./.libs/libf2c.a")
libtool:   error: object name conflicts in archive: .libs/libigraph.lax/libf2c.a//c/igraph-0.8.1/src/./.libs/libf2c.a
make[3]: *** [Makefile:3713: libigraph.la] Error 1
make[3]: Leaving directory '/c/igraph-0.8.1/src'
make[2]: *** [Makefile:2452: all] Error 2
make[2]: Leaving directory '/c/igraph-0.8.1/src'
make[1]: *** [Makefile:502: all-recursive] Error 1
make[1]: Leaving directory '/c/igraph-0.8.1'
make: *** [Makefile:405: all] Error 2

which should I do please?

regarding the previous issue, I have found the soluation in this link. :slight_smile: