snap-stanford / snap

Stanford Network Analysis Platform (SNAP) is a general purpose network analysis and graph mining library.
Other
2.16k stars 797 forks source link

How can I use SNAP in my own project? #170

Closed verniyb closed 4 years ago

verniyb commented 5 years ago

I am a Linux user, using CLion as my IDE and C/C++ for programming.

I've tried to compile given examples and it works, while what I want to do is not simply modify the example but to use SNAP as a standard library, for example, LEMON, using commands like make all sudo make install and then #include<xxx/Snap.h> in my project.

There is a make command libinstall in /snap/snap-core/Makefile, but it doesn't seem to work properly (glib-core needed?).

Then I copied all .cpp and .h files from folders "snap-core" "snap-adv" "glib-core" to my own project, include them like other codes wrote by myself, failed. It was not as easy as I thought.

Is there anyone who knows how to make it? Thanks a lot :)

ion-turcanu commented 5 years ago

I am also interested in this

ThomasThelen commented 4 years ago

You need to let the compiler/linker know where to look for header files. I've only tried this on windows with Visual Studio 2017.

I set the following directories to be included and things worked fine. snap-core snap-adv glib-core

You should include the "Snap.h" header in whichever cpp file you're using the library.

mohamadmahdi3 commented 4 years ago

I have the same issue.

ThomasThelen commented 4 years ago

The Makefile is for the examples. You shouldn't be touching that file for your own personal projects; it's completely unrelated. Have you told GCC or whatever toolchain you're using which directories to include?

If you want to use makefiles, then mimic the ones in the examples. The main Makefile should point you to all of the dependencies.

roks commented 4 years ago

The "testgraph" example is provided for this purpose. Make sure that you can compile it, then modify it with your code.