I finally got it to compile after fixing a few things.
-
The install script was referencing libAspose.Pdf.Cpp_gcc6.so, but the file was named libAspose.PDF.Cpp_gcc6.so
-
I needed to run “sudo apt-get install libfontconfig” to install required libraries for the project.
-
I needed to run “sudo apt-get install libgl1-mesa-dev” to install required libraries for the project.
Now I am trying to compile a simple project that creates a document, sets the author and outputs to the console, but I am getting the error. From what I can tell the syntax is per the documentation, but it won’t compile.
The build log is:
: ~/src/example $ sudo ./build_gcc.sh
SRC Root:
SHARED LIB PREFIX:
– The CXX compiler identification is GNU 6.5.0
– Check for working CXX compiler: /usr/bin/g+±6
– Check for working CXX compiler: /usr/bin/g+±6 – works
– Detecting CXX compiler ABI info
– Detecting CXX compiler ABI info - done
– Detecting CXX compile features
– Detecting CXX compile features - done
– Project name: Aspose.Pdf.Cpp.Example
– Configuring done
– Generating done
– Build files have been written to: /home/ubuntu/src/example/build
Scanning dependencies of target Aspose.Pdf.Cpp.Example
[ 50%] Building CXX object CMakeFiles/Aspose.Pdf.Cpp.Example.dir/source/main.cpp.o
/home/ubuntu/src/example/source/main.cpp: In function ‘ int main(int, char)** ’:
/home/ubuntu/src/example/source/main.cpp:22:13: error: invalid use of incomplete type ‘ System::SmartPtrAspose::Pdf::DocumentInfo::Pointee_ {aka class Aspose::Pdf::DocumentInfo} ’
info -> set_Author(L"Some Author");
^~
In file included from /home/ubuntu/src/example/source/main.cpp:8:0 :
/home/ubuntu/src/example/…/include/Aspose.PDF.Cpp/Document.h:120:42: note: forward declaration of ‘ System::SmartPtrAspose::Pdf::DocumentInfo::Pointee_ {aka class Aspose::Pdf::DocumentInfo} ’
namespace Aspose { namespace Pdf { class DocumentInfo ; } }
**^~~~~~~~~~~~**
/home/ubuntu/src/example/source/main.cpp:23:48: error: invalid use of incomplete type ‘ System::SmartPtrAspose::Pdf::DocumentInfo::Pointee_ {aka class Aspose::Pdf::DocumentInfo} ’
Console::WriteLine(L"Author: {0}", info -> get_Author());
^~
In file included from /home/ubuntu/src/example/source/main.cpp:8:0 :
/home/ubuntu/src/example/…/include/Aspose.PDF.Cpp/Document.h:120:42: note: forward declaration of ‘ System::SmartPtrAspose::Pdf::DocumentInfo::Pointee_ {aka class Aspose::Pdf::DocumentInfo} ’
namespace Aspose { namespace Pdf { class DocumentInfo ; } }
**^~~~~~~~~~~~**
At global scope:
cc1plus: warning: unrecognized command line option ‘ -Wno-inconsistent-missing-override ’
CMakeFiles/Aspose.Pdf.Cpp.Example.dir/build.make:62: recipe for target ‘CMakeFiles/Aspose.Pdf.Cpp.Example.dir/source/main.cpp.o’ failed
make[2]: *** [CMakeFiles/Aspose.Pdf.Cpp.Example.dir/source/main.cpp.o] Error 1
CMakeFiles/Makefile2:67: recipe for target ‘CMakeFiles/Aspose.Pdf.Cpp.Example.dir/all’ failed
make[1]: *** [CMakeFiles/Aspose.Pdf.Cpp.Example.dir/all] Error 2
Makefile:83: recipe for target ‘all’ failed
make: *** [all] Error 2
./build_gcc.sh: line 12: ./Aspose.Pdf.Cpp.Example: No such file or directory
The source is:
#include <exception>
#include “system/aspose_cpp_library.h”
#include “system/console.h”
#include “system/exceptions.h”
#include “Aspose.PDF.Cpp/Properties/PortingAssemblyInfo.h”
#include “Aspose.PDF.Cpp/Document.h”
using namespace System;
using namespace Aspose::Pdf;
using namespace Aspose::Pdf::Text;
int main(int argc, char** argv)
{
try
{
auto doc = MakeObject();
auto info = doc->get_Info();
info->set_Author(L"Some Author");
Console::WriteLine(L"Author: {0}", info->get_Author());
Console::WriteLine(u"Example finished.");
}
catch (const System::Exception& error)
{
Console::WriteLine(u"Error: {0}", error->get_Message());
return 1;
}
catch (const std::exception& error)
{
std::cerr << "Error: " << error.what() << std::endl;
return 1;
}
return 0;
}