News:

When registered with our forums, feel free to send a "here I am" post here to differ human beings from SPAM bots.

Main Menu

problem with mysql headers

Started by dali1985, May 15, 2013, 12:14:05 PM

Previous topic - Next topic

dali1985

I would like to ask you if there is a tutorial with steps how to insert mysql library and headers in codeblocks. Because I want to connect my database with a c++ program which I want to write.
I used exactly step by step this one http://www.ehow.com/how_12032609_codeblocks-mysql-tutorial.html but when I build and run the project I have an error with the #include <mysql.h>
Maybe something goes wrong with the path.

BlueHazzard

Quote from: dali1985 on May 15, 2013, 12:14:05 PM
but when I build and run the project I have an error with the #include <mysql.h>

build log?

Quote from: dali1985 on May 15, 2013, 12:14:05 PM
Maybe something goes wrong with the path.
probably, but without build log....

have you set the path to your mysql include files in  "Project->Build Options ->Search directories->Compiler" ?
also don't forget to add the library in "Project->Build Options ->Linker settings->Link libraries" ?
and the path to the library in "Project->Build Options ->Search directories->Linker"

dali1985

I did the following
Project->Build Options ->Search directories-> /usr/include/mysql
Project -> Build Options -> Compiler Settings tab -> Other Options and enter `mysql_config --cflags`
Project -> Build Options -> Linker Settings tab -> Other Options and enter `mysql_config --libs`

It is working BUT when I change for example the 'Hello World' with the 'Hello my beautiful world' then the 'build and run' button gives me 'Hello World'.

BlueHazzard

#3
Quote from: BlueHazzard on May 15, 2013, 12:46:51 PM
Quote from: dali1985 on May 15, 2013, 12:14:05 PM
but when I build and run the project I have an error with the #include <mysql.h>
build log?

the "full build log"....
We can't help you without information.....

http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28general%29#Q:_How_do_I_report_a_compilation_problem_on_the_forums.3F

dali1985

#4
The build log which I receive with the above changes is

Checking for existence: /home/pi/Desktop/test8/bin/Debug/test8
Executing: xterm -T test8 -e /usr/bin/cb_console_runner LD_LIBRARY_PATH=$LD_LIBRARY_PATH:. /home/pi/Desktop/test8/bin/Debug/test8  (in /home/pi/Desktop/test8/.)
Process terminated with status 0 (0 minutes, 5 seconds)


I have this build log but I have always the same result 'Hello World' whatever I change in the text

BlueHazzard

please make a rebuild (Build->Rebuild)
and post the full build log (tab Build Log)

BlueHazzard

Quote from: dali1985 on May 15, 2013, 02:09:55 PM
I have this build log but I have always the same result 'Hello World' whatever I change in the text

have you done a rebuild?
Build->Rebuild or
Build->Clean and Build->Build and run

dali1985

Ok. Lets explain step by step.

First I created a simple project called test10. I built and ran it and I have the hello world.
Next step
Project->Build Options ->Search directories-> /usr/include/mysql
Project -> Build Options -> Compiler Settings tab -> Other Options and enter `mysql_config --cflags`
Project -> Build Options -> Linker Settings tab -> Other Options and enter `mysql_config --libs`

I added the mysql.h and now my program is

#include <iostream>
#include <mysql.h>
using namespace std;

int main()
{
   cout << "Hello world!" << endl;
   return 0;
}


Next
build-> clean
build-> build and run

'It seems that this project have not been built yet.Do you want to built it now?' I clicked Yes.

I have the following in the build log

-------------- Build: Debug in test10 ---------------

Compiling: main.cpp
g++: fatal error: no input files
compilation terminated.
Process terminated with status 4 (0 minutes, 4 seconds)
0 errors, 0 warnings


oBFusCATed

Quote from: dali1985 on May 15, 2013, 02:47:17 PM
Project->Build Options ->Search directories-> /usr/include/mysql
This isn't required.

It seems you've not enabled full logging.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

BlueHazzard

Somehow your project is messed up...

It seems that you are working with a old version of c::b...
please enable the full compiler logging: this is done by selecting the "Full command line" option Under menu "Settings" -> "Compiler" -> Global compiler settings -> [the compiler you use] -> "Other Setting" tab, "Compiler logging"
make a rebuild and post the full log again...

this thread could have the half length if you would follow the instructions under the link i posted 6 answers prior :
Quote from: BlueHazzard on May 15, 2013, 01:44:43 PM
http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28general%29#Q:_How_do_I_report_a_compilation_problem_on_the_forums.3F
till now i don't know your os, your c::b version etc...