error: undefined reference to `mysql_init'
-
@micha_eleric So why don't you try it out?
@Christian-Ehrlicher
[expected to need lmysql]
unix:LIBS += -L/usr/lib/x86_64-linux-gnu -lmysql
:-1: error: cannot find -lmysql: No such file or directory[maybe llibmysqlclient instead of lmysql]
unix:LIBS += -L/usr/lib/x86_64-linux-gnu -llibmysqlclient
:-1: error: cannot find -llibmysqlclient: No such file or directory[maybe l and lib are the same, as in lmath instead of libmath]
unix:LIBS += -L/usr/lib/x86_64-linux-gnu -libmysqlclient
:-1: error: cannot find -libmysqlclient: No such file or directory[did not expect it to work, but why not try and see?]
unix:LIBS += -L/usr/lib/x86_64-linux-gnu
error: undefined reference tomysql_init' undefined reference to
mysql_real_connect'i will keep guessing
:-1: error: note to link with /usr/lib/x86_64-linux-gnu/libmysqlclient.a use -l:libmysqlclient.a or rename it to liblibmysqlclient.a
does not seem to be what https://doc.qt.io/qt-6/qmake-variable-reference.html#libs, says, but why not try?unix:LIBS += -L/usr/lib/x86_64-linux-gnu -l:libmysqlclient
:-1: error: cannot find -l:libmysqlclient: No such file or directoryunix:LIBS += -L/usr/lib/x86_64-linux-gnu -liblibmysqlclient
:-1: error: cannot find -liblibmysqlclient: No such file or directoryunix:LIBS += -L/usr/lib/x86_64-linux-gnu -l:libmysqlclient.a
298 errors in libunix:LIBS += -L/usr/lib/x86_64-linux-gnu -liblibmysqlclient.a
:-1: error: cannot find -liblibmysqlclient.a: No such file or directoryunix:LIBS += -L/usr/lib/x86_64-linux-gnu -libmysqlclient.a
:-1: error: cannot find -libmysqlclient.a: No such file or directoryunix:LIBS += -L/usr/lib/x86_64-linux-gnu -libmysqlclient.so
:-1: error: cannot find -libmysqlclient.so: No such file or directoryunix:LIBS += -L/usr/lib -libmysqlclient
:-1: error: cannot find -libmysqlclient: No such file or directoryunix:LIBS += -L/usr/lib/ -libmysqlclient
:-1: error: cannot find -libmysqlclient: No such file or directoryunix:LIBS += -L/usr/lib/x86_64-linux-gnu -l;libmysqlclient
[error, but disappears and can not copy]unix:LIBS += -L/usr/lib/x86_64-linux-gnu -l libmysqlclient
:-1: error: cannot find -llibmysqlclient: No such file or directoryjust to see what would happen
unix:LIBS += -L/usr/lib/ -llibmysqlclient
:-1: error: cannot find -llibmysqlclient: No such file or directory
:-1: error: note to link with
/usr/lib/gcc/x86_64-linux-gnu/11/../../../x86_64-linux-gnu/libmysqlclient.a use
-l:libmysqlclient.a or rename it to liblibmysqlclient.aunix:LIBS += -L/usr/lib -llibmysqlclient
:-1: error: cannot find -llibmysqlclient: No such file or directory
:-1: error: note to link with
/usr/lib/gcc/x86_64-linux-gnu/11/../../../x86_64-linux-gnu/libmysqlclient.a use
-l:libmysqlclient.a or rename it to liblibmysqlclient.aunix:LIBS += -L/usr/ -llibmysqlclient
:-1: error: cannot find -llibmysqlclient: No such file or directory
:-1: error: note to link with
/usr/lib/gcc/x86_64-linux-gnu/11/../../../x86_64-linux-gnu/libmysqlclient.a use
-l:libmysqlclient.a or rename it to liblibmysqlclient.aunix:LIBS += -L/ -llibmysqlclient
:-1: error: cannot find -llibmysqlclient: No such file or directory
:-1: error: note to link with
/usr/lib/gcc/x86_64-linux-gnu/11/../../../x86_64-linux-gnu/libmysqlclient.a use
-l:libmysqlclient.a or rename it to liblibmysqlclient.aunix:LIBS += -L -llibmysqlclient
error: undefined reference tomysql_init' undefined reference to
mysql_real_connect' -
@micha_eleric
I wonder if you should take a step back and question why you are even trying to do this? You have chosen to pick example code from 2016, and one that has nothing to do with Qt. It uses direct, "low level" libraries to interact with MYSQL. But Qt provides a whole set of "higher level" classes,QSql...
, which are integrated with Qt (e.g. can be used for models for Qt's views) and preferable in a host of ways.Why don't you abandon that example's approach and just use the Qt way? My understanding is that if you are Windows you may have to(?) compile the MySQL libraries, but if you are Linux like I am your distro (e.g. Ubuntu) will offer a pre-compiled set of libraries for MySQL. My system does not have any
libmysql.so
files, the only stuff islibmysqlclient...
. That is the route I would follow.@JonB said in error: undefined reference to `mysql_init':
@micha_eleric
I wonder if you should take a step back and question why you are even trying to do this?first example found, first example try
You have chosen to pick example code from 2016
does it matter if it is from 2016, or 1908, it showed what library is needed, and how to link libraries, which will be needed for future projects.
-
It must be something like libmysql.so
@Christian-Ehrlicher said in error: undefined reference to `mysql_init':
It must be something like libmysql.so
.so files that show up from mysql search
libmysqlclient.so
libmysqlclient.so.21
libmysqlclient.so.21.2.35
mysql_clear_password.so -
folder /usr/lib/x86_64-linux-gnu/ has libmysqlclient.so
error seems to be with how i have
unix:LIBS += -L/usr/lib/x86_64-linux-gnu -llibmysqlclient -
folder /usr/lib/x86_64-linux-gnu/ has libmysqlclient.so
error seems to be with how i have
unix:LIBS += -L/usr/lib/x86_64-linux-gnu -llibmysqlclient@micha_eleric said in error: undefined reference to `mysql_init':
unix:LIBS += -L/usr/lib/x86_64-linux-gnu -llibmysqlclient
This is wrong. If you use -l you skip the lib prefix:
unix:LIBS += -L/usr/lib/x86_64-linux-gnu -lmysqlclient
-
@JonB said in error: undefined reference to `mysql_init':
@micha_eleric
I wonder if you should take a step back and question why you are even trying to do this?first example found, first example try
You have chosen to pick example code from 2016
does it matter if it is from 2016, or 1908, it showed what library is needed, and how to link libraries, which will be needed for future projects.
@micha_eleric said in error: undefined reference to `mysql_init':
does it matter if it is from 2016, or 1908, it showed what library is needed, and how to link libraries, which will be needed for future projects.
Yes, it matters. I tried to advise you that I do not need any
-lmysql
which you are struggling with. I tried to advise that there is no need and no point using your level of library when writing code for Qt. Tried to advise you that the example you have picked and the code it uses is not the best way at all to go about thing in a Qt program, and you will end up having to do a lot of unnecessary work especially later on if you follow it for a Qt program. You wouldn't need it for future projects, and I have never seen a Qt program which attempts to usemysql_...
functions.All in the spirit of friendly advice, which you are free to take or ignore,
-
@micha_eleric said in error: undefined reference to `mysql_init':
unix:LIBS += -L/usr/lib/x86_64-linux-gnu -llibmysqlclient
This is wrong. If you use -l you skip the lib prefix:
unix:LIBS += -L/usr/lib/x86_64-linux-gnu -lmysqlclient
@jsulm thank you for the answer.
two questions:- why is part of file name dropped?
- why can std library be used without these extra steps?
-
-
@micha_eleric said in error: undefined reference to `mysql_init':
does it matter if it is from 2016, or 1908, it showed what library is needed, and how to link libraries, which will be needed for future projects.
Yes, it matters. I tried to advise you that I do not need any
-lmysql
which you are struggling with. I tried to advise that there is no need and no point using your level of library when writing code for Qt. Tried to advise you that the example you have picked and the code it uses is not the best way at all to go about thing in a Qt program, and you will end up having to do a lot of unnecessary work especially later on if you follow it for a Qt program. You wouldn't need it for future projects, and I have never seen a Qt program which attempts to usemysql_...
functions.All in the spirit of friendly advice, which you are free to take or ignore,
@JonB said in error: undefined reference to `mysql_init':
@micha_eleric said in error: undefined reference to `mysql_init':
does it matter if it is from 2016, or 1908, it showed what library is needed, and how to link libraries, which will be needed for future projects.
Yes, it matters. I tried to advise you that I do not need any
-lmysql
which you are struggling with. I tried to advise that there is no need and no point using your level of library when writing code for Qt. Tried to advise you that the example you have picked and the code it uses is not the best way at all to go about thing in a Qt program, and you will end up having to do a lot of unnecessary work especially later on if you follow it for a Qt program. You wouldn't need it for future projects, and I have never seen a Qt program which attempts to usemysql_...
functions.All in the spirit of friendly advice, which you are free to take or ignore,
arguing high level vs. low level just encourages me to learn assembly, although i would more likely use C.
-
@JonB said in error: undefined reference to `mysql_init':
@micha_eleric said in error: undefined reference to `mysql_init':
does it matter if it is from 2016, or 1908, it showed what library is needed, and how to link libraries, which will be needed for future projects.
Yes, it matters. I tried to advise you that I do not need any
-lmysql
which you are struggling with. I tried to advise that there is no need and no point using your level of library when writing code for Qt. Tried to advise you that the example you have picked and the code it uses is not the best way at all to go about thing in a Qt program, and you will end up having to do a lot of unnecessary work especially later on if you follow it for a Qt program. You wouldn't need it for future projects, and I have never seen a Qt program which attempts to usemysql_...
functions.All in the spirit of friendly advice, which you are free to take or ignore,
arguing high level vs. low level just encourages me to learn assembly, although i would more likely use C.
@micha_eleric said in error: undefined reference to `mysql_init':
arguing high level vs. low level just encourages me to learn assembly, although i would more likely use C.
So why do you use Qt then?
-
@micha_eleric said in error: undefined reference to `mysql_init':
arguing high level vs. low level just encourages me to learn assembly, although i would more likely use C.
So why do you use Qt then?
@Christian-Ehrlicher said in error: undefined reference to `mysql_init':
@micha_eleric said in error: undefined reference to `mysql_init':
arguing high level vs. low level just encourages me to learn assembly, although i would more likely use C.
So why do you use Qt then?
one little piece of qt