1

I am having trouble installing the Stanford C++ Libraries, in particular, the Graph related libraries that I need to use for a project. I am using the Visual Studio IDE, Eclipse IDE, so instructions tailored to either would be appreciated.

I have done the following already:

-> Downloaded and unzipped the library at https://stanford.edu/~stepp/cppdoc/

-> selected the 'collections' folder in StanfordCPPLib as #include directory for Eclipse/Visual Studio

-> things seem to work until this point, and #include works. But During compile time, a ton of other 'unresolved inclusions' occur.

Please can someone who has actually installed the library/willing to do so, help me to do the same. I have spent quite a bit of time trying to solve this myself, and this is a major bottleneck.

Specs: Windows 10 Home MY CODE:

     #include "pch.h"
     #include <iostream>
     #include <collections/basicgraph.h>

     using namespace std;
     int main() {
     BasicGraph g;
     g.addVertex("1");
     g.addVertex("2");
     g.addEdge("1", "2");
    cout<< g.getVertex("1")->name <<endl;
    //boost::optional<int>;
    return 0;
 }  

RESULT:

1>------ Build started: Project: IsolationBranchingImplementation, Configuration: Debug Win32 ------
1>main.cpp
1>main.obj : error LNK2019: unresolved external symbol "void __cdecl stanfordcpplib::staticInitializeLibrary(void)" (?staticInitializeLibrary@stanfordcpplib@@YAXXZ) referenced in function "public: __thiscall stanfordcpplib::StanfordCppLibraryInitializer::StanfordCppLibraryInitializer(void)" (??0StanfordCppLibraryInitializer@stanfordcpplib@@QAE@XZ)
1>main.obj : error LNK2019: unresolved external symbol "void __cdecl error(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?error@@YAXABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function "private: void __thiscall Vector<struct Map<class EdgeGen<void *,void *> *,bool>::iterator::NodeMarker>::checkIndex(int,int,int,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)const " (?checkIndex@?$Vector@UNodeMarker@iterator@?$Map@PAV?$EdgeGen@PAXPAX@@_N@@@@ABEXHHHV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
1>main.obj : error LNK2019: unresolved external symbol "double __cdecl stringToReal(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?stringToReal@@YANABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function "public: virtual void __thiscall BasicGraphGen<void *,void *>::scanArcData(class TokenScanner &,class EdgeGen<void *,void *> *,class EdgeGen<void *,void *> *)" (?scanArcData@?$BasicGraphGen@PAXPAX@@UAEXAAVTokenScanner@@PAV?$EdgeGen@PAXPAX@@1@Z)
1>main.obj : error LNK2019: unresolved external symbol "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall TokenScanner::getStringValue(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)const " (?getStringValue@TokenScanner@@QBE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@ABV23@@Z) referenced in function "private: class VertexGen<void *,void *> * __thiscall Graph<class VertexGen<void *,void *>,class EdgeGen<void *,void *> >::scanNode(class TokenScanner &)" (?scanNode@?$Graph@V?$VertexGen@PAXPAX@@V?$EdgeGen@PAXPAX@@@@AAEPAV?$VertexGen@PAXPAX@@AAVTokenScanner@@@Z)
1>main.obj : error LNK2019: unresolved external symbol "public: enum TokenScanner::TokenType __thiscall TokenScanner::getTokenType(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)const " (?getTokenType@TokenScanner@@QBE?AW4TokenType@1@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function "private: class VertexGen<void *,void *> * __thiscall Graph<class VertexGen<void *,void *>,class EdgeGen<void *,void *> >::scanNode(class TokenScanner &)" (?scanNode@?$Graph@V?$VertexGen@PAXPAX@@V?$EdgeGen@PAXPAX@@@@AAEPAV?$VertexGen@PAXPAX@@AAVTokenScanner@@@Z)
1>main.obj : error LNK2019: unresolved external symbol "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall TokenScanner::nextToken(void)" (?nextToken@TokenScanner@@QAE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ) referenced in function "public: virtual void __thiscall BasicGraphGen<void *,void *>::scanArcData(class TokenScanner &,class EdgeGen<void *,void *> *,class EdgeGen<void *,void *> *)" (?scanArcData@?$BasicGraphGen@PAXPAX@@UAEXAAVTokenScanner@@PAV?$EdgeGen@PAXPAX@@1@Z)
1>main.obj : error LNK2019: unresolved external symbol "public: void __thiscall TokenScanner::saveToken(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?saveToken@TokenScanner@@QAEXABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function "public: virtual void __thiscall BasicGraphGen<void *,void *>::scanArcData(class TokenScanner &,class EdgeGen<void *,void *> *,class EdgeGen<void *,void *> *)" (?scanArcData@?$BasicGraphGen@PAXPAX@@UAEXAAVTokenScanner@@PAV?$EdgeGen@PAXPAX@@1@Z)
1>C:\Users\Aditya Tyagi\source\repos\IsolationBranchingImplementation\Debug\IsolationBranchingImplementation.exe : fatal error LNK1120: 7 unresolved externals
1>Done building project "IsolationBranchingImplementation.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
  • 1
    This is hard to answer without knowing your specific issues. Please, [edit] your question and copy/paste the error messages into question. (Please, don't include a snapshot as image.) In general, it couldn't hurt to take the [Tour](https://stackoverflow.com/tour) for a short introduction into this site. – Scheff's Cat Mar 15 '19 at 06:36

1 Answers1

0

Based on the error, it seems to be missing the library/implementations that it needs to link with to produce the executable. The library in the link that you provided, it's distributed as raw source. What you would have to do is to either incorporate that whole library into your project so that you can include and build it together with your own codes. Or you can build it as a separate project that would create a static library, then you can include its headers like you're currently doing and then link your program with the library that it produced.

Something like this:

MyProject\
  main.cpp
  stanfordlib\
    collections\
      graph.h
      graph.cpp
    ....

then in your code include the library like this,

#include "stanfordlib/collections/graph.h"

This will allow your project to compile the lib and link it with your code.

melpomene
  • 84,125
  • 8
  • 85
  • 148
noobius
  • 1,529
  • 7
  • 14
  • Thank you so much, Melpomene & Noobius! I just transitioned to the Boost Graph Library, and was able to successfully install and use the library. Kind thanks for your help. :) – Aditya Tyagi Mar 29 '19 at 23:51