CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 28

Hybrid View

  1. #1
    Join Date
    Oct 2013
    Posts
    39

    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

  2. #2
    Join Date
    Apr 1999
    Posts
    27,449

    Re: MySQL and C++ lib error

    Quote Originally Posted by DaigonoYouso View Post
    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.
    5. linked "libmysql.lib"
    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

  3. #3
    Join Date
    Oct 2013
    Posts
    39

    Re: MySQL and C++ lib error

    Quote Originally Posted by Paul McKenzie View Post
    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

  4. #4
    VictorN's Avatar
    VictorN is online now Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: MySQL and C++ lib error

    Quote Originally Posted by DaigonoYouso View Post
    ...
    5. i linked it under input
    What could it mean?
    Victor Nijegorodov

  5. #5
    Join Date
    Oct 2013
    Posts
    39

    Re: MySQL and C++ lib error

    Quote Originally Posted by VictorN View Post
    What could it mean?
    uhm, that it is linked under input section of linker in properties?

  6. #6
    VictorN's Avatar
    VictorN is online now Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: MySQL and C++ lib error

    Quote Originally Posted by DaigonoYouso View Post
    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

  7. #7
    Join Date
    Apr 1999
    Posts
    27,449

    Re: MySQL and C++ lib error

    Here is the lib file that was installed on my machine.

    libsql.zip

    Regards,

    Paul McKenzie

  8. #8
    Join Date
    Oct 2013
    Posts
    39

    Re: MySQL and C++ lib error

    Quote Originally Posted by Paul McKenzie View Post
    Here is the lib file that was installed on my machine.

    libsql.zip

    Regards,

    Paul McKenzie
    works, why?

  9. #9
    Join Date
    Apr 1999
    Posts
    27,449

    Re: MySQL and C++ lib error

    Quote Originally Posted by DaigonoYouso View Post
    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

  10. #10
    VictorN's Avatar
    VictorN is online now Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: MySQL and C++ lib error

    Quote Originally Posted by DaigonoYouso View Post
    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

  11. #11
    Join Date
    Oct 2013
    Posts
    39

    Re: MySQL and C++ lib error

    Quote Originally Posted by VictorN View Post
    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

  12. #12
    Join Date
    Apr 1999
    Posts
    27,449

    Re: MySQL and C++ lib error

    Quote Originally Posted by DaigonoYouso View Post
    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

  13. #13
    Join Date
    Nov 2004
    Posts
    17

    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...

  14. #14
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: MySQL and C++ lib error

    Quote Originally Posted by Anddos View Post
    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.

  15. #15
    Join Date
    Nov 2004
    Posts
    17

    Re: MySQL and C++ lib error

    Quote Originally Posted by Arjay View Post
    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..

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured