为什么我仍然在MySQL C ++ API中获得未解析的外部符号? [英] Why am I still getting unresolved external symbols in MySQL C++ API?

查看:96
本文介绍了为什么我仍然在MySQL C ++ API中获得未解析的外部符号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,所以我应该首先提到我在两个C ++项目中使用VS 2010和MySQL C API。一个项目是一个API静态库我正在创建,以便更快地访问我的MySQL数据库(使用api ..),而另一个项目是一个控制台应用程序,将测试新的库。在两个项目属性下,我已设置PROPERTIES \ CONFIGURATION PROPERTIES \ C / C ++ \ ADDITIONAL INCLUDE LIBRARIES以包含包含包含文件的MySQL文件夹(MySQL \ Include)。对于测试应用程序,我显然也将头文件包含在我的静态库中。



在PROPERTIES \ CONFIGURATION PROPERTIES \ LINKER \ GENERAL中,我已经包含MySQL库目录(MySQL \ lib \ opt),以及我的新库的静态库文件。我还为Input下的Additional Dependencies添加了必要的lib文件以及两个程序。但是,虽然我的静态库编译得很好,但是当我尝试编译测试应用程序时,我仍然会收到以下错误:



Okay, so I should probably start off by mentioning that I am using VS 2010 with the MySQL C API in two C++ projects. One project is an API static library I''m creating for providing quicker access to my MySQL database (using the api..), while the other project is a console app that will test the new library. Under both project properties I have set PROPERTIES \ CONFIGURATION PROPERTIES \ C/C++ \ ADDITIONAL INCLUDE LIBRARIES to include the MySQL folder containing the include files (MySQL \ Include). For the test app, I obviously include the header file to my static library as well.

In PROPERTIES \ CONFIGURATION PROPERTIES \ LINKER \ GENERAL, I have included the MySQL library directory (MySQL \ lib \ opt), as well as the static library file for my new library. I also added the necessary lib files for "Additional Dependencies" under "Input" as well for both programs. However, although my static library compiles fine, when I try compiling the test app I still get the following errors:

Error	27	error LNK2019: unresolved external symbol _mysql_real_connect@32 referenced in function "public: __thiscall Mainframe::User::User(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (??0User@Mainframe@@QAE@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)	E:\My Documents\Visual Studio 2010\Projects\Example\MSQLClientTest\server.lib(connect.obj)	MSQLClientTest

Error	30	error LNK2019: unresolved external symbol _mysql_query@8 referenced in function "public: int __thiscall Mainframe::User::grabInfo(void)" (?grabInfo@User@Mainframe@@QAEHXZ)	E:\My Documents\Visual Studio 2010\Projects\Example\MSQLClientTest\server.lib(connect.obj)	MSQLClientTest

Error	28	error LNK2019: unresolved external symbol _mysql_init@4 referenced in function "public: __thiscall Mainframe::User::User(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (??0User@Mainframe@@QAE@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)	E:\My Documents\Visual Studio 2010\Projects\Example\MSQLClientTest\server.lib(connect.obj)	MSQLClientTest

Error	29	error LNK2019: unresolved external symbol _mysql_close@4 referenced in function "public: int __thiscall Mainframe::User::grabInfo(void)" (?grabInfo@User@Mainframe@@QAEHXZ)	E:\My Documents\Visual Studio 2010\Projects\Example\MSQLClientTest\server.lib(connect.obj)	MSQLClientTest

Error	31	error LNK1120: 4 unresolved externals	1	E:\My Documents\Visual Studio 2010\Projects\Example\Debug\MSQLClientTest.exe	1	MSQLClientTest





这是我的库代码示例及其实现:



server.h



Here''s a sample of my library code and it''s implementation:

server.h

#include <vector>
#include <iostream>
#include <string>
#include <my_global.h>
#include <mysql.h>
namespace Mainframe
{
class User
{

public:
	
	Mainframe::User::User();
	Mainframe::User::User(std::string);

	int grabInfo();
};
}



图书馆:


Library:

#include "stdafx.h"
#include "server.h"

    Mainframe::User::User() {}
    Mainframe::User::User(std::string id)
	{
	conn = mysql_init(NULL); //Obtain a connection handler

	//Connect to the server...
	mysql_real_connect(conn, "localhost", "root", "password", "users", 0, NULL, 0);
	}

	int Mainframe::User::grabInfo()
	{
		return mysql_query(conn, "SELECT * FROM users");
		mysql_close(conn);
	}





测试应用:



Test App:

#include "stdafx.h"
#include "server.h"

int main(int argc, char* argv[])
{
	Mainframe::User u;
	std::cout << u.grabInfo();
	std::system("PAUSE");
	return 0;
}





知道造成这些错误的原因是什么吗?快速谷歌搜索显示这是一个常见问题,但我所看到的单一论坛似乎没有提供适用的解决方案。任何帮助将不胜感激。



TIA!



Any idea what''s causing these errors? A quick Google search reveals that this is a common issue, but not a single forum I looked at seemed to present an applicable solution. Any help would be greatly appreciated.

TIA!

推荐答案

basic_string @ DU?
basic_string@DU?


char_traits @ D @ std @@ V?
char_traits@D@std@@V?


allocator @ D @ 2 @@ std @@@ Z)E:\ My Documents\Visual Studio 2010 \Projects\Example\MSQLClientTest \server.lib(connect.obj)MSQLClientTest

错误 30 错误LNK2019:未解析的外部符号_mysql_query @ 8引用 函数 public:int __thiscall Mainframe :: User :: grabInfo(void)(?grabInfo @ User @ Mainframe @@ QAEHXZ)E:\ My Documents\Visual Studio 2010 \Projects\Example\MSQLClientTest \ server。 lib(connect.obj)MSQLClientTest

错误 28 错误LNK2019:未解析的外部符号_mysql_init @ 4引用功能 public:__ thishisall Mainframe :: User :: User(class std :: basic_string< char,struct std :: char_traits< char>,类std :: allocator< char> >)(?? 0User @ Mainframe @@ QAE @ V?
allocator@D@2@@std@@@Z) E:\My Documents\Visual Studio 2010\Projects\Example\MSQLClientTest\server.lib(connect.obj) MSQLClientTest Error 30 error LNK2019: unresolved external symbol _mysql_query@8 referenced in function "public: int __thiscall Mainframe::User::grabInfo(void)" (?grabInfo@User@Mainframe@@QAEHXZ) E:\My Documents\Visual Studio 2010\Projects\Example\MSQLClientTest\server.lib(connect.obj) MSQLClientTest Error 28 error LNK2019: unresolved external symbol _mysql_init@4 referenced in function "public: __thiscall Mainframe::User::User(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (??0User@Mainframe@@QAE@V?


这篇关于为什么我仍然在MySQL C ++ API中获得未解析的外部符号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