c++ - Windows Forms应用程序中的链接器错误

标签 c++ c++-cli linker-errors

我正在尝试制作我的第一个Windows窗体应用程序。我试图建立一个SQL连接,所以我插入了我的SQL函数,该函数在控制台应用程序中非常有效。我重写了一下,但是现在,我收到了链接器错误,而且我不知道为什么。

有人可以帮助我,我做错了吗?

谢谢!

错误:
Error 3 error LNK2028: unresolved token (0A000023) "extern "C" short __stdcall SQLGetData(void *,unsigned short,short,void *,long,long *)" (?SQLGetData@@$$J224YGFPAXGF0JPAJ@Z) referenced in function "private: bool __clrcall Test_WindowsForm::Form1::ExecuteSQLCommand(void)" (?ExecuteSQLCommand@Form1@Test_WindowsForm@@$$FA$AAM_NXZ) Test_WindowsForm.objError 4 error LNK2028: unresolved token (0A000024) "extern "C" short __stdcall SQLFetch(void *)" (?SQLFetch@@$$J14YGFPAX@Z) referenced in function "private: bool __clrcall Test_WindowsForm::Form1::ExecuteSQLCommand(void)" (?ExecuteSQLCommand@Form1@Test_WindowsForm@@$$FA$AAM_NXZ) Test_WindowsForm.objError 5 error LNK2028: unresolved token (0A000025) "extern "C" short __stdcall SQLRowCount(void *,long *)" (?SQLRowCount@@$$J18YGFPAXPAJ@Z) referenced in function "private: bool __clrcall Test_WindowsForm::Form1::ExecuteSQLCommand(void)" (?ExecuteSQLCommand@Form1@Test_WindowsForm@@$$FA$AAM_NXZ) Test_WindowsForm.objError 6 error LNK2028: unresolved token (0A000026) "extern "C" short __stdcall SQLNumResultCols(void *,short *)" (?SQLNumResultCols@@$$J18YGFPAXPAF@Z) referenced in function "private: bool __clrcall Test_WindowsForm::Form1::ExecuteSQLCommand(void)" (?ExecuteSQLCommand@Form1@Test_WindowsForm@@$$FA$AAM_NXZ) Test_WindowsForm.objError 7 error LNK2028: unresolved token (0A000027) "extern "C" short __stdcall SQLDisconnect(void *)" (?SQLDisconnect@@$$J14YGFPAX@Z) referenced in function "private: bool __clrcall Test_WindowsForm::Form1::ExecuteSQLCommand(void)" (?ExecuteSQLCommand@Form1@Test_WindowsForm@@$$FA$AAM_NXZ) Test_WindowsForm.objError 8 error LNK2028: unresolved token (0A000028) "extern "C" short __stdcall SQLFreeHandle(short,void *)" (?SQLFreeHandle@@$$J18YGFFPAX@Z) referenced in function "private: bool __clrcall Test_WindowsForm::Form1::ExecuteSQLCommand(void)" (?ExecuteSQLCommand@Form1@Test_WindowsForm@@$$FA$AAM_NXZ) Test_WindowsForm.objError 9 error LNK2028: unresolved token (0A000029) "extern "C" short __stdcall SQLExecDirectA(void *,unsigned char *,long)" (?SQLExecDirectA@@$$J212YGFPAXPAEJ@Z) referenced in function "private: bool __clrcall Test_WindowsForm::Form1::ExecuteSQLCommand(void)" (?ExecuteSQLCommand@Form1@Test_WindowsForm@@$$FA$AAM_NXZ) Test_WindowsForm.objError 10 error LNK2028: unresolved token (0A00002A) "extern "C" short __stdcall SQLSetStmtAttrW(void *,long,void *,long)" (?SQLSetStmtAttrW@@$$J216YGFPAXJ0J@Z) referenced in function "private: bool __clrcall Test_WindowsForm::Form1::ExecuteSQLCommand(void)" (?ExecuteSQLCommand@Form1@Test_WindowsForm@@$$FA$AAM_NXZ) Test_WindowsForm.objError 11 error LNK2028: unresolved token (0A00002B) "extern "C" short __stdcall SQLDriverConnectA(void *,struct HWND__ *,unsigned char *,short,unsigned char *,short,short *,unsigned short)" (?SQLDriverConnectA@@$$J232YGFPAXPAUHWND__@@PAEF2FPAFG@Z) referenced in function "private: bool __clrcall Test_WindowsForm::Form1::ExecuteSQLCommand(void)" (?ExecuteSQLCommand@Form1@Test_WindowsForm@@$$FA$AAM_NXZ) Test_WindowsForm.objError 12 error LNK2028: unresolved token (0A00002C) "extern "C" short __stdcall SQLSetConnectAttrW(void *,long,void *,long)" (?SQLSetConnectAttrW@@$$J216YGFPAXJ0J@Z) referenced in function "private: bool __clrcall Test_WindowsForm::Form1::ExecuteSQLCommand(void)" (?ExecuteSQLCommand@Form1@Test_WindowsForm@@$$FA$AAM_NXZ) Test_WindowsForm.objError 13 error LNK2028: unresolved token (0A00002D) "extern "C" short __stdcall SQLSetEnvAttr(void *,long,void *,long)" (?SQLSetEnvAttr@@$$J216YGFPAXJ0J@Z) referenced in function "private: bool __clrcall Test_WindowsForm::Form1::ExecuteSQLCommand(void)" (?ExecuteSQLCommand@Form1@Test_WindowsForm@@$$FA$AAM_NXZ) Test_WindowsForm.objError 14 error LNK2028: unresolved token (0A00002E) "extern "C" short __stdcall SQLAllocHandle(short,void *,void * *)" (?SQLAllocHandle@@$$J212YGFFPAXPAPAX@Z) referenced in function "private: bool __clrcall Test_WindowsForm::Form1::ExecuteSQLCommand(void)" (?ExecuteSQLCommand@Form1@Test_WindowsForm@@$$FA$AAM_NXZ) Test_WindowsForm.objError 15 error LNK2019: unresolved external symbol "extern "C" short __stdcall SQLGetData(void *,unsigned short,short,void *,long,long *)" (?SQLGetData@@$$J224YGFPAXGF0JPAJ@Z) referenced in function "private: bool __clrcall Test_WindowsForm::Form1::ExecuteSQLCommand(void)" (?ExecuteSQLCommand@Form1@Test_WindowsForm@@$$FA$AAM_NXZ) Test_WindowsForm.objError 16 error LNK2019: unresolved external symbol "extern "C" short __stdcall SQLFetch(void *)" (?SQLFetch@@$$J14YGFPAX@Z) referenced in function "private: bool __clrcall Test_WindowsForm::Form1::ExecuteSQLCommand(void)" (?ExecuteSQLCommand@Form1@Test_WindowsForm@@$$FA$AAM_NXZ) Test_WindowsForm.objError 17 error LNK2019: unresolved external symbol "extern "C" short __stdcall SQLRowCount(void *,long *)" (?SQLRowCount@@$$J18YGFPAXPAJ@Z) referenced in function "private: bool __clrcall Test_WindowsForm::Form1::ExecuteSQLCommand(void)" (?ExecuteSQLCommand@Form1@Test_WindowsForm@@$$FA$AAM_NXZ) Test_WindowsForm.objError 18 error LNK2019: unresolved external symbol "extern "C" short __stdcall SQLNumResultCols(void *,short *)" (?SQLNumResultCols@@$$J18YGFPAXPAF@Z) referenced in function "private: bool __clrcall Test_WindowsForm::Form1::ExecuteSQLCommand(void)" (?ExecuteSQLCommand@Form1@Test_WindowsForm@@$$FA$AAM_NXZ) Test_WindowsForm.objError 19 error LNK2019: unresolved external symbol "extern "C" short __stdcall SQLDisconnect(void *)" (?SQLDisconnect@@$$J14YGFPAX@Z) referenced in function "private: bool __clrcall Test_WindowsForm::Form1::ExecuteSQLCommand(void)" (?ExecuteSQLCommand@Form1@Test_WindowsForm@@$$FA$AAM_NXZ) Test_WindowsForm.objError 20 error LNK2019: unresolved external symbol "extern "C" short __stdcall SQLFreeHandle(short,void *)" (?SQLFreeHandle@@$$J18YGFFPAX@Z) referenced in function "private: bool __clrcall Test_WindowsForm::Form1::ExecuteSQLCommand(void)" (?ExecuteSQLCommand@Form1@Test_WindowsForm@@$$FA$AAM_NXZ) Test_WindowsForm.objError 21 error LNK2019: unresolved external symbol "extern "C" short __stdcall SQLExecDirectA(void *,unsigned char *,long)" (?SQLExecDirectA@@$$J212YGFPAXPAEJ@Z) referenced in function "private: bool __clrcall Test_WindowsForm::Form1::ExecuteSQLCommand(void)" (?ExecuteSQLCommand@Form1@Test_WindowsForm@@$$FA$AAM_NXZ) Test_WindowsForm.objError 22 error LNK2019: unresolved external symbol "extern "C" short __stdcall SQLSetStmtAttrW(void *,long,void *,long)" (?SQLSetStmtAttrW@@$$J216YGFPAXJ0J@Z) referenced in function "private: bool __clrcall Test_WindowsForm::Form1::ExecuteSQLCommand(void)" (?ExecuteSQLCommand@Form1@Test_WindowsForm@@$$FA$AAM_NXZ) Test_WindowsForm.objError 23 error LNK2019: unresolved external symbol "extern "C" short __stdcall SQLDriverConnectA(void *,struct HWND__ *,unsigned char *,short,unsigned char *,short,short *,unsigned short)" (?SQLDriverConnectA@@$$J232YGFPAXPAUHWND__@@PAEF2FPAFG@Z) referenced in function "private: bool __clrcall Test_WindowsForm::Form1::ExecuteSQLCommand(void)" (?ExecuteSQLCommand@Form1@Test_WindowsForm@@$$FA$AAM_NXZ) Test_WindowsForm.objError 24 error LNK2019: unresolved external symbol "extern "C" short __stdcall SQLSetConnectAttrW(void *,long,void *,long)" (?SQLSetConnectAttrW@@$$J216YGFPAXJ0J@Z) referenced in function "private: bool __clrcall Test_WindowsForm::Form1::ExecuteSQLCommand(void)" (?ExecuteSQLCommand@Form1@Test_WindowsForm@@$$FA$AAM_NXZ) Test_WindowsForm.objError 25 error LNK2019: unresolved external symbol "extern "C" short __stdcall SQLSetEnvAttr(void *,long,void *,long)" (?SQLSetEnvAttr@@$$J216YGFPAXJ0J@Z) referenced in function "private: bool __clrcall Test_WindowsForm::Form1::ExecuteSQLCommand(void)" (?ExecuteSQLCommand@Form1@Test_WindowsForm@@$$FA$AAM_NXZ) Test_WindowsForm.objError 26 error LNK2019: unresolved external symbol "extern "C" short __stdcall SQLAllocHandle(short,void *,void * *)" (?SQLAllocHandle@@$$J212YGFFPAXPAPAX@Z) referenced in function "private: bool __clrcall Test_WindowsForm::Form1::ExecuteSQLCommand(void)" (?ExecuteSQLCommand@Form1@Test_WindowsForm@@$$FA$AAM_NXZ) Test_WindowsForm.objError 27 fatal error LNK1120: 24 unresolved externals D:\testVS2008\Test_WindowsForm\Debug\Test_WindowsForm.exe

最佳答案

您需要将odbc32.lib添加到项目的linker inputs中。

关于c++ - Windows Forms应用程序中的链接器错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8217744/

相关文章:

c++ - 你能在 C++ 中嵌入 for 循环吗?

c++ - erase-remove 习语 : did I just delete something?

c - 包含 gcc 的链接器选项

c++ - .NET c++ 中父级的子窗体调用函数

c# - 使用 C++-cli,如何实例化 C# 库中定义的 WinForms 表单?

ios - 代码 8 : Symbol(s) not found for architecture arm64 for pods

c++ - 使用 g++ 编译 C 和 C++ 代码时出现链接错误

c++ - 使用 substr 查找附近的字符

c++ - 为什么 MinGW 将 Win API 函数定义为宏?

visual-studio-2012 - 如何在 Visual Studio 中设置 C++/CLI 项目的版本?