PDA

View Full Version : mysql plugin not compiling from source



rahulvishwakarma
30th October 2017, 04:38
i have qt 5.2.1 in centos6.6 (32 bit) linux, in vmware machine. mysql in another VM. mysql is connection from client

to server is successful. But when i want to build plugin for mysql database connectivity by command :


# /opt/Qt5.2.1/5.2.1/gcc/bin/qmake "INCLUDEPATH+=/usr/include" "LIBS+=-L/usr/lib/mysql -lmysqlclient_r" mysql.pro
# make

this gives following error :


/export/home/pb2/build/sb_0-14135570-1421675634.15/rpm/BUILD/mysql-5.6.23/mysql-5.6.23/mysys/my_getsystime.c:44: undefined
reference to `clock_gettime'
collect2: error: ld returned 1 exit status
make: *** [../../../../plugins/sqldrivers/libqsqlmysql.so] Error 1

how to solvw this

high_flyer
30th October 2017, 22:24
Try adding librt to the linker:


# /opt/Qt5.2.1/5.2.1/gcc/bin/qmake "INCLUDEPATH+=/usr/include" "LIBS+=-L/usr/lib/mysql -lmysqlclient_r -lrt" mysql.pro

rahulvishwakarma
4th November 2017, 06:27
this " -lrt" adding give following error:-
-------------------------------------------


/usr/lib/mysql/libmysqlclient_r.a(client_plugin.c.o): In function `do_add_plugin':
/export/home/pb2/build/sb_0-14135570-1421675634.15/rpm/BUILD/mysql-5.6.23/mysql-5.6.23/sql-common/client_plugin.c:179:

undefined reference to `dlclose'
/usr/lib/mysql/libmysqlclient_r.a(client_plugin.c.o): In function `mysql_client_plugin_deinit':
/export/home/pb2/build/sb_0-14135570-1421675634.15/rpm/BUILD/mysql-5.6.23/mysql-5.6.23/sql-common/client_plugin.c:306:

undefined reference to `dlclose'
/usr/lib/mysql/libmysqlclient_r.a(client_plugin.c.o): In function `mysql_load_plugin_v':
/export/home/pb2/build/sb_0-14135570-1421675634.15/rpm/BUILD/mysql-5.6.23/mysql-5.6.23/sql-common/client_plugin.c:393:

undefined reference to `dlopen'
/export/home/pb2/build/sb_0-14135570-1421675634.15/rpm/BUILD/mysql-5.6.23/mysql-5.6.23/sql-common/client_plugin.c:422:

undefined reference to `dlsym'
/export/home/pb2/build/sb_0-14135570-1421675634.15/rpm/BUILD/mysql-5.6.23/mysql-5.6.23/sql-common/client_plugin.c:413:

undefined reference to `dlerror'
/export/home/pb2/build/sb_0-14135570-1421675634.15/rpm/BUILD/mysql-5.6.23/mysql-5.6.23/sql-common/client_plugin.c:425:

undefined reference to `dlclose'
collect2: error: ld returned 1 exit status
make: *** [../../../../plugins/sqldrivers/libqsqlmysql.so] Error 1

high_flyer
6th November 2017, 10:18
this is not the result of adding librt.
Adding librt solved the error you posted at first, now you are having another lib missing:
Now you have to add '-ldl'.
And if you continue getting such errors, google for the functions which the linker is complaining about and see in which lib they are defined, and add them to you linker line until all the dependencies are satisfied.

rahulvishwakarma
6th November 2017, 11:26
Thanks high_flyer, you solved my problem. I added -lrt and -ldl like this:-



# /opt/Qt5.2.1/5.2.1/gcc/bin/qmake "INCLUDEPATH+=/usr/include" "LIBS+=-L/usr/lib/mysql -lmysqlclient_r -lrt -ldl" mysql.pro

#make
# make install


and the problem was gone.

And finally tell me how to set this thread as SOLVED.