We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Visual Studio 2019 Won't Build for Linux Remote on C++

I am trying to complete a POC using Apose.PDF for C++ for a Linux Console Application. I created a basic project for Linux in Visual Studio 2019 with a remote connection to a Linux server for a remote build. Prior to adding the Aspose.PDF library the project builds fine. When I add the Aspose.PDF library using NuGet and then try to include “Aspose::Pdf/document.h” no intellitense for “Aspose::Pdf” appears. The only option I get is the “package” folder.

So instead using intellisense I included the following:

#include “packages/Aspose.PDF.Cpp.20.4.0/build/native/include/Aspose.PDF.Cpp/Document.h”

Then it complains that the file cannot be found on build, so I went to the folder and right-clicked on the file and chose “include in project”. Next I go the error:
“xml/xpath/i_xpath_navigable.h: No such file or directory”

Even after including that file it still is saying the file is not found.

My intent is to create a console application that can be run in Linux in an Ubuntu Docker Container along side with other applications.

Is there a better approach to develop a Linux Console application in C++ using Apose.Pdf with the target OS to be Ubuntu not running on a windows machine, or is there something I am doing wrong here?

One thing to note is that when I create a windows console project following the same steps adding via NutGet everything works and compiled. It is just when I try to create a Linux remote console app it is failing.

@sulox45

Thanks for contacting support.

Would you kindly try to download Aspose.PDF for C++ Linux release from our website and use it in Linux environment. However, if you still face any issue, please feel free to let us know. We will further proceed to assist you accordingly.

Thank you. I extracted the zip to an ubuntu linux box and then executed the ./build_gcc.sh and got some errors. I’m running version 3.10 of cmake.

: ~/src/example $ ./build_gcc.sh

– The CXX compiler identification is GNU 7.5.0

– Check for working CXX compiler: /usr/bin/g++

– Check for working CXX compiler: /usr/bin/g++ – 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

make[2]: *** No rule to make target ‘…/…/lib/libAspose.Pdf.Cpp_gcc7.so’, needed by ‘Aspose.Pdf.Cpp.Example’. Stop.

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

@sulox45

We are looking into this and will get back to you shortly.

1 Like

Has there been any progress on this? I really need to get this working soon or I’ll need to look for alternative solutions. I like your libraries as I’ve used them in the past. If you can get this working for me, then I’ll move forward to purchase as I’ve already been able to demonstrate in windows that the library does what I need it to do.

@sulox45

We have investigated the scenario and found that you are trying to use the API in gcc 7.5.0 compiler whereas we only support gcc 6 compiler. We need to further look if gcc 7 compiler support can be added in future. Would you please try to use the API in supported environment and in case you face any issue, please feel free to let us know.

Sure, thanks, I’ll try that with the gcc 6 compiler and will let you know if that works.

I just installed the gcc-6 and g+±6 and edited the install file exports

export CC=gcc
export CXX=g++

to be

export CC=gcc-6
export CXX=g+±6

and then I get the following:

: ~/src/example $ sudo ./build_gcc.sh

– 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:7:44: fatal error: Properties/PortingAssemblyInfo.h: No such file or directory

#include “Properties/PortingAssemblyInfo.h”

^

compilation terminated.

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

I found the issue with the error above. Apparently in the main.cpp file the include path was wrong for the PortingAssemblyInfo.h should have been Aspose.Pdf.Cpp/Properties/PortingAssemblyInfo.h. Once changed I am now getting the previous error as before. Here is the current output.

: ~/src/example $ sudo ./build_gcc.sh

– 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

make[2]: *** No rule to make target ‘…/…/lib/libAspose.Pdf.Cpp_gcc6.so’, needed by ‘Aspose.Pdf.Cpp.Example’. Stop.

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

I finally got it to compile after fixing a few things.

  1. The install script was referencing libAspose.Pdf.Cpp_gcc6.so, but the file was named libAspose.PDF.Cpp_gcc6.so

  2. I needed to run “sudo apt-get install libfontconfig” to install required libraries for the project.

  3. 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;

}

@sulox45

Thanks for sharing further details.

We are looking into the issue you are facing. Meanwhile, would you please make sure to include all necessary header files in your program. We will get back to you soon upon this.

I think that may be part of the problem as the documentation for linux with the library is very limited. What I am doing is a very basic test, so I assume I have all the right headers, but that could be the problem is some headers are missing. Based on the windows c++ example, I’ve included all the required headers.

@sulox45

Please try including DocumentInfo.h class in the header.

When I do that and try to compile I get a new set of errors. The following is the trace.

