Click here to Skip to main content
15,867,851 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am new in QT in C++ 98. I have made this project using netbeans

Netbeans C++ QT Application [image]


In this project I have made new QT From

QT Form [image]

I am trying to import SQL but it failed.Using this code in "newFrom.cpp"

C++
#include <stdlib.h>
    #include <iostream>
    #include <mysql_driver.h>
    #include <mysql_connection.h>
    #include <exception.h>
    #include <sstream>
    #include <stdexcept>
    
    #include <cppconn/driver.h>
    #include <<cppconn/exception.h>
    #include <cppconn/connection.h>
    #include <cppconn/resultset.h>
    #include <cppconn/statement.h>
    #include <cppconn/prepared_statement.h>
    
    using namespace std;
    using namespace sql;     // <---- add here

I am getting this error
C++
cd '/root/NetBeansProjects/BTMDispaly' /usr/bin/gmake -f Makefile
 CONF=Debug QMAKE=/usr/lib64/qt4/bin/qmake "/usr/bin/gmake" -f
 nbproject/Makefile-Debug.mk QMAKE=/usr/lib64/qt4/bin/qmake
 SUBPROJECTS= .build-conf gmake[1]: Entering directory
 `/root/NetBeansProjects/BTMDispaly' /usr/lib64/qt4/bin/qmake VPATH=.
 -o qttmp-Debug.mk nbproject/qt-Debug.pro Project MESSAGE: Warning: unknown QT: widgets Project MESSAGE: Warning: unknown QT: printsupport> mv -f qttmp-Debug.mk nbproject/qt-Debug.mk "/usr/bin/gmake" -f
 nbproject/qt-Debug.mk dist/Debug/GNU-Linux/BTMDispaly gmake[2]:
 Entering directory `/root/NetBeansProjects/BTMDispaly' g++ -c -m64
 -pipe -g -Wall -W -D_REENTRANT -DQT_QT3SUPPORT_LIB -DQT3_SUPPORT -DQT_SQL_LIB -DQT_OPENGL_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -I/usr/lib64/qt4/mkspecs/linux-g++-64 -Inbproject -I/usr/include/QtCore -I/usr/include/QtNetwork -I/usr/include/QtGui -I/usr/include/QtOpenGL -I/usr/include/QtSql -I/usr/include/Qt3Support -I/usr/include -I/usr -I/usr/bin -I/usr/X11R6/include -I. -I. -Inbproject -I. -o build/Debug/GNU-Linux/newForm.cpp.o
 
     newForm.cpp.cc:18:26: error: mysql_driver.h: No such file or directory
     newForm.cpp.cc:19:30: error: mysql_connection.h: No such file or directory
     newForm.cpp.cc:23:28: error: cppconn/driver.h: No such file or directory
     newForm.cpp.cc:24:32: error: cppconn/exception.h: No such file or directory
     newForm.cpp.cc:25:32: error: cppconn/connection.h: No such file or directory
     newForm.cpp.cc:26:31: error: cppconn/resultset.h: No such file or directory
     newForm.cpp.cc:27:31: error: cppconn/statement.h: No such file or directory
     newForm.cpp.cc:28:40: error: cppconn/prepared_statement.h: No such file or directory
     newForm.cpp.cc:32: error: ‘sql’ is not a namespace-name
     newForm.cpp.cc:32: error: expected namespace-name before ‘;’ token
      error: expected namespace-name
 
 before ‘;’ token gmake[2]: *** [build/Debug/GNU-Linux/newForm.cpp.o]
 Error 1 gmake[2]: Leaving directory
 `/root/NetBeansProjects/BTMDispaly' gmake[1]: *** [.build-conf] Error
 2 gmake[1]: Leaving directory `/root/NetBeansProjects/BTMDispaly'
 gmake: *** [.build-impl] Error 2
 
 BUILD FAILED (exit value 2, total time: 1s)


What I have tried:

I am configuring the Linker of this project like this

Netbeans linker [image]

How i can remove this SQL related error? please help.
Posted
Updated 12-Nov-22 2:10am
v3

1 solution

Your problem is that all those header files cannot be found. It may be that they are in a subdirectory of your project, in which case you need to change the angle brackets to double quotes, thus:
C++
#include "mysql_driver.h"
#include "mysql_connection.h"

#include "cppconn/driver.h"
#include "cppconn/exception.h"
#include "cppconn/connection.h"
#include "cppconn/resultset.h"
#include "cppconn/statement.h"
#include "cppconn/prepared_statement.h"

If that is not the case, and they are stored somewhere elxe then you need to add their location to your set of include directory names.
 
Share this answer
 
v2
Comments
Member 8840306 12-Nov-22 10:45am    
Addng "" in all includes still give error.

I can not find location like cppconn in include.

How i can resolve all thoses error now?
Richard MacCutchan 12-Nov-22 11:05am    
Sorry, but it's your system so you are the only person who knows where these files are located.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900