Install Aspose.Words for C++ Package into Ubuntu Project | CMake Lists | VSCode | Aspose.Words.Cpp

I hava an across platform project which needs to use Aspose.Words.Cpp. One platform is Windows and another is Ubuntu.
I ran command Install-Package Aspose.Words.Cpp from Package Manager Console in Visual Studio to install package on Windows.
On Ubuntu, I use VSCode as IDE, but it seems there’s no good package management plug-ins. I installed NuGet package management plug-in, but it appears only supports .NET packages.
So how can I install Aspose.Words.Cpp package in my Ubuntu project?
I also manually downloaded Linux zip, but why there’s .so file but no .a file?

@clarence.guo,

Please use Aspose.Words for C++ 20.10 Linux Package from the following page:

As far as I know, Linux dynamic libraries (.so file) does not require .a file unlike Windows. But you can check CMake example project - it works both on Windows and Linux.

@awais.hafeez
Yes, I’m using this Linux package. I meant is there a detailed guide to tell me how to configure Aspose.Words in my own Linux project like this Windows’ one: https://docs.aspose.com/words/cpp/configure-aspose-words-for-cpp-in-visual-studio/?
Or in another words, when I call Aspose.Words’ methods in my Linux project, how the code know direct to the so file of Aspose.Words?
Thanks

@clarence.guo,

We have logged your query in our issue tracking system. Your ticket number is:

  • WORDSCPP-1027 : Provide a step by step guide to configure Aspose.Words for C++ in Linux projects

We will further look into the details of this requirement and will keep you updated on the status of the linked ticket.

@awais.hafeez Thank you and may I have the ticket link here as I don’t know how to locate this ticket

@clarence.guo,

Unfortunately, there is no direct way that you can use to interact with the issue tracking system. But, you are welcome to ask your issue status via the forum threads. We will verify the status from our internal issue tracking system and reply you about the progress.

Regarding WORDSCPP-1027, according to https://www.jetbrains.com/lp/devecosystem-2020/cpp/, the following IDE and build systems are most popular:

  • CLion
  • Visual Studio Code
  • Vim
  • QtCreator
  • CMake
  • Makefiles
  • QMake
  • Autotools

We will try to write a guide for the most common IDE and build systems.

But, there may be more different project models and build systems for C++. Can you please inform us what IDE and build system are you using?

@awais.hafeez
Thank you. I’m using Ubuntu 18.04 LTS on Windows 10 WSL, CMake 3.18.4 & make.

@clarence.guo,

How to add Aspose.Words for C++ into you CMake project.

Let’s suppose you have the following CMake project:

CMakeLists.txt:

cmake_minimum_required(VERSION 3.18 FATAL_ERROR)
project(app CXX)
add_executable(app main.cpp)

main.cpp:

int main()
{
    return 0;
}
  • Step 1: Download latest Aspose.Words for C++ package
  • Step 2: Copy Aspose.Words.Cpp and CodePorting.Native.Cs2Cpp_api_. folders next to your CMakeLists.txt
  • Step 3: Add the following lines to your CMakeLists.txt

# find Aspose.Words for C++ package and it's dependencies
find_package(CodePorting.Native.Cs2Cpp REQUIRED CONFIG PATHS ${CMAKE_CURRENT_SOURCE_DIR} NO_DEFAULT_PATH)
find_package(Aspose.Words.Cpp REQUIRED CONFIG PATHS ${CMAKE_CURRENT_SOURCE_DIR} NO_DEFAULT_PATH)
find_package(Threads REQUIRED)

# Link target application with Aspose.Words for C++
target_link_libraries(app PRIVATE Aspose::Words Threads::Threads) 

Now you can build you application with Aspose.Words for C++

cd <path_to_dir_with_CMakeLists.txt>
cmake -S . -B build -D CMAKE_BUILD_TYPE=Release
cmake --build build
./build/app

@awais.hafeez Thank you for so detialed a guide.
I found another way and it works in my project. Share the steps with you:

  1. Download latest Aspose.Words for C++ package and unzipped under my project
  2. Add two include directories of Aspose.Words in CMakeLists.txt of my project
    INCLUDE_DIRECTORIES(…/Aspose.Words.Cpp_20.10_linux/Aspose.Words.Cpp/include)
    INCLUDE_DIRECTORIES(…/Aspose.Words.Cpp_20.10_linux/CodePorting.Native.Cs2Cpp_api_20.10/include)
  3. cmake .
  4. Call below compile link command to link two Aspose.Words’ so files to my project:
    /usr/bin/c++ -O3 -DNDEBUG -rdynamic CMakeFiles/mycode.dir/mycode.cpp.o -o mycode mysopath/libaspose_cpp_gcc6.so mysopath/libAspose.Words.Cpp_gcc9.so -ldl -lpthread -luuid -lrt
  5. make
  6. Copy two Aspose.Words so files to /usr/local/lib
    cp mysopath/libAspose.Words.Cpp_gcc9.so /usr/local/lib
    cp mysopath/libaspose_cpp_gcc6.so /usr/local/lib
  7. Export /usr/local/lib to LD_LIBRARY_PATH so that my code can get so files in runtime
    export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
  8. ldconfig

@clarence.guo,

It is great that you were able to find what you were looking for and thanks for sharing your solution which may also help other developers who are looking to solve similar problem.