GIDForums  

Go Back   GIDForums > Computer Programming Forums > C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 14-Feb-2004, 20:49
trs2988 trs2988 is offline
New Member
 
Join Date: Feb 2004
Posts: 6
trs2988 is on a distinguished road

MySQL Won't Work


I'm having a problem connecting to a MySQL database through my c++ programs. I use Borland 5.5.1 C++ Builder and I used the "MySQL++ 1.7.1 for Borland C++ 5.* for Windows (contributed by Arturs Aboltins", which can be found the sixth from the bottom at http://www.mysql.com/downloads/api-mysql++.html. I installed it, and I tried to compile this test program:

CPP / C++ / C Code:
#include <stdio.h>
#include <iostream.h>
#if defined(_WIN32) || defined(_WIN64) 
#include <windows.h> 
#endif 
#include <C:\mysqlpp\include\mysql\mysql.h>

int main() {
MYSQL mysql;

mysql_init(&mysql);
mysql_options(&mysql,MYSQL_READ_DEFAULT_GROUP,"test");
if (!mysql_real_connect(&mysql,"rotox.net","trs2988_trs","******","trs2988_game",0,NULL,0))
{
    fprintf(stderr, "Failed to connect to database: Error: %s\n",
          mysql_error(&mysql));
}

But I get this error:

Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland
test.cpp:
Turbo Incremental Link 5.00 Copyright (c) 1997, 2000 Borland
Error: Unresolved external 'mysql_init' referenced from C:\BORLAND\BCC55\BIN\TEST.OBJ
Error: Unresolved external 'mysql_options' referenced from C:\BORLAND\BCC55\BIN\TEST.OBJ
Error: Unresolved external 'mysql_real_connect' referenced from C:\BORLAND\BCC55\BIN\TEST.OBJ
Error: Unresolved external 'mysql_error' referenced from C:\BORLAND\BCC55\BIN\TEST.OBJ


What can I do to fix this? If I can't fix it, what other options do I have to use MySQL databases in my programs (without paying for anything!)?
  #2  
Old 14-Feb-2004, 21:30
dsmith's Avatar
dsmith dsmith is offline
Senior Member
 
Join Date: Jan 2004
Location: Utah, USA
Posts: 1,351
dsmith is a glorious beacon of lightdsmith is a glorious beacon of lightdsmith is a glorious beacon of lightdsmith is a glorious beacon of lightdsmith is a glorious beacon of light
Quote:
Originally Posted by trs2988
test.cpp:
Turbo Incremental Link 5.00 Copyright (c) 1997, 2000 Borland
Error: Unresolved external 'mysql_init' referenced from C:\BORLAND\BCC55\BIN\TEST.OBJ
Error: Unresolved external 'mysql_options' referenced from C:\BORLAND\BCC55\BIN\TEST.OBJ
Error: Unresolved external 'mysql_real_connect' referenced from C:\BORLAND\BCC55\BIN\TEST.OBJ
Error: Unresolved external 'mysql_error' referenced from C:\BORLAND\BCC55\BIN\TEST.OBJ

I've never used this library, but this is a linker error. Are you linking your program with the library? This would either be a precompiled library (lib-dll) or the c file. If you are and having this problem, then it is something that I would need to look into further before I could help.
  #3  
Old 14-Feb-2004, 21:52
trs2988 trs2988 is offline
New Member
 
Join Date: Feb 2004
Posts: 6
trs2988 is on a distinguished road
Thanks - I just realized you're the same person who helped me with my earlier problem, the one with cin.

Anyway, sorry for being a total idiot. But how do you do that? Is it different with different compilers, or do you include it with the code?

I'm such a newbie
  #4  
Old 14-Feb-2004, 22:04
dsmith's Avatar
dsmith dsmith is offline
Senior Member
 
Join Date: Jan 2004
Location: Utah, USA
Posts: 1,351
dsmith is a glorious beacon of lightdsmith is a glorious beacon of lightdsmith is a glorious beacon of lightdsmith is a glorious beacon of lightdsmith is a glorious beacon of light
I haven't used the borland c compiler, but if it is similar to the Visual C compiler, you should be able to make a project somehow. What you want to do is include the source code for the library into that project along with your source code above. Your compiler should handle compiling both your project and the library and then passing them to the linker to be linked together.

Sorry, I can't be of more help. If you are still struggling with this let me know and I can take a closer look at the mysql library that you downloaded tommorow.
  #5  
Old 14-Feb-2004, 22:28
trs2988 trs2988 is offline
New Member
 
Join Date: Feb 2004
Posts: 6
trs2988 is on a distinguished road

Works


I got it to work. Since Borland C++ Builder is a command-line tool, you can't make projects. But I just had to list the .lib file with the file I was compiling, and it linked it. Thanks for your help, I wouldn't have been able to figure it out without you.
  #6  
Old 31-Mar-2004, 08:29
royblack royblack is offline
New Member
 
Join Date: Mar 2004
Posts: 1
royblack is on a distinguished road
Unhappy

Need your help


Quote:
Originally Posted by trs2988
I got it to work. Since Borland C++ Builder is a command-line tool, you can't make projects. But I just had to list the .lib file with the file I was compiling, and it linked it. Thanks for your help, I wouldn't have been able to figure it out without you.
Hello,

I am facing the same problem as you were before. I'm a newbie and don't know how to make projects to work.
I'm coding with Borland CBuilder 6, need to code with mySQL++ API.

If you got it work let me know how. Please help, the more details the better.

Thanks.
  #7  
Old 31-Mar-2004, 09:48
dsmith's Avatar
dsmith dsmith is offline
Senior Member
 
Join Date: Jan 2004
Location: Utah, USA
Posts: 1,351
dsmith is a glorious beacon of lightdsmith is a glorious beacon of lightdsmith is a glorious beacon of lightdsmith is a glorious beacon of lightdsmith is a glorious beacon of light
Quote:
Originally Posted by royblack
Hello,

I am facing the same problem as you were before. I'm a newbie and don't know how to make projects to work.
I'm coding with Borland CBuilder 6, need to code with mySQL++ API.

If you got it work let me know how. Please help, the more details the better.

Thanks.

Hi Roy. I am a little unfamiliar with Borland Builder, but if it does use a command line, then you should be able to add libraries quite easily. use the -l to add a library to be linked to your project and a -L to add a search path for a library to your compile command. (This is based on gcc, but most compilers follow this convention.) So, if you compile from the commmand line, you should be able to type something like:
Code:
bc myprogrm -lmysql -Lc:\path_to\mysql_library\

Hopefully, TRS can give you the exact commandline that he used.

Good luck!
 
 

Recent GIDBlogToyota - 2009 May Promotion by Nihal

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Why doesnt my form work correctly? rhino1616 Web Design Forum 2 06-Nov-2003 18:21
How do web redirection scripts work? rhino1616 Web Design Forum 9 27-Oct-2003 10:47
MySQL Syntax Error DropZite MySQL / PHP Forum 3 09-Jul-2003 05:00
Windows: From only £20p/y,Linux: from $10p/m. ASP, ASP.NET, PHP, Free MySQL, +More EyotaHosts Web Hosting Advertisements & Offers 0 28-Jun-2003 14:54
mysql vs sql - what is the difference zabell MySQL / PHP Forum 2 14-Jun-2003 17:32

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 08:49.


vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.