Hello. I am a newcomer using Visual Studio 2022 community edition. This should be easy to solve. I only need to link to a library, as I use some functions in it. But I don't know how to do it.
I have been trying out an example application which I downloaded. This concerns the SP (SGML Parser) library made by James Clark. He is actually the father of XML 1.0 and a lot of other web standards. He is famous. He constructed a library that can be called. He also constructed the following small example which shows basic usage of SP (SGML Parser) library.
When trying to compile his example I get linker errors.
The source for the example:
#include <iostream>
// The next two lines are only to ensure bool gets defined appropriately.
#include "config.h"
#include "Boolean.h"
#include "ParserEventGeneratorKit.h"
#include <iostream>
std::ostream& operator<<(std::ostream& os, SGMLApplication::CharString s)
{
for (size_t i = 0; i < s.len; i++)
os << char(s.ptr[i]);
return os;
}
class OutlineApplication : public SGMLApplication {
public:
OutlineApplication() : depth_(0) { }
~OutlineApplication() {}
void startElement(const StartElementEvent& event) {
for (unsigned i = 0; i < depth_; i++)
std::cout << " ";
std::cout << event.gi << '\n';
depth_++;
}
void endElement(const EndElementEvent&) { depth_--; }
private:
unsigned depth_;
};
int main(int argc, char** argv)
{
ParserEventGeneratorKit parserKit;
// Use all the arguments after argv[0] as filenames.
EventGenerator* egp = parserKit.makeEventGenerator(argc - 1, argv + 1);
OutlineApplication app;
unsigned nErrors = egp->run(app);
delete egp;
return nErrors > 0;
}
When I compile it, I get 23 error messages. The linker can not find the functions that are referenced in this example. First error out of 23:
Severity Code Description Project File Line Suppression State
Error LNK2019 unresolved external symbol "__declspec(dllimport) public: virtual __cdecl SGMLApplication::~SGMLApplication(void)" (__imp_??1SGMLApplication@@UEAA@XZ) referenced in function "public: virtual __cdecl OutlineApplication::~OutlineApplication(void)" (??1OutlineApplication@@UEAA@XZ) SP example 1 C:\Users\Dell\OneDrive\source\repos\SP example 1\SP example 1.obj 1
Second error of 23:
Severity Code Description Project File Line Suppression State
Error LNK2019 unresolved external symbol "__declspec(dllimport) public: __cdecl SGMLApplication::SGMLApplication(void)" (__imp_??0SGMLApplication@@QEAA@XZ) referenced in function "public: __cdecl OutlineApplication::OutlineApplication(void)" (??0OutlineApplication@@QEAA@XZ) SP example 1 C:\Users\Dell\OneDrive\source\repos\SP example 1\SP example 1.obj 1
I suspect that I need to edit properties in Visual Studio 2022 to link to the right library. How do I get rid of these 2 error messages? This should be easy to solve.
Thanks for reading this.