:~/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:23:40: error: no matching function for call to ‘Aspose::Pdf::DocumentInfo::set_Author(const wchar_t [12])’
info->set_Author(L"Matt Meyers");
^
In file included from /home/ubuntu/src/example/source/main.cpp:9:0:
/home/ubuntu/src/example/…/include/Aspose.PDF.Cpp/DocumentInfo.h:58:10: note: candidate: void Aspose::Pdf::DocumentInfo::set_Author(System::String)
void set_Author(System::String value);
^~~~~~~~~~
/home/ubuntu/src/example/…/include/Aspose.PDF.Cpp/DocumentInfo.h:58:10: note: no known conversion for argument 1 from ‘const wchar_t [12]’ to ‘System::String’
/home/ubuntu/src/example/source/main.cpp:24:62: error: no matching function for call to ‘System::Console::WriteLine(const wchar_t [12], System::String)’
Console::WriteLine(L"Author: {0}", info->get_Author());
^
In file included from /home/ubuntu/src/example/source/main.cpp:4:0:
/home/ubuntu/src/example/…/include/asposecpplib/system/console.h:91:42: note: candidate: static void System::Console::WriteLine()
static ASPOSECPP_SHARED_API void WriteLine();
^~~~~~~~~
/home/ubuntu/src/example/…/include/asposecpplib/system/console.h:91:42: note: candidate expects 0 arguments, 2 provided
/home/ubuntu/src/example/…/include/asposecpplib/system/console.h:97:21: note: candidate: template static void System::Console::WriteLine(System::SharedPtr&)
static void WriteLine(const SharedPtr& object)
^~~~~~~~~
/home/ubuntu/src/example/…/include/asposecpplib/system/console.h:97:21: note: template argument deduction/substitution failed:
/home/ubuntu/src/example/source/main.cpp:24:62: note: mismatched types ‘System::SharedPtr’ and ‘const wchar_t [12]’
Console::WriteLine(L"Author: {0}", info->get_Author());
^
In file included from /home/ubuntu/src/example/source/main.cpp:4:0:
/home/ubuntu/src/example/…/include/asposecpplib/system/console.h:104:42: note: candidate: static void System::Console::WriteLine(bool)
static ASPOSECPP_SHARED_API void WriteLine(bool value);
^~~~~~~~~
/home/ubuntu/src/example/…/include/asposecpplib/system/console.h:104:42: note: candidate expects 1 argument, 2 provided
/home/ubuntu/src/example/…/include/asposecpplib/system/console.h:107:42: note: candidate: static void System::Console::WriteLine(char_t)
static ASPOSECPP_SHARED_API void WriteLine(char_t value);
^~~~~~~~~
/home/ubuntu/src/example/…/include/asposecpplib/system/console.h:107:42: note: candidate expects 1 argument, 2 provided
/home/ubuntu/src/example/…/include/asposecpplib/system/console.h:110:42: note: candidate: static void System::Console::WriteLine(System::SharedPtr<System::Array<char16_t> >&)
static ASPOSECPP_SHARED_API void WriteLine(const SharedPtr<Array<char_t>>& buffer);
^~~~~~~~~
/home/ubuntu/src/example/…/include/asposecpplib/system/console.h:110:42: note: candidate expects 1 argument, 2 provided
/home/ubuntu/src/example/…/include/asposecpplib/system/console.h:113:42: note: candidate: static void System::Console::WriteLine(System::Decimal)
static ASPOSECPP_SHARED_API void WriteLine(Decimal value);
^~~~~~~~~
/home/ubuntu/src/example/…/include/asposecpplib/system/console.h:113:42: note: candidate expects 1 argument, 2 provided
/home/ubuntu/src/example/…/include/asposecpplib/system/console.h:116:42: note: candidate: static void System::Console::WriteLine(double)
static ASPOSECPP_SHARED_API void WriteLine(double value);
^~~~~~~~~
/home/ubuntu/src/example/…/include/asposecpplib/system/console.h:116:42: note: candidate expects 1 argument, 2 provided
/home/ubuntu/src/example/…/include/asposecpplib/system/console.h:119:42: note: candidate: static void System::Console::WriteLine(float)
static ASPOSECPP_SHARED_API void WriteLine(float value);
^~~~~~~~~
/home/ubuntu/src/example/…/include/asposecpplib/system/console.h:119:42: note: candidate expects 1 argument, 2 provided
/home/ubuntu/src/example/…/include/asposecpplib/system/console.h:122:42: note: candidate: static void System::Console::WriteLine(int32_t)
static ASPOSECPP_SHARED_API void WriteLine(int32_t value);
^~~~~~~~~
/home/ubuntu/src/example/…/include/asposecpplib/system/console.h:122:42: note: candidate expects 1 argument, 2 provided
/home/ubuntu/src/example/…/include/asposecpplib/system/console.h:125:42: note: candidate: static void System::Console::WriteLine(int64_t)
static ASPOSECPP_SHARED_API void WriteLine(int64_t value);
^~~~~~~~~
/home/ubuntu/src/example/…/include/asposecpplib/system/console.h:125:42: note: candidate expects 1 argument, 2 provided
/home/ubuntu/src/example/…/include/asposecpplib/system/console.h:128:42: note: candidate: static void System::Console::WriteLine(const System::String&)
static ASPOSECPP_SHARED_API void WriteLine(const String& value);
^~~~~~~~~
/home/ubuntu/src/example/…/include/asposecpplib/system/console.h:128:42: note: candidate expects 1 argument, 2 provided
/home/ubuntu/src/example/…/include/asposecpplib/system/console.h:131:42: note: candidate: static void System::Console::WriteLine(const char_t*)
static ASPOSECPP_SHARED_API void WriteLine(const char_t * value);
^~~~~~~~~
/home/ubuntu/src/example/…/include/asposecpplib/system/console.h:131:42: note: candidate expects 1 argument, 2 provided
/home/ubuntu/src/example/…/include/asposecpplib/system/console.h:134:42: note: candidate: static void System::Console::WriteLine(const System::TypeInfo&)
static ASPOSECPP_SHARED_API void WriteLine(const TypeInfo& value);
^~~~~~~~~
/home/ubuntu/src/example/…/include/asposecpplib/system/console.h:134:42: note: candidate expects 1 argument, 2 provided
/home/ubuntu/src/example/…/include/asposecpplib/system/console.h:137:42: note: candidate: static void System::Console::WriteLine(uint32_t)
static ASPOSECPP_SHARED_API void WriteLine(uint32_t value);
^~~~~~~~~
/home/ubuntu/src/example/…/include/asposecpplib/system/console.h:137:42: note: candidate expects 1 argument, 2 provided
/home/ubuntu/src/example/…/include/asposecpplib/system/console.h:140:42: note: candidate: static void System::Console::WriteLine(uint64_t)
static ASPOSECPP_SHARED_API void WriteLine(uint64_t value);
^~~~~~~~~
/home/ubuntu/src/example/…/include/asposecpplib/system/console.h:140:42: note: candidate expects 1 argument, 2 provided
/home/ubuntu/src/example/…/include/asposecpplib/system/console.h:145:42: note: candidate: static void System::Console::WriteLine(System::SharedPtr<System::Array<char16_t> >&, int, int)
static ASPOSECPP_SHARED_API void WriteLine(const SharedPtr<Array<char_t>>& buffer, int index, int count);
^~~~~~~~~
/home/ubuntu/src/example/…/include/asposecpplib/system/console.h:145:42: note: candidate expects 3 arguments, 2 provided
/home/ubuntu/src/example/…/include/asposecpplib/system/console.h:148:42: note: candidate: static void System::Console::WriteLine(const Exception&)
static ASPOSECPP_SHARED_API void WriteLine(const System::Exception &e);
^~~~~~~~~
/home/ubuntu/src/example/…/include/asposecpplib/system/console.h:148:42: note: candidate expects 1 argument, 2 provided
/home/ubuntu/src/example/…/include/asposecpplib/system/console.h:155:21: note: candidate: template<class … Args> static void System::Console::WriteLine(const System::String&, const Args& …)
static void WriteLine(const String& format, const Args&… args)
^~~~~~~~~
/home/ubuntu/src/example/…/include/asposecpplib/system/console.h:155:21: note: template argument deduction/substitution failed:
/home/ubuntu/src/example/source/main.cpp:24:62: note: cannot convert ‘“A\000\000\000u\000\000\000t\000\000\000h\000\000\000o\000\000\000r\000\000\000:\000\000\000 \000\000\000{\000\000\0000\000\000\000}\000\000\000\000\000\000”’ (type ‘const wchar_t [12]’) to type ‘const System::String&’
Console::WriteLine(L"Author: {0}", info->get_Author());

