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?
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?
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
download the source code (git clone https://github.com/troldal/OpenXLSX.git
on Linux/Mac or using git bash on Windows)
generate the build system for your compiler (mkdir build; cd build; cmake ..
on Linux/Mac)
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
.
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.