G
G
German2018-10-26 12:32:10
linux
German, 2018-10-26 12:32:10

How to use third party C++ libraries in Visual Code on Linux?

I'm on an Ubuntu distribution, writing in C++, using Microsoft Visual Code for this purpose.
I want to try to work with the SFML library, then with boost, how to connect them?
I'm not a pro in Linux, so I'm asking for help.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
res2001, 2018-10-26
@res2001

Regardless of which OS you are running and which IDE you use, the scheme is the same:
1. In order for you to use third-party library calls in your sources, you must include the library's header files using the #include directive.
2. In order for the compiler to compile your code, you must set it to the location of the header files of the third-party library using the -I option of the compiler. In Linux, if the library is installed by a regular package manager, this may not be required, because. header files will be available via the standard header file search paths.
3. In order for the linker to be able to build the executable file, you must tell it the path and name of the library binaries using the -L and -l options. Again, in Linux, you may not need to specify the path (-L) (see item 2), only the name of the library (-l).
4.If the library is not installed in standard directories, then the executable file loader may not find it. To fix this, you may need to run the ldconfig utility, or even add the library directory to the ldconfig configuration file. As an option, add the path to the library binaries to the LD_LIBRARY_PATH environment variable before starting the program.
There is no ldconfig in Windows - library files must be either in the directory where the program's executable file is located, or in one of the paths specified in the PATH environment variable.
When you run a build in the IDE, you usually need to specify the compiler options from steps 1-3 in the project properties.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question