-
October 29th, 2013, 08:40 AM
#1
MySQL and C++ lib error
1. I downloaded win installer
2. installed "FULL" version
3. added programfiles/mysql/include dir
4. added programfiles/mysql/lib dir
5. linked "libmysql.lib"
still getting
Code:
1>Source.obj : error LNK2001: unresolved external symbol _mysql_real_connect@32
1>Source.obj : error LNK2001: unresolved external symbol _mysql_init@4
looks like the lib is for 64 bit (I guess), but I downloaded 32 bit installer and im compiling it for 32 bit, any suggestions? im using vs2012
code:
Code:
#include <my_global.h>
#include <mysql.h>
#include <iostream>
#include <string>
using namespace std;
#define DB_HOST "localhost"
#define DB_USER "root"
#define DB_PASS "root"
#define DB_DB "test"
#define DB_PORT 3306
int main()
{
MYSQL *conn;
conn = mysql_init(NULL);
if(conn = mysql_real_connect(conn, DB_HOST, DB_USER, DB_PASS, DB_DB, DB_PORT, NULL, 0))
{
}
else
cout << "Cant connect to the DB" << endl;
system("pause");
return 0;
}
I have 64 bit OS, vs2012 express, compiling for 32 bit, I downloaded 32 bit mysql installer
-
October 29th, 2013, 11:54 AM
#2
Re: MySQL and C++ lib error
Originally Posted by DaigonoYouso
1. I downloaded win installer
2. installed "FULL" version
3. added programfiles/mysql/include dir
4. added programfiles/mysql/lib dir
5. linked "libmysql.lib"
You list all of these things you did, but no one knows if you did any of these correctly.
looks like the lib is for 64 bit
Nothing in that error message suggests that the library is 64-bit.
Tell us what you mean by "linked". There are multiple ways to specify a library to link to in Visual Studio.
Also, showing us C++ source code isn't going to give information on what caused a linker error.
Regards,
Paul McKenzie
-
October 29th, 2013, 11:58 AM
#3
Re: MySQL and C++ lib error
Originally Posted by Paul McKenzie
You list all of these things you did, but no one knows if you did any of these correctly.
Nothing in that error message suggests that the library is 64-bit.
Tell us what you mean by "linked". There are multiple ways to specify a library to link to in Visual Studio.
Regards,
Paul McKenzie
1. well, I downloaded win installer from mysql website, and I dont really think this can be done wrong
2. I installed full version by selecting "full" on the start of installation, it did install connectors and everything it could
3. and 4. im not using external libs for the first time, I also did this correctly
5. i linked it under input
I had same error with lua lib that I accidentaly built for 64 bit, everything was linked but I still got the error telling me that I dont have lib included in my project
-
October 29th, 2013, 01:41 PM
#4
Re: MySQL and C++ lib error
Originally Posted by DaigonoYouso
...
5. i linked it under input
What could it mean?
Victor Nijegorodov
-
October 29th, 2013, 01:56 PM
#5
Re: MySQL and C++ lib error
Originally Posted by VictorN
What could it mean?
uhm, that it is linked under input section of linker in properties?
-
October 29th, 2013, 02:02 PM
#6
Re: MySQL and C++ lib error
Originally Posted by DaigonoYouso
uhm, that it is linked under input section of linker in properties?
Do you mean you added the lib pathname in the Additional Dependencies list?
And BTW, are there different .lib versions for debug/release builds?
Victor Nijegorodov
-
October 30th, 2013, 10:50 AM
#7
Re: MySQL and C++ lib error
Here is the lib file that was installed on my machine.
libsql.zip
Regards,
Paul McKenzie
-
October 30th, 2013, 11:38 AM
#8
Re: MySQL and C++ lib error
Originally Posted by Paul McKenzie
Here is the lib file that was installed on my machine.
libsql.zip
Regards,
Paul McKenzie
works, why?
-
October 30th, 2013, 11:47 AM
#9
Re: MySQL and C++ lib error
Originally Posted by DaigonoYouso
works, why?
It works because it does. This is what is installed by the MySql installer -- it has to work, else the people at MySql needs to go back and provide a workable lib file.
Regards,
Paul McKenzie
-
October 30th, 2013, 11:47 AM
#10
Re: MySQL and C++ lib error
Originally Posted by DaigonoYouso
works, why?
It is wrong question! It "works" just because this lib file was created to "work"!
The question you have to ask is: why does your lib file not work? I guess it is because "your" lib is NOT for 32-bit debug version or the file was corrupted.
Victor Nijegorodov
-
October 30th, 2013, 11:51 AM
#11
Re: MySQL and C++ lib error
Originally Posted by VictorN
It is wrong question! It "works" just because this lib file was created to "work"!
The question you have to ask is: why does your lib file not work? I guess it is because "your" lib is NOT for 32-bit debug version or the file was corrupted.
32bit release version*
yeah, I said that it is probvably for a 64 bit, but I have no idea why, I downloaded installer for 32 bit
-
October 30th, 2013, 11:58 AM
#12
Re: MySQL and C++ lib error
Originally Posted by DaigonoYouso
32bit release version*
yeah, I said that it is probvably for a 64 bit, but I have no idea why, I downloaded installer for 32 bit
Well, I downloaded the installer last night, and didn't do anything beyond that except make the installer run.
Make sure that you are pointing to the proper directory. Maybe the installer can detect what system you're running, and install both 32 and 64 bit versions. If that is the case, then usually 32-bit versions are installed in "Program Files (x86)" and not "Program Files". I am running a 32-bit only system, and installing caused no issues.
Regards,
Paul McKenzie
-
September 13th, 2014, 05:39 AM
#13
Re: MySQL and C++ lib error
Hey was just reading through this thread, i am in the same situtation now, i downloaded the x86 mysql installer and picked developer enviroment, now the directories path is C:\Program Files\MySQL\MySQL Server 5.6, and i changed my project from x86 to x64 and it compiled fine, now why would it compile with x64 if i downloaded x86 installer?, how would i get the x86 version of the mysql library so i can use it with an x86 project, thanks if you can help...
-
September 15th, 2014, 09:38 PM
#14
Re: MySQL and C++ lib error
Originally Posted by Anddos
Hey was just reading through this thread, i am in the same situtation now, i downloaded the x86 mysql installer and picked developer enviroment, now the directories path is C:\Program Files\MySQL\MySQL Server 5.6, and i changed my project from x86 to x64 and it compiled fine, now why would it compile with x64 if i downloaded x86 installer?, how would i get the x86 version of the mysql library so i can use it with an x86 project, thanks if you can help...
Looks like the x86 installer detected the 64-bit system and installed the 64-bit version. If it had installed the 32-bit version, it would have installed to C:\Program Files (x86)\etc, not C:\Program Files\etc.
You might try checking if the installer installed to both locations (C:\Program Files\MySQL & and C:\Program Files (x86)\MySQL), otherwise, I'd post a question to the MySQL forum directly.
-
September 19th, 2014, 05:32 PM
#15
Re: MySQL and C++ lib error
Originally Posted by Arjay
Looks like the x86 installer detected the 64-bit system and installed the 64-bit version. If it had installed the 32-bit version, it would have installed to C:\Program Files (x86)\etc, not C:\Program Files\etc.
You might try checking if the installer installed to both locations (C:\Program Files\MySQL & and C:\Program Files (x86)\MySQL), otherwise, I'd post a question to the MySQL forum directly.
theres no MySQL Server 5.6 in C:\Program Files (x86)\MySQL), i dont think posting in the mysql section will help as mysql.h is used for programming related and there is no issues with the server etc..
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|