snap-stanford / snap

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

undefined reference #138

Closed SALAH30 closed 4 years ago

SALAH30 commented 6 years ago
i'm trying to use SNAP, with C++, I'm using CLion when i add #include "Snap.h" i had this problem :

CMakeFiles/CNI.dir/main.cpp.o: In function TRStr::~TRStr()': C:/Users/salah-eddine.boukhet/Documents/ETUDE/PFE/subgraph-isomorphism-searche-implementation/snap-master/glib-core/dt.h:366: undefined reference toExeStop(char const, char const, char const, char const, int const&)' C:/Users/salah-eddine.boukhet/Documents/ETUDE/PFE/subgraph-isomorphism-searche-implementation/snap-master/glib-core/dt.h:366:(.text$_ZN5TRStrD1Ev[_ZN5TRStrD1Ev]+0x72): relocation truncated to fit: R_X86_64_PC32 against undefined symbol ExeStop(char const*, char const*, char const*, char const*, int const&)' CMakeFiles/CNI.dir/main.cpp.o: In functionTRStr::UnRef()': C:/Users/salah-eddine.boukhet/Documents/ETUDE/PFE/subgraph-isomorphism-searche-implementation/snap-master/glib-core/dt.h:379: undefined reference to ExeStop(char const*, char const*, char const*, char const*, int const&)' C:/Users/salah-eddine.boukhet/Documents/ETUDE/PFE/subgraph-isomorphism-searche-implementation/snap-master/glib-core/dt.h:379:(.text$_ZN5TRStr5UnRefEv[_ZN5TRStr5UnRefEv]+0x50): relocation truncated to fit: R_X86_64_PC32 against undefined symbolExeStop(char const, char const, char const, char const, int const&)' CMakeFiles/CNI.dir/main.cpp.o: In function TRStr::GetNullRStr()': C:/Users/salah-eddine.boukhet/Documents/ETUDE/PFE/subgraph-isomorphism-searche-implementation/snap-master/glib-core/dt.h:403: undefined reference toExeStop(char const, char const, char const, char const, int const&)' C:/Users/salah-eddine.boukhet/Documents/ETUDE/PFE/subgraph-isomorphism-searche-implementation/snap-master/glib-core/dt.h:403:(.text$_ZN5TRStr11GetNullRStrEv[_ZN5TRStr11GetNullRStrEv]+0xa8): relocation truncated to fit: R_X86_64_PC32 against undefined symbol ExeStop(char const*, char const*, char const*, char const*, int const&)' CMakeFiles/CNI.dir/main.cpp.o: In functionTStr::TStr(char const)': C:/Users/salah-eddine.boukhet/Documents/ETUDE/PFE/subgraph-isomorphism-searche-implementation/snap-master/glib-core/dt.h:427: undefined reference to `TStr::GetRStr(char const)' C:/Users/salah-eddine.boukhet/Documents/ETUDE/PFE/subgraph-isomorphism-searche-implementation/snap-master/glib-core/dt.h:427:(.text$_ZN4TStrC1EPKc[_ZN4TStrC1EPKc]+0x18): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `TStr::GetRStr(char const*)' collect2: error: ld returned 1 exit status make[3]: [CMakeFiles/CNI.dir/build.make:355: CNI.exe] Error 1 make[2]: [CMakeFiles/Makefile2:68: CMakeFiles/CNI.dir/all] Error 2 make[1]: [CMakeFiles/Makefile2:80: CMakeFiles/CNI.dir/rule] Error 2 make: [Makefile:118: CNI] Error 2

jessemapel commented 6 years ago

I am getting these same errors on Fedora 25. I compiled snap.o into a static library using the make lib command in the snap-core makefile, then I link my application against it and get the same set of undefined reference errors.

RubinYao commented 4 years ago

I have the same problem, how to solve?

jessemapel commented 4 years ago

@RubinYao I wasn't able to find a solution for this and ended up going with a different graph library.

RubinYao commented 4 years ago

@jessemapel thanks for your reply, can you tell me which graph library did you use, I want to try, thanks again!

jessemapel commented 4 years ago

@RubinYao We had a lot of success with boost's graph library.

RubinYao commented 4 years ago

@jessemapel thanks.

roks commented 4 years ago

@RubinYao Which OS and compiler do you use?

RubinYao commented 4 years ago

@roks I used snap library under Window 10 with Cygwin with GCC. After downloading the source code from http://snap.stanford.edu/releases/Snap-5.0.zip and zipping, I run "make all" in the main SNAP directory under Cygwin. Then, I create a new C++ project in Eclipse CDT IDE and set the project property: C/C++ General -> paths and symbols -> includes -> GUN C++ : "C:\cygwin64\home\lenovo\Snap-5.0\snap-adv; C:\cygwin64\home\lenovo\Snap-5.0\snap-core; C:\cygwin64\home\lenovo\Snap-5.0\glib-core;". After that, run a helloworld cpp like this `//======================

include < iostream >

include "Snap.h";

using namespace std;

int main() {

cout << "!!!Hello World!!!" << endl; // prints !!!Hello World!!!
return 0;

} ` then get the errors:

/home/lenovo/Snap-5.0/glib-core/dt.h:366: undefined reference to ExeStop(char const*, char const*, char const*, char const*, int const&)' /home/lenovo/Snap-5.0/glib-core/dt.h:366:(.text$_ZN5TRStrD1Ev[_ZN5TRStrD1Ev]+0x62): relocation truncated to fit: R_X86_64_PC32 against undefined symbolExeStop(char const, char const, char const, char const, int const&)' ./src/SNAP.o: In function TRStr::UnRef()': /home/lenovo/Snap-5.0/glib-core/dt.h:379: undefined reference toExeStop(char const, char const, char const, char const, int const&)' /home/lenovo/Snap-5.0/glib-core/dt.h:379:(.text$_ZN5TRStr5UnRefEv[_ZN5TRStr5UnRefEv]+0x40): relocation truncated to fit: R_X86_64_PC32 against undefined symbol ExeStop(char const*, char const*, char const*, char const*, int const&)' ./src/SNAP.o: In functionTRStr::GetNullRStr()': /home/lenovo/Snap-5.0/glib-core/dt.h:403: undefined reference to ExeStop(char const*, char const*, char const*, char const*, int const&)' /home/lenovo/Snap-5.0/glib-core/dt.h:403:(.text$_ZN5TRStr11GetNullRStrEv[_ZN5TRStr11GetNullRStrEv]+0x9e): relocation truncated to fit: R_X86_64_PC32 against undefined symbolExeStop(char const, char const, char const, char const, int const&)' ./src/SNAP.o: In function TStr::TStr(char const*)': /home/lenovo/Snap-5.0/glib-core/dt.h:427: undefined reference toTStr::GetRStr(char const)' /home/lenovo/Snap-5.0/glib-core/dt.h:427:(.text$_ZN4TStrC1EPKc[_ZN4TStrC1EPKc]+0x18): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `TStr::GetRStr(char const)' collect2: error: ld returned 1 exit status make: *** [makefile:47: SNAP.exe] Error 1

then I try the Visual studio 2019 and configure the environment following the steps "SNAP on Windows with Visual Studio", also have the same problem.

trevorKirkby commented 4 years ago

I just ran into the same issue on Ubuntu 18.04.4 LTS, using the ordinary GCC that comes out of the box with Ubuntu, compiling pretty much the same program RubinYao tried out, just including "Snap.h" without doing anything else. I looked around for where "ExeStop" is supposed to be defined, and it's under "glib-core/bd.h", so I guess for some reason that file isn't getting included when it should be? I tried forcibly including that file in the command line options to see what happens, but it appears doing that creates a large number of other errors.

roks commented 4 years ago

try "cd Snap-5.0/examples/testgraph; make; ./testgraph". This works on our version of Ubuntu 18.04. If the command is successful, you can start with testgraph and modify it for your purpose. It compile command is "g++ -std=c++98 -Wall -O3 -DNDEBUG -fopenmp -o testgraph testgraph.cpp ../../snap-core/Snap.o -I../../snap-core -I../../snap-adv -I../../glib-core -I../../snap-exp -lrt'.

dngurdl commented 4 years ago

Platform: FreeBSD11 + gcc 9.3.0 (C++11) main src file (BellmanFord.cpp): 'include "Snap.h"' and instantiates a (directed) PNGraph. SNAP: compiled from source (version: 5.0)

I am tinkering with SNAP to implement Bellman-Ford on a directed computer networks graph. I also ran into the ExeStop error when gcc links my main application + (static library) libsnap.a.

The main issue is that order matters when you link: my Makefile changed the order of object file and LDFLAGS linker flags gcc $(LDFLAGS) -lsnap BellmanFord.o -o BellmanFord ===> gcc BellmanFord.o $(LDFLAGS) -lsnap -o BellmanFord

This resolved the ExeStop +GetRStr errors. (after which other issues came up)