I am attempting to familiarize myself with the DocxFactory Library (library for c++ that helps with docx)
Currently attempting to do exercise one which involves running the following to generate a docx template.
#include "WordProcessingMerger.h"
#include "WordProcessingCompiler.h"
#include <iostream>
#include <exception>
#include <ctime>
#include <tchar.h>
using namespace DocxFactory;
using namespace std;
int main()
{
try
{
WordProcessingCompiler& l_compiler =
WordProcessingCompiler::getInstance();
time_t l_start = clock();
l_compiler.compile(
"/opt/DocxFactory/exercises/templates/top_level_items.docx",
"/opt/DocxFactory/exercises/templates/top_level_items.dfw");
cout << "Completed (in "
<< (double)(clock() - l_start) / CLOCKS_PER_SEC
<< " seconds)."
<< endl;
}
catch (const exception& p_exception)
{
cout << p_exception.what() << endl;
}
} // main
I run into around 50 errors many of which i assume are linking errors (i suspect it's due to improper library configuration). Such as LINK 2019 LINK 1120
I've looked at multiple results for those errors but no luck.
I have done the following steps in visual studio 2013
- Add the DocxFactory\bin\ directory to the Windows PATH
- Add the DocxFactory/include/ directory to the list of include directories
- Link to the DocxFactory.lib library under the linker section
- Include the corresponding DocxFactory.lib under the Linker input
- Included the .cpp files and .h files in the code
I'm unsure of which step i missed, or if its due to my unfamiliarity of using external libraries.
EDIT I've reinstalled it and have gotten it down to three errors (fixed a tiny PATH error)
Error 3 error LNK1120: 2 unresolved externals c:\users\100489004\documents\visual studio 2013\Projects\docxfinal\Debug\docxfinal.exe 1 1 docxfinal Error 1 error LNK2019: unresolved external symbol "public: static class DocxFactory::WordProcessingCompiler & __cdecl DocxFactory::WordProcessingCompiler::getInstance(void)" (?getInstance@WordProcessingCompiler@DocxFactory@@SAAAV12@XZ) referenced in function _main c:\Users\100489004\documents\visual studio 2013\Projects\docxfinal\docxfinal\Source.obj docxfinal Error 2 error LNK2019: unresolved external symbol "public: void __thiscall DocxFactory::WordProcessingCompiler::compile(class std::basic_string,class std::allocator > const &,class std::basic_string,class std::allocator > const &)" (?compile@WordProcessingCompiler@DocxFactory@@QAEXABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@0@Z) referenced in function _main c:\Users\100489004\documents\visual studio 2013\Projects\docxfinal\docxfinal\Source.obj docxfinal
Something interesting to note when i add the .cpp two corresponding cpp files as per instructions it appears to break the linker so the amount of errors jump to 50 again. So for now i simply have chosen not to included the .cpp files in the project. Unsure if this is correct or not