C + + uses MySQL API connectivity related issues

Source: Internet
Author: User

Record your own use of the relevant issues, to facilitate the same problem of students to solve.

  • About the various configurations in VS. Look here. Just need to notice, I now use the MySQL version number is 5.6, there is no "MySQL Server \lib\opt" this path. Set this to "MySQL Server \lib" to

  • Assume that an error such as the following occurs:
    1>main.obj:error LNK2019: unresolved external symbol [email protected], which is referenced in function _main 1>main.obj:error LNK2019: unresolved external symbol [Emai L protected]. The symbol is referenced in the function _main 1>main.obj:error LNK2019: unresolved external symbol [email protected], which is referenced in function _main 1>main.obj:error : unresolved external symbol [email protected], the symbol is referenced in function _main

    As a result of the first step, the establishment of the Win32 project, and now the system, MySQL use is x64. It can be changed to x64, the operation process is as follows:
    . Project, properties, Configuration Manager
    Active solution platform. Drop-down to new, a new check box appears. Select X64 in the type select New platform
    Learn from here

  • can then write a simple C program test success
     #include" winsock.h "#include" iostream "#include" mysql.h "#pragma comment (lib," Ws2_32.lib ") #pragma c        Omment (Lib, "Libmysql.lib") using namespace std;            void Main () {MYSQL mydata; Mysql_library_init (0,null,null);//initialize MySQL C API library Mysql_init (&mydata);//Initialize MyData data structure, MyData is MySQL object mysql_ Options (&mydata,mysql_set_charset_name, "GBK");//Connection options: Join GBK Character Set support//Connection function if (Mysql_real_connect (&myda Ta, "localhost", "root", "1234", "Demo", 3306, 0, 0) = NULL) cout<< "Database connection ok!"  <<endl; 

    Note here that several of the parameters in the Mysql_real_connect function (&mydata, "localhost", "root", "1234", "Demo", 3306, 0, 0), generally need to be changed by 2, 3,4,5 several parameters can be, the database location, Username,password, the database name to connect to

  • Suppose the code has a # include "stdafx.h" Error: Error. Unable to open source file ..., see here
    This is mainly because the header file belongs to the precompiled header file. Suppose you didn't tell the VS related information when you created the project, and of course you didn't know what it was.



  • #error: Building MFC Application With/md[d] (CRT DLL version) requires MFC shared DLL version. Please #define _afxdll
    See here

  • C + + Fatal error C1083: Could not open precompiled header file: ". \debug\router.pch"
    See here, this problem is also a precompiled header file problem


C + + uses MySQL API connectivity related issues

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.