Permalink
Cannot retrieve contributors at this time
description | title | ms.date | f1_keywords | helpviewer_keywords | ms.assetid |
---|---|---|---|---|---|
Learn more about: Linker Tools Error LNK2028 |
Linker Tools Error LNK2028 |
11/04/2016 |
LNK2028 |
LNK2028 |
e2b03293-6066-464d-a050-ce747bcf7f0e |
«exported_function» (decorated_name) referenced in function «function_containing_function_call» (decorated_name)
Remarks
When attempting to import a native function into a pure image, remember that the implicit calling conventions differ between native and pure compilations.
The /clr:pure compiler option is deprecated in Visual Studio 2015 and unsupported in Visual Studio 2017.
Examples
This code sample generates a component with an exported, native, function whose calling convention is implicitly __cdecl.
// LNK2028.cpp // compile with: /LD __declspec(dllexport) int func() { return 3; }
The following sample creates a pure client that consumes the native function. However, the calling convention under /clr:pure is __clrcall. The following sample generates LNK2028.
// LNK2028_b.cpp // compile with: /clr:pure lnk2028.lib // LNK2028 expected int func(); int main() { return func(); }
Kojans 2 / 2 / 4 Регистрация: 27.01.2015 Сообщений: 48 |
||||||||
1 |
||||||||
31.01.2015, 19:05. Показов 15329. Ответов 16 Метки нет (Все метки)
Взял код для графического интерфейса от сюда:
а он ошибки:
0 |
120 / 142 / 46 Регистрация: 31.10.2014 Сообщений: 721 Записей в блоге: 1 |
|
01.02.2015, 10:13 |
2 |
потому что код не С и не С++, а какая то сборная солянка.
0 |
2 / 2 / 4 Регистрация: 27.01.2015 Сообщений: 48 |
|
01.02.2015, 11:46 [ТС] |
3 |
Напиши тогда, как правильно.
0 |
demmax2004 120 / 142 / 46 Регистрация: 31.10.2014 Сообщений: 721 Записей в блоге: 1 |
||||
01.02.2015, 12:17 |
4 |
|||
0 |
2 / 2 / 4 Регистрация: 27.01.2015 Сообщений: 48 |
|
01.02.2015, 13:33 [ТС] |
5 |
error C2601: ‘SendToCalc’ : local function definitions are illegal
0 |
120 / 142 / 46 Регистрация: 31.10.2014 Сообщений: 721 Записей в блоге: 1 |
|
01.02.2015, 14:19 |
6 |
Добавь ее в класс если нужно
0 |
Модератор 8809 / 6592 / 894 Регистрация: 14.02.2011 Сообщений: 23,178 |
|
01.02.2015, 14:40 |
7 |
main.cpp
error LNK2028: unresolved token (0A000037) «extern «C» int __stdcall PostMessageW есть подозрение, что код для винды, а проект сделан под консоль
0 |
Kojans 2 / 2 / 4 Регистрация: 27.01.2015 Сообщений: 48 |
||||
01.02.2015, 15:26 [ТС] |
8 |
|||
да, я хотел консольное переделать в вин Добавлено через 14 минут
Добавь ее в класс если нужно
0 |
120 / 142 / 46 Регистрация: 31.10.2014 Сообщений: 721 Записей в блоге: 1 |
|
01.02.2015, 16:24 |
9 |
есть подозрение, что код для винды, а проект сделан под консоль Без разницы.
referenced in function «private: void __clrcall WinForm::MyForm::SendToCalc(void)» Зачем ты опять пользуешься НЕ языком программирования С++ ?????
0 |
Kojans 2 / 2 / 4 Регистрация: 27.01.2015 Сообщений: 48 |
||||
01.02.2015, 16:28 [ТС] |
10 |
|||
Подставь сюда, чтобы работало
0 |
Модератор 8809 / 6592 / 894 Регистрация: 14.02.2011 Сообщений: 23,178 |
|
01.02.2015, 16:38 |
11 |
я хотел консольное переделать в вин да судя по этому тебе лучше уйти в специализированную ветку
Без разницы. Серьезно?
ты опять пользуешься НЕ языком программирования С++ это язык c++ cli(у Visual Studio это CLR)
0 |
120 / 142 / 46 Регистрация: 31.10.2014 Сообщений: 721 Записей в блоге: 1 |
|||||
01.02.2015, 17:12 |
12 |
||||
Подставь сюда, чтобы работало Это не С++. Пиши код на С++ Добавлено через 55 секунд
и консолька не поддерживает виндовые библиотеки?без лишних телодвижений У меня все без проблем делается, видимо у меня руки прямые и из нужных мест растут.
0 |
Администратор 9392 / 4676 / 757 Регистрация: 17.04.2012 Сообщений: 9,519 Записей в блоге: 14 |
|
07.02.2015, 13:15 |
13 |
РешениеKojans, нужно добавить зависимости в свойствах проекта: открываете свойства проекта, там идёте по «Компоновщик — Ввод — Дополнительные зависимости» Добавляете библиотеки advapi32.lib, kernel32.lib и user32.lib Теперь должно нормально скомпоноваться.
8 |
Kojans 2 / 2 / 4 Регистрация: 27.01.2015 Сообщений: 48 |
||||
07.02.2015, 19:42 [ТС] |
14 |
|||
Компилируется без ошибок, но ничего не выполняется.
Подскажете, как это переделать под c++ cli?
0 |
Администратор 9392 / 4676 / 757 Регистрация: 17.04.2012 Сообщений: 9,519 Записей в блоге: 14 |
|
07.02.2015, 20:14 |
15 |
но ничего не выполняется Калькулятор открыт? Если вы на Windows 7, то окно просто «Калькулятор».
0 |
Модератор 8809 / 6592 / 894 Регистрация: 14.02.2011 Сообщений: 23,178 |
|
07.02.2015, 20:14 |
16 |
Hop = FindWindow проверять нужно нашел /не нашел
0 |
2 / 2 / 4 Регистрация: 27.01.2015 Сообщений: 48 |
|
07.02.2015, 20:38 [ТС] |
17 |
Но GetPixel работает.
0 |
IT_Exp Эксперт 87844 / 49110 / 22898 Регистрация: 17.06.2006 Сообщений: 92,604 |
07.02.2015, 20:38 |
Помогаю со студенческими работами здесь Error LNK2028, LNK2019, LNK1120: 2 неразрешенных внешних элементов Ошибки LNK2019 и LNK2001 при сборке проекта
Error LNK1120, error LNK2019, error LNK2028, queue // строка, из-за… Искать еще темы с ответами Или воспользуйтесь поиском по форуму: 17 |
I have got a .dll file and .lib file. For these I have also header files.
When I am writing a console application with these files, everything is Ok. Our program ran. But, when I try to write windows application with VStudio .NET2005 C++, I got these errors.
________________
Error 1 error LNK2028: unresolved token (0A000010) «public: static class My1614::ATDeviceManager * __cdecl My1614::ATDeviceManager::Instance(void)» (?Instance@ATDeviceManager@My1614@@$$FSAPAV12@XZ) referenced in function «private: void __clrcall My1614::Form1::button1_Click(class System:bject ^,class System::EventArgs ^)» (?button1_Click@Form1@My1614@@$$FA$AAMXP$AAVObject@System@@P$AAVEventArgs@4@@Z) 1614.obj
Error 2 error LNK2019: unresolved external symbol «public: static class My1614::ATDeviceManager * __cdecl My1614::ATDeviceManager::Instance(void)» (?Instance@ATDeviceManager@My1614@@$$FSAPAV12@XZ) referenced in function «private: void __clrcall My1614::Form1::button1_Click(class System:bject ^,class System::EventArgs ^)» (?button1_Click@Form1@My1614@@$$FA$AAMXP$AAVObject@System@@P$AAVEventArgs@4@@Z) 1614.obj
Error 3 fatal error LNK1120: 2 unresolved externals C:UsersmeeDocumentsVisual Studio 2005Projects1614Debug1614.exe
_________________
* I also write the library information in «Project->Properties->Linker->Additional Dependicies—> «
* I think the problem is relevant with manage code or unmanaged code. But if it is even yes, I did not solve the problem.
What is wrong?
Hi I have seen this type of question have been asked before but none of them worked for me. Thats why I am asking again.
I have written a code using opencv 2.4 and I have added all the files needed by the code. but still I am getting this error.
Error 1 error LNK2028: unresolved token (0A00000C) "extern "C" unsigned long __stdcall ibwrt(int,void const *,unsigned int)" (?ibwrt@@$$J212YGKHPBXI@Z) referenced in function "int __cdecl WriteData(void const *,unsigned int)" (?WriteData@@$$FYAHPBXI@Z) D:F1Nh-TESTER-2014-08-04PUMA_LED_TESTERPUMA_LED_TESTERni_gpib.obj PUMA_LED_TESTER
I tried solving this by adding the header file related to this function but nothing worked. Please help me resolving this.
See more:
<windows.h> already included
WINVER = 0x0501 for Xp already defined in windows.h
Server program, using TCP
#include <stdio.h> #include <winsock2.h> int main() { WORD wVersionRequested; WSADATA wsaData; int wsaerr; wVersionRequested = MAKEWORD(2, 2); wsaerr = WSAStartup(wVersionRequested, &wsaData); if (wsaerr != 0) { printf("Server: The Winsock dll not found!n"); return 0; } else { printf("Server: The Winsock dll found!n"); printf("Server: The status: %s.n", wsaData.szSystemStatus); } if (LOBYTE(wsaData.wVersion) != 2 || HIBYTE(wsaData.wVersion) != 2 ) { printf("Server: The dll do not support the Winsock version %u.%u!n", LOBYTE(wsaData.wVersion), HIBYTE(wsaData.wVersion)); WSACleanup(); return 0; } else { printf("Server: The dll supports the Winsock version %u.%u!n", LOBYTE(wsaData.wVersion), HIBYTE(wsaData.wVersion)); printf("Server: The highest version this dll can support: %u.%un", LOBYTE(wsaData.wHighVersion), HIBYTE(wsaData.wHighVersion)); } SOCKET m_socket; m_socket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); if (m_socket == INVALID_SOCKET) { printf("Server: Error at socket(): %ldn", WSAGetLastError()); WSACleanup(); return 0; } else { printf("Server: socket() is OK!n"); } sockaddr_in service; service.sin_family = AF_INET; service.sin_addr.s_addr = inet_addr("127.0.0.1"); service.sin_port = htons(55555); if (bind(m_socket, (SOCKADDR*)&service, sizeof(service)) == SOCKET_ERROR) { printf("Server: bind() failed: %ld.n", WSAGetLastError()); closesocket(m_socket); return 0; } else { printf("Server: bind() is OK!n"); } if (listen(m_socket, 10) == SOCKET_ERROR) printf("Server: listen(): Error listening on socket %ld.n", WSAGetLastError()); else { printf("Server: listen() is OK, I'm waiting for connections...n"); } SOCKET AcceptSocket; printf("Server: Waiting for a client to connect...n" ); printf("***Hint: Server is ready...run your client program...***n"); while (1) { AcceptSocket = SOCKET_ERROR; while (AcceptSocket == SOCKET_ERROR) { AcceptSocket = accept(m_socket, NULL, NULL); } printf("Server: Client Connected!n"); m_socket = AcceptSocket; break; } int bytesSent; int bytesRecv = SOCKET_ERROR; char sendbuf[200] = "This string is a test data from server"; char recvbuf[200] = ""; printf("Server: Sending some test data to client...n"); bytesSent = send(m_socket, sendbuf, strlen(sendbuf), 0); if (bytesSent == SOCKET_ERROR) printf("Server: send() error %ld.n", WSAGetLastError()); else { printf("Server: send() is OK.n"); printf("Server: Bytes Sent: %ld.n", bytesSent); } bytesRecv = recv(m_socket, recvbuf, 200, 0); if (bytesRecv == SOCKET_ERROR) printf("Server: recv() error %ld.n", WSAGetLastError()); else { printf("Server: recv() is OK.n"); printf("Server: Received data is: "%s"n", recvbuf); printf("Server: Bytes received: %ld.n", bytesRecv); } WSACleanup(); return 0; }
error log’
1>------ Build started: Project: server, Configuration: Debug Win32 ------ 1>Compiling... 1>server.cpp 1>Linking... 1>server.obj : error LNK2028: unresolved token (0A000018) "extern "C" int __stdcall WSAStartup(unsigned short,struct WSAData *)" (?WSAStartup@@$$J18YGHGPAUWSAData@@@Z) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ) 1>server.obj : error LNK2028: unresolved token (0A00001B) "extern "C" unsigned long __stdcall inet_addr(char const *)" (?inet_addr@@$$J14YGKPBD@Z) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ) 1>server.obj : error LNK2028: unresolved token (0A000020) "extern "C" int __stdcall WSAGetLastError(void)" (?WSAGetLastError@@$$J10YGHXZ) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ) 1>server.obj : error LNK2028: unresolved token (0A000022) "extern "C" unsigned short __stdcall htons(unsigned short)" (?htons@@$$J14YGGG@Z) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ) 1>server.obj : error LNK2028: unresolved token (0A00002B) "extern "C" int __stdcall WSACleanup(void)" (?WSACleanup@@$$J10YGHXZ) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ) 1>server.obj : error LNK2028: unresolved token (0A00002C) "extern "C" int __stdcall recv(unsigned int,char *,int,int)" (?recv@@$$J216YGHIPADHH@Z) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ) 1>server.obj : error LNK2028: unresolved token (0A00002D) "extern "C" int __stdcall bind(unsigned int,struct sockaddr const *,int)" (?bind@@$$J212YGHIPBUsockaddr@@H@Z) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ) 1>server.obj : error LNK2028: unresolved token (0A000031) "extern "C" unsigned int __stdcall socket(int,int,int)" (?socket@@$$J212YGIHHH@Z) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ) 1>server.obj : error LNK2028: unresolved token (0A000037) "extern "C" int __stdcall closesocket(unsigned int)" (?closesocket@@$$J14YGHI@Z) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ) 1>server.obj : error LNK2028: unresolved token (0A000041) "extern "C" int __stdcall send(unsigned int,char const *,int,int)" (?send@@$$J216YGHIPBDHH@Z) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ) 1>server.obj : error LNK2028: unresolved token (0A000047) "extern "C" int __stdcall listen(unsigned int,int)" (?listen@@$$J18YGHIH@Z) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ) 1>server.obj : error LNK2028: unresolved token (0A00004A) "extern "C" unsigned int __stdcall accept(unsigned int,struct sockaddr *,int *)" (?accept@@$$J212YGIIPAUsockaddr@@PAH@Z) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ) 1>server.obj : error LNK2019: unresolved external symbol "extern "C" int __stdcall recv(unsigned int,char *,int,int)" (?recv@@$$J216YGHIPADHH@Z) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ) 1>server.obj : error LNK2019: unresolved external symbol "extern "C" int __stdcall send(unsigned int,char const *,int,int)" (?send@@$$J216YGHIPBDHH@Z) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ) 1>server.obj : error LNK2019: unresolved external symbol "extern "C" unsigned int __stdcall accept(unsigned int,struct sockaddr *,int *)" (?accept@@$$J212YGIIPAUsockaddr@@PAH@Z) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ) 1>server.obj : error LNK2019: unresolved external symbol "extern "C" int __stdcall listen(unsigned int,int)" (?listen@@$$J18YGHIH@Z) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ) 1>server.obj : error LNK2019: unresolved external symbol "extern "C" int __stdcall closesocket(unsigned int)" (?closesocket@@$$J14YGHI@Z) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ) 1>server.obj : error LNK2019: unresolved external symbol "extern "C" int __stdcall bind(unsigned int,struct sockaddr const *,int)" (?bind@@$$J212YGHIPBUsockaddr@@H@Z) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ) 1>server.obj : error LNK2019: unresolved external symbol "extern "C" unsigned short __stdcall htons(unsigned short)" (?htons@@$$J14YGGG@Z) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ) 1>server.obj : error LNK2019: unresolved external symbol "extern "C" unsigned long __stdcall inet_addr(char const *)" (?inet_addr@@$$J14YGKPBD@Z) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ) 1>server.obj : error LNK2019: unresolved external symbol "extern "C" int __stdcall WSAGetLastError(void)" (?WSAGetLastError@@$$J10YGHXZ) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ) 1>server.obj : error LNK2019: unresolved external symbol "extern "C" unsigned int __stdcall socket(int,int,int)" (?socket@@$$J212YGIHHH@Z) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ) 1>server.obj : error LNK2019: unresolved external symbol "extern "C" int __stdcall WSACleanup(void)" (?WSACleanup@@$$J10YGHXZ) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ) 1>server.obj : error LNK2019: unresolved external symbol "extern "C" int __stdcall WSAStartup(unsigned short,struct WSAData *)" (?WSAStartup@@$$J18YGHGPAUWSAData@@@Z) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ) 1>C:Documents and SettingssyamMy DocumentsVisual Studio 2008ProjectsserverDebugserver.exe : fatal error LNK1120: 24 unresolved externals 1>Build log was saved at "file://c:Documents and SettingssyamMy DocumentsVisual Studio 2008ProjectsserverserverDebugBuildLog.htm" 1>server - 25 error(s), 0 warning(s)<pre lang="text">