-1

I want to use this library https://github.com/troldal/OpenXLSX on my linux machine. How do I install or use libraries found on Gitub?

Also how do I know what compiler flags to use?

2
  • 1
    Note the CMakeLists.txt file. It means that the library should be built with CMake. See: stackoverflow.com/a/7859663/2752075 Commented Dec 1, 2019 at 21:07
  • GitHub is just a place to put things. Installation instructions differ wildly by project (some aren't even code!) and are usually included with the project. This one apparently the author decided it was simple enough that most people could work it out for themselves Commented Dec 1, 2019 at 21:08

2 Answers 2

3

The library you linked to is built using CMake (can be seen by the existence of a CMakeLists.txt file).

So you'd have to

  1. download the source code (git clone https://github.com/troldal/OpenXLSX.git on Linux/Mac or using git bash on Windows)

  2. generate the build system for your compiler (mkdir build; cd build; cmake .. on Linux/Mac)

  3. build the library (make on Linux/Mac)

Once you have built the library, generally there is an include directory and a lib directory (sometimes also named bin). If you are compiling directly using g++ or clang++, you'll have to add the include directory with the -I flag and the built library file in lib or bin with the -l flag:

g++ -Ipath/to/include -l/path/to/lib/libOpenXLSX.so your_sources.cpp 

If you are using CMake or an IDE with its own build system, you'll have to add those two paths according to the documentation of that build system (see target_link_libraries for CMake for example).

CMake sometimes also generates "install" commands for built library. When you install the libraries, the headers and library will be copied to your global include path, so you won't need to specify the paths in your compile command anymore: g++ -lOpenXLSX your_sources.cpp.

Sign up to request clarification or add additional context in comments.

5 Comments

For bonus points add how you know it's designed to be built with CMake (i.e. the presence of CMakeLists.txt)
Was just about to edit the answer because of that :D
Perfect thank you! This is where the spoonfeeding gets real. How do I "link it and include its headers?" I know how to include headers I made and standard ones but this my first time using a library like this.
@GTA.sprx What tools are you using to develop? Most IDEs have project files to specify which paths are included and which libraries are linked.
@GTA.sprx I have tried to add some general information on how to use the built library. Hope that helps.
0

Use the git clone command to download the library these two questions already answered would probably help you the most: And in regards to flags you would use the -I flag.

How to use Libraries C++ Link external libraries

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.