Author Topic: problem with mysql headers  (Read 10560 times)

Offline dali1985

  • Single posting newcomer
  • *
  • Posts: 5
problem with mysql headers
« on: May 15, 2013, 12:14:05 pm »
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.

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: problem with mysql headers
« Reply #1 on: May 15, 2013, 12:46:51 pm »
but when I build and run the project I have an error with the #include <mysql.h>

build log?

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"

Offline dali1985

  • Single posting newcomer
  • *
  • Posts: 5
Re: problem with mysql headers
« Reply #2 on: May 15, 2013, 01:41:46 pm »
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'.

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: problem with mysql headers
« Reply #3 on: May 15, 2013, 01:44:43 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
« Last Edit: May 15, 2013, 01:47:51 pm by BlueHazzard »

Offline dali1985

  • Single posting newcomer
  • *
  • Posts: 5
Re: problem with mysql headers
« Reply #4 on: May 15, 2013, 02:09:55 pm »
The build log which I receive with the above changes is
Code
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
« Last Edit: May 15, 2013, 02:14:28 pm by dali1985 »

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: problem with mysql headers
« Reply #5 on: May 15, 2013, 02:11:34 pm »
please make a rebuild (Build->Rebuild)
and post the full build log (tab Build Log)

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: problem with mysql headers
« Reply #6 on: May 15, 2013, 02:21:25 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

Offline dali1985

  • Single posting newcomer
  • *
  • Posts: 5
Re: problem with mysql headers
« Reply #7 on: May 15, 2013, 02:47:17 pm »
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
Code
#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
Code
-------------- 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

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: problem with mysql headers
« Reply #8 on: May 15, 2013, 03:02:50 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!]

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: problem with mysql headers
« Reply #9 on: May 15, 2013, 10:35:47 pm »
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 :
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...