c++ - Application compiles in Eclipse, but has 'undefined reference errors' in Qt -
i building application uses mysql , needs graphical user interface. because more comfortable eclipse, , seems have better organization , 'pop-up references', decided develop main engine in eclipse, , transfer qt (using qt creator 3.1.2, based on qt 5.3.1) gui. engine compiles in eclipse fine (and command-line test in eclipse runs well), when include files in qt project, undefined reference errors.
i error (undefined reference 'sql::mysql::get_driver_instance'
) anywhere have code:
sql::mysql::mysql_driver* driver = sql::mysql::get_driver_instance();
i have relevant headers included (since eclipse sees no problem it):
#include "mysql_driver.h"
#include "mysql_connection.h"
#include < cppconn/driver.h>
#include < cppconn/connection.h>
#include < cppconn/statement.h>
#include < cppconn/prepared_statement.h>
#include < cppconn/resultset.h>
#include < cppconn/metadata.h>
#include < cppconn/resultset_metadata.h>
#include < cppconn/exception.h>
#include < cppconn/warning.h>
sounds linker error, can't find place specify linker options in qt options page. i'm using gcc compiler on ubuntu 14.04.
am forgetting change setting somewhere or else?
i figured out, this thread. rather linking in options page, merely had edit qt project (.pro
) file. added following:
libs += -lmysqlcppconn
and compiles , runs fine. problem didn't understand how linking.
Comments
Post a Comment