How to create static library using existing .cpp and .h files (in this case SNAP library)

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hi Guys,
I am encountering a problem while trying to create a static library from the provided snap and glib codes though I have not changed any file.
My intention is to create a static library using the code from Snap library ( http://snap.stanford.edu/snap/download.html http://snap.stanford.edu/snap/download.html ) and then to reference it from my project. So I created a VC project (by
name SnapLib) of type standard library (.lib) and created a Header file and .cpp file of the same name. In these two files I copied the same code as in Snap.h and Snap.cpp. Now, based on SnapLib.h, I copied and pasted the included header and .cpp files into
my SnapLib project from the downloaded project location.
<span style="border-collapse:collapse; color:#333333; font-family:arial,sans-serif; font-size:13px
Then from the command line I tried to compile the library to generate SnapLib.obj just to get the below errors where it says that CntNonZNodes is not a member of TSnap though I found the function CntNonZNodes defined within TSnap in alg.h.
<br/>
<span style="color:#000099 C:UsersSomnathDocumentsVisual Studio 2008ProjectsSnapLib>cl /c /EHsc SnapL<br/>
ib.cpp<br/>
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 15.00.21022.08 for 80x86<br/>
Copyright (C) Microsoft Corporation. All rights reserved.<br/>
<br/>
SnapLib.cpp
<span style="color:#000099 C:UsersSomnathDownloadsSnap-10-10-01snaptimenet.cpp(326) : error C2039: C<br/>
ntNonZNodes : is not a member of TSnap<br/>
C:UsersSomnathDownloadsSnap-10-10-01snaptimenet.cpp(326) : error C3861: C<br/>
ntNonZNodes: identifier not found<br/>
C:UsersSomnathDownloadsSnap-10-10-01snaptimenet.cpp(334) : error C2039: C<br/>
ntNonZNodes : is not a member of TSnap<br/>
C:UsersSomnathDownloadsSnap-10-10-01snaptimenet.cpp(334) : error C3861: C<br/>
ntNonZNodes: identifier not found<br/>
C:UsersSomnathDownloadsSnap-10-10-01snaptimenet.cpp(373) : error C2039: C<br/>
ntInDegNodes : is not a member of TSnap<br/>
C:UsersSomnathDownloadsSnap-10-10-01snaptimenet.cpp(374) : error C2039: C<br/>
ntOutDegNodes : is not a member of TSnap<br/>
C:UsersSomnathDownloadsSnap-10-10-01snaptimenet.cpp(373) : error C3861: C<br/>
ntInDegNodes: identifier not found<br/>
C:UsersSomnathDownloadsSnap-10-10-01snaptimenet.cpp(374) : error C3861: C<br/>
ntOutDegNodes: identifier not found<br/>
C:UsersSomnathDownloadsSnap-10-10-01snaptimenet.cpp(460) : error C2039: C<br/>
ntDegNodes : is not a member of TSnap<br/>
C:UsersSomnathDownloadsSnap-10-10-01snaptimenet.cpp(460) : error C3861: C<br/>
ntDegNodes: identifier not found<br/>
C:UsersSomnathDownloadsSnap-10-10-01snaptimenet.cpp(541) : error C2039: C<br/>
ntDegNodes : is not a member of TSnap<br/>
C:UsersSomnathDownloadsSnap-10-10-01snaptimenet.cpp(541) : error C3861: C<br/>
ntDegNodes: identifier not found
<span style="color:#000099 <span style="color:#333333
<br/>

In short, I am trying to create a static library from some downloaded .cpp and .h codes but facing some problems. The error message says that the functions are not a member of TSnap namespace though in the header file alg.h the functions are defined
and declared within namespace.
Any help will be appreciated.
<br/>

Thanks,
Somnath




View the full article
 
Back
Top