-
Notifications
You must be signed in to change notification settings - Fork 103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LNK2019 when build in Visual Studio 2017 #10
Comments
I never tried to build under Windows. Perhaps you need to update the socket
API to use Windows WinSock, a totally different system. (Unix-based systems
uses the same API for network sockets.)
…--
Yours sincerely, Xiaoqi Chen
cxqn.info
On Sat, Jul 28, 2018 at 4:00 PM, kxu-ffd ***@***.***> wrote:
Hi, I am trying your solution to stream OpenCV processed images from one
computer to another. However, I am stuck at the build step. It seems the VS
compiler is not able to link the functions in TCPServerSocket. No issue
during the cmake. I tried to modify the CMakeLists.txt to explicitly
include the header files, but it does not work. Strangely, I am able to
build the project in Ubuntu. The attached is the error log from VS 2017.
PracticalSocket.obj : error LNK2019: unresolved external symbol accept
referenced in function "public: class TCPSocket * __cdecl
TCPServerSocket::accept(void)" ***@***.***@@
QEAAPEAVTCPSocket@@xz <https://github.com/xz>)
2>PracticalSocket.obj : error LNK2019: unresolved external symbol bind
referenced in function "public: void __cdecl Socket::setLocalPort(unsigned
short)" ***@***.***@@***@***.***)
2>PracticalSocket.obj : error LNK2019: unresolved external symbol
closesocket referenced in function "public: __cdecl Socket::~Socket(void)"
(??1Socket@@***@***.***)
2>PracticalSocket.obj : error LNK2019: unresolved external symbol connect
referenced in function "public: void __cdecl CommunicatingSocket::connect(class
std::basic_string<char,struct std::char_traits,class std::allocator > const
&,unsigned short)" ***@***.***@
@***@***.******@***.***@std@@v <https://github.com/v>?$
***@***.***@2@@std <https://github.com/std>@@g ***@***.***)
2>PracticalSocket.obj : error LNK2019: unresolved external symbol
getpeername referenced in function "public: class
std::basic_string<char,struct std::char_traits,class std::allocator >
__cdecl CommunicatingSocket::getForeignAddress(void)" (?getForeignAddress@
CommunicatingSocket@@***@***.******@***.***@std@@v
***@***.***@2@@std <https://github.com/std>@@xz
<https://github.com/xz>)
3>Generating Code...
2>PracticalSocket.obj : error LNK2019: unresolved external symbol
getsockname referenced in function "public: class
std::basic_string<char,struct std::char_traits,class std::allocator >
__cdecl Socket::getLocalAddress(void)" ***@***.***@@
***@***.******@***.***@std@@v <https://github.com/v>?$
***@***.***@2@@std <https://github.com/std>@@xz <https://github.com/xz>)
2>PracticalSocket.obj : error LNK2019: unresolved external symbol htonl
referenced in function "public: void __cdecl Socket::setLocalPort(unsigned
short)" ***@***.***@@***@***.***)
2>PracticalSocket.obj : error LNK2019: unresolved external symbol htons
referenced in function "public: void __cdecl Socket::setLocalPort(unsigned
short)" ***@***.***@@***@***.***)
2>PracticalSocket.obj : error LNK2019: unresolved external symbol
inet_addr referenced in function "public: void __cdecl
UDPSocket::joinGroup(class std::basic_string<char,struct
std::char_traits,class std::allocator > const &)" ***@***.***@@
***@***.******@***.***@std@@v <https://github.com/v>?$
***@***.***@2@@std <https://github.com/std>@@@z <https://github.com/z>)
2>PracticalSocket.obj : error LNK2019: unresolved external symbol
inet_ntoa referenced in function "public: class
std::basic_string<char,struct std::char_traits,class std::allocator >
__cdecl Socket::getLocalAddress(void)" ***@***.***@@
***@***.******@***.***@std@@v <https://github.com/v>?$
***@***.***@2@@std <https://github.com/std>@@xz <https://github.com/xz>)
2>PracticalSocket.obj : error LNK2019: unresolved external symbol listen
referenced in function "private: void __cdecl TCPServerSocket::setListen(int)"
***@***.***@@***@***.***)
2>PracticalSocket.obj : error LNK2019: unresolved external symbol ntohs
referenced in function "public: unsigned short __cdecl
Socket::getLocalPort(void)" ***@***.***@@QEAAGXZ)
2>PracticalSocket.obj : error LNK2019: unresolved external symbol recv
referenced in function "public: int __cdecl CommunicatingSocket::recv(void
*,int)" ***@***.***@@***@***.***)
2>PracticalSocket.obj : error LNK2019: unresolved external symbol recvfrom
referenced in function "public: int __cdecl UDPSocket::recvFrom(void
*,int,class std::basic_string<char,struct std::char_traits,class
std::allocator > &,unsigned short &)" ***@***.***@@
***@***.******@***.***@std@@v
***@***.***@2@@std <https://github.com/std>@@aeag
***@***.***)
2>PracticalSocket.obj : error LNK2019: unresolved external symbol send
referenced in function "public: void __cdecl CommunicatingSocket::send(void
const *,int)" ***@***.***@@***@***.***)
2>PracticalSocket.obj : error LNK2019: unresolved external symbol sendto
referenced in function "public: void __cdecl UDPSocket::sendTo(void const
*,int,class std::basic_string<char,struct std::char_traits,class
std::allocator > const &,unsigned short)" ***@***.***@@
***@***.******@***.***@std@@v
***@***.***@2@@std <https://github.com/std>@@g
***@***.***)
2>PracticalSocket.obj : error LNK2019: unresolved external symbol
setsockopt referenced in function "public: void __cdecl
UDPSocket::setMulticastTTL(unsigned char)" ***@***.***@@
***@***.***)
2>PracticalSocket.obj : error LNK2019: unresolved external symbol socket
referenced in function "protected: __cdecl Socket::Socket(int,int)"
(??0Socket@@iEAA ***@***.***@z)
2>PracticalSocket.obj : error LNK2019: unresolved external symbol
gethostbyname referenced in function "void __cdecl fillAddr(class
std::basic_string<char,struct std::char_traits,class std::allocator > const
&,unsigned short,struct sockaddr_in &)" (?fillAddr@@YAXAEBV?$basic_
***@***.******@***.***@std@@v ***@***.***@2@@std
<https://github.com/std>@@GAEAUsockaddr_in@@@z <https://github.com/z>)
2>PracticalSocket.obj : error LNK2019: unresolved external symbol
getservbyname referenced in function "public: static unsigned short __cdecl
Socket::resolveService(class std::basic_string<char,struct
std::char_traits,class std::allocator > const &,class
std::basic_string<char,struct std::char_traits,class std::allocator > const
&)" ***@***.***@@***@***.******@***.***@std@
@v ***@***.***@2@@std <https://github.com/std>@@0
***@***.***)
2>PracticalSocket.obj : error LNK2019: unresolved external symbol
WSAStartup referenced in function "protected: __cdecl
Socket::Socket(int,int)" (??0Socket@@iEAA ***@***.***@z)
2>PracticalSocket.obj : error LNK2019: unresolved external symbol
WSACleanup referenced in function "public: static void __cdecl
Socket::cleanUp(void)" ***@***.***@@Saxxz)
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#10>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ABvpXhWqS3Vp0ojWlC8XAJiaGt_WoXxRks5uLMLNgaJpZM4VlKkC>
.
|
Looks like practical socket already uses winsock in the Socket superclass if WIN32 is defined. |
Oh interesting, then I dont know why there's linking error. Probably we
need to add a flag (similar to the gcc -lm flag for math module)?
…On Mon, Jul 30, 2018, 15:35 Jie Wei ***@***.***> wrote:
Looks like practical socket already uses winsock in the Socket superclass
if WIN32 is defined.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#10 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABvpXjroxVfCnjMZM5_MtxNvu_-de36sks5uL1_tgaJpZM4VlKkC>
.
|
It may have to do with something is not working well with x64. I tried compiling this for windows in Visual Studios, at first it was just saying my target machine was x86. But after I changed the target machine it started to not recognize the functions. Do you know if practical socket works on x64 bit machines? |
I dont believe its an issue related to x64 in general, as I wrote those
code under OS X x64. I vaguely remember I also tested under VS 2013 x64.
…On Mon, Jul 30, 2018, 16:39 Jie Wei ***@***.***> wrote:
It may have to do with something is not working well with x64. I tried
compiling this for windows in Visual Studios, at first it was just saying
my target machine was x86. But after I changed the target machine it
started to not recognize the functions. Do you know if practical socket
works on x64 bit machines?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#10 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABvpXiRRxpvYu1uM7FjNd-HkDOwLZQhhks5uL27ngaJpZM4VlKkC>
.
|
Looks like it needs to link different libraries and uses different dlls... https://docs.microsoft.com/en-us/windows/desktop/winsock/creating-a-basic-winsock-application tried it out and it works now |
@email2jie , hi , could you share what you tried out and made it work? |
Any plans on updating this to build in windows? |
These code was originally build on Windows using VS2015. If something is
broken now on VS2019, feel free to open pull requests.
|
@jweiA10 How did you get it working on Windows? Can you please share your steps? Thanks. |
If anybody is wondering, for Windows, the easiest method is to replace, in PracticalSocket.cpp :
by :
|
Hi, I am trying your solution to stream OpenCV processed images from one computer to another. However, I am stuck at the build step. It seems the VS compiler is not able to link the functions in TCPServerSocket. No issue during the cmake. I tried to modify the CMakeLists.txt to explicitly include the header files, but it does not work. Strangely, I am able to build the project in Ubuntu. The attached is the error log from VS 2017.
PracticalSocket.obj : error LNK2019: unresolved external symbol accept referenced in function "public: class TCPSocket * __cdecl TCPServerSocket::accept(void)" (?accept@TCPServerSocket@@QEAAPEAVTCPSocket@@xz)
2>PracticalSocket.obj : error LNK2019: unresolved external symbol bind referenced in function "public: void __cdecl Socket::setLocalPort(unsigned short)" (?setLocalPort@Socket@@QEAAXG@Z)
2>PracticalSocket.obj : error LNK2019: unresolved external symbol closesocket referenced in function "public: __cdecl Socket::~Socket(void)" (??1Socket@@qeaa@XZ)
2>PracticalSocket.obj : error LNK2019: unresolved external symbol connect referenced in function "public: void __cdecl CommunicatingSocket::connect(class std::basic_string<char,struct std::char_traits,class std::allocator > const &,unsigned short)" (?connect@CommunicatingSocket@@QEAAXAEBV?$basic_string@DU?$char_traits@D@std@@v?$allocator@D@2@@std@@g@Z)
2>PracticalSocket.obj : error LNK2019: unresolved external symbol getpeername referenced in function "public: class std::basic_string<char,struct std::char_traits,class std::allocator > __cdecl CommunicatingSocket::getForeignAddress(void)" (?getForeignAddress@CommunicatingSocket@@qeaa?AV?$basic_string@DU?$char_traits@D@std@@v?$allocator@D@2@@std@@xz)
3>Generating Code...
2>PracticalSocket.obj : error LNK2019: unresolved external symbol getsockname referenced in function "public: class std::basic_string<char,struct std::char_traits,class std::allocator > __cdecl Socket::getLocalAddress(void)" (?getLocalAddress@Socket@@qeaa?AV?$basic_string@DU?$char_traits@D@std@@v?$allocator@D@2@@std@@xz)
2>PracticalSocket.obj : error LNK2019: unresolved external symbol htonl referenced in function "public: void __cdecl Socket::setLocalPort(unsigned short)" (?setLocalPort@Socket@@QEAAXG@Z)
2>PracticalSocket.obj : error LNK2019: unresolved external symbol htons referenced in function "public: void __cdecl Socket::setLocalPort(unsigned short)" (?setLocalPort@Socket@@QEAAXG@Z)
2>PracticalSocket.obj : error LNK2019: unresolved external symbol inet_addr referenced in function "public: void __cdecl UDPSocket::joinGroup(class std::basic_string<char,struct std::char_traits,class std::allocator > const &)" (?joinGroup@UDPSocket@@QEAAXAEBV?$basic_string@DU?$char_traits@D@std@@v?$allocator@D@2@@std@@@z)
2>PracticalSocket.obj : error LNK2019: unresolved external symbol inet_ntoa referenced in function "public: class std::basic_string<char,struct std::char_traits,class std::allocator > __cdecl Socket::getLocalAddress(void)" (?getLocalAddress@Socket@@qeaa?AV?$basic_string@DU?$char_traits@D@std@@v?$allocator@D@2@@std@@xz)
2>PracticalSocket.obj : error LNK2019: unresolved external symbol listen referenced in function "private: void __cdecl TCPServerSocket::setListen(int)" (?setListen@TCPServerSocket@@AEAAXH@Z)
2>PracticalSocket.obj : error LNK2019: unresolved external symbol ntohs referenced in function "public: unsigned short __cdecl Socket::getLocalPort(void)" (?getLocalPort@Socket@@QEAAGXZ)
2>PracticalSocket.obj : error LNK2019: unresolved external symbol recv referenced in function "public: int __cdecl CommunicatingSocket::recv(void *,int)" (?recv@CommunicatingSocket@@QEAAHPEAXH@Z)
2>PracticalSocket.obj : error LNK2019: unresolved external symbol recvfrom referenced in function "public: int __cdecl UDPSocket::recvFrom(void *,int,class std::basic_string<char,struct std::char_traits,class std::allocator > &,unsigned short &)" (?recvFrom@UDPSocket@@QEAAHPEAXHAEAV?$basic_string@DU?$char_traits@D@std@@v?$allocator@D@2@@std@@aeag@Z)
2>PracticalSocket.obj : error LNK2019: unresolved external symbol send referenced in function "public: void __cdecl CommunicatingSocket::send(void const *,int)" (?send@CommunicatingSocket@@QEAAXPEBXH@Z)
2>PracticalSocket.obj : error LNK2019: unresolved external symbol sendto referenced in function "public: void __cdecl UDPSocket::sendTo(void const *,int,class std::basic_string<char,struct std::char_traits,class std::allocator > const &,unsigned short)" (?sendTo@UDPSocket@@QEAAXPEBXHAEBV?$basic_string@DU?$char_traits@D@std@@v?$allocator@D@2@@std@@g@Z)
2>PracticalSocket.obj : error LNK2019: unresolved external symbol setsockopt referenced in function "public: void __cdecl UDPSocket::setMulticastTTL(unsigned char)" (?setMulticastTTL@UDPSocket@@QEAAXE@Z)
2>PracticalSocket.obj : error LNK2019: unresolved external symbol socket referenced in function "protected: __cdecl Socket::Socket(int,int)" (??0Socket@@iEAA@HH@Z)
2>PracticalSocket.obj : error LNK2019: unresolved external symbol gethostbyname referenced in function "void __cdecl fillAddr(class std::basic_string<char,struct std::char_traits,class std::allocator > const &,unsigned short,struct sockaddr_in &)" (?fillAddr@@YAXAEBV?$basic_string@DU?$char_traits@D@std@@v?$allocator@D@2@@std@@GAEAUsockaddr_in@@@z)
2>PracticalSocket.obj : error LNK2019: unresolved external symbol getservbyname referenced in function "public: static unsigned short __cdecl Socket::resolveService(class std::basic_string<char,struct std::char_traits,class std::allocator > const &,class std::basic_string<char,struct std::char_traits,class std::allocator > const &)" (?resolveService@Socket@@SAGAEBV?$basic_string@DU?$char_traits@D@std@@v?$allocator@D@2@@std@@0@Z)
2>PracticalSocket.obj : error LNK2019: unresolved external symbol WSAStartup referenced in function "protected: __cdecl Socket::Socket(int,int)" (??0Socket@@iEAA@HH@Z)
2>PracticalSocket.obj : error LNK2019: unresolved external symbol WSACleanup referenced in function "public: static void __cdecl Socket::cleanUp(void)" (?cleanUp@Socket@@Saxxz)
The text was updated successfully, but these errors were encountered: