Compiling C ++ programs, including mysql

I am new to gcc and trying to compile C ++ - a program that includes mysql.h using the command:

g ++ -o test test.cpp -L / usr / include / mysql -lmysqlclient -I / usr / include / mysql

This works without problems, but I was wondering if anyone could explain the arguments to me. I don’t like teams that I don’t understand.

thanks

+4
source share
3 answers

-o test means the output file should be named "test".

test.cpp is your source file, of course.

-L/usr/include/mysql means looking for libraries in / usr / include / mysql, as well as in the normal link path. (He probably doesn't find any libraries, my libmysqlclient.a is in the standard library directory / usr / lib. So I don't think you need this option.)

-lmysqlclient means a reference to the mysqlclient library (actually called libmysqlclient.a)

-I/usr/include/mysql means search for #include files in / usr / include / mysql, as well as in the usual include path.

+4
source

try "man g ++" for a full description of what the various options mean.

+1
source

man gcc will provide you with detailed information about all of these options.

g ++ -o test test.cpp -L / usr / include / mysql -lmysqlclient -I / usr / include / mysql

 g++ : the compiler -o test : name the resulting binary "test" test.cpp : your source file -L : the directory to look in for libraries (that are specified by -l) -l : named library to link against (looks for it in -L) -I : the directory to look in for #included header files 
0
source

Source: https://habr.com/ru/post/1308959/


All Articles