R
R
Rag'n' Code Man2021-11-28 13:40:58
C++ / C#
Rag'n' Code Man, 2021-11-28 13:40:58

How to connect this library to the project correctly?

I need to write a program in C ++, and since I really don't want to enter the paths by hand, I want to include this library here .

But since I'm new to C++, I don't quite understand how to do this. There is no command in its sources make installand it cannot be installed via apt.

I am also not very familiar with the structure of C ++ projects and I do not quite understand what is happening here.

I have such a project (the structure is generated by VSCode):

61a35bc350454227681230.png
Since I have never installed libraries in this way and in general I have been on the pros for less than a week, it is not very clear to me what and where to put it in order to make it work.

What the developer says about building it: https://github.com/mlabbe/nativefiledialog#building

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergio, 2021-11-28
@iDmitriyWinX

The nativefiledialog code has a Makefile for building with GNU Make. Since you also use make, the process is something like this:
1. Copy the library code to the lib/nativefiledialog folder

git clone https://github.com/mlabbe/nativefiledialog.git lib/nativefiledialog

2. Add a target for compiling the library to your Makefile and add the appropriate flags for the header directory and linking with the library, like this:
all: my_program

my_program: nfd_lib
  g++ -Llib/nativefiledialog/build/lib/Release/x64 -Ilib/nativefiledialog/src/include \
    -lnfd src/main.cpp -o my_program

clean: nfd_clean
  rm *.o my_program

nfd_lib:
  make -C lib/nativefiledialog/build/gmake_linux

nfd_clean:
  make -C lib/nativefiledialog/build/gmake_linux clean

3. Include the library in main.cpp
#include <nfd.h>
I used the Release/x64 configuration, if you have a 32-bit machine (which is unlikely), you will have Release/x86.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question