I am new to C++. I am trying to use the MySQL replication in a C++ program to read the binlogs from MySQL.
I got the header files and .cpp
source files from Internet. Now I've placed the header files in /usr/include/mysql
folder and set the path of the CPLUS_INCLUDE_PATH
to point to it. It is able to use the header files. Also, I've placed the .cpp
files in /usr/lib64/mysql
folder and I compiled all .cpp
files to create the .o
files in the same directory.
But when I compile my program using g++
(g++ -I/usr/include/mysql -L/usr/lib64/mysql/ -g bin_log.cpp -o bin_log.out
), I am getting Undefined Reference to error for all the methods I am trying to invoke. See below:
/home/oracle/MySQL_To_Db2_Replication/bin_log.cpp:17:
undefined reference to `mysql::system::create_transport(char const*)
undefined reference to `mysql::Binary_log::Binary_log(mysql::system::Binary_log_driver*)'
undefined reference to `mysql::Binary_log::connect()'
undefined reference to `mysql::Binary_log::wait_for_next_event(mysql::Binary_log_event**)'
undefined reference to `mysql::Binary_log::get_position()'
I've also tried creating a .so file and linking it while compiling but it's not working. (I used g++ -I/usr/include/mysql -L/usr/lib64/mysql/binlogapi.so -g bin_log.cpp -o bin_log.out
).
I've tried building the libraries using cmake
, but no luck.
Could any guess what could be the problem with this? I think I am missing something basic.