@sulox45

Please use u"" for string literals like
info->set_Author(u"Matt Meyers");
instead of
info->set_Author(L"Matt Meyers");

That seemed to do it. I now have it pulling the author from the actual package. Now that I have a base app building, can you please direct me to where I should be looking specifically for linux what the includes should be for the methods I am calling as the documentation seems more general in nature and I’ve been having to do a lot of guessing when it came to linux development. I was able to pretty quickly get a windows POC up and running, but I found that didn’t translate too well to linux for required includes.

@sulox45

You may please check Aspose.PDF for C++ API Reference Section in order to know inherited members of each class. Furthermore, usage of the API in the Linux environment is almost similar to the Windows except for the changes which have already been discussed in this forum thread. In case you still experience any issue, please feel free to let us know.

Thank you. I am running into one more issue that I spent all day yesterday on and couldn’t find a resolution. I am now trying to pass the file path as a parameter when starting the console application to pass to the Document constructor. The problem is that console applications can only take parameters as a char *[], but your Document constructor is expecting a char16_t[]. Do you have any code snippets you can share that show how to send a file path from a console application parameter to the Document() constructor? I’ve tried various conversion methods, but none seem to work.

@sulox45

Please try following code snippet:

static function System::String::FromUtf8 creates System::String instances from char*:
#include "system/console.h"

int main(int argc, char* args[])
{
	System::Console::WriteLine(argc);
	for (int i = 0; i < argc; i++)
	{
		System::String str = System::String::FromUtf8(args[i]);
		System::Console::WriteLine(str);
	}
}

Thanks that worked. Hopefully the rest is more straight-forward like I was able to do already in c++ in windows. I’ll let you know if I have any other issues.