简体   繁体   中英

How do I install OpenXLSX on Linux?

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

  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 .

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM