visual-studiovisual-studio-2017nanomsg

Link Errors for NanoMsg with VS2017


I am trying to build a nanomsg next gen (https://github.com/nanomsg/nng) on a windows box. I am using VS2017. The CMAKE worked like a charm.

I am getting link errors. I have verifed that the nng.lib file is located at:

D:\Source\LinkWareMessageBus\nng\lib

Dumbin.exe says the symbols are all in place (and there were no compile or link errors)

that the Linker/General/Additional Library Directories is: D:\Source\LinkWareMessageBus\nng\lib

The .h files are read fine. But I am getting the following link errors:

Severity    Code    Description Project File    Line    Suppression State
Error   LNK2019 unresolved external symbol __imp__nng_setopt referenced in function "int __cdecl client(char const *,char const *)" (?client@@YAHPBD0@Z)    LinkWareMessageBus  D:\Source\LinkWareMessageBus\LinkWareMessageBus.obj 1   
Error   LNK2019 unresolved external symbol __imp__nng_listen referenced in function "int __cdecl server(char const *)" (?server@@YAHPBD@Z)  LinkWareMessageBus  D:\Source\LinkWareMessageBus\LinkWareMessageBus.obj 1   
Error   LNK2019 unresolved external symbol __imp__nng_dial referenced in function "int __cdecl client(char const *,char const *)" (?client@@YAHPBD0@Z)  LinkWareMessageBus  D:\Source\LinkWareMessageBus\LinkWareMessageBus.obj 1   
Error   LNK2019 unresolved external symbol __imp__nng_strerror referenced in function "void __cdecl fatal(char const *,int)" (?fatal@@YAXPBDH@Z)    LinkWareMessageBus  D:\Source\LinkWareMessageBus\LinkWareMessageBus.obj 1   
Error   LNK2019 unresolved external symbol __imp__nng_send referenced in function "int __cdecl server(char const *)" (?server@@YAHPBD@Z)    LinkWareMessageBus  D:\Source\LinkWareMessageBus\LinkWareMessageBus.obj 1   
Error   LNK2019 unresolved external symbol __imp__nng_recv referenced in function "int __cdecl client(char const *,char const *)" (?client@@YAHPBD0@Z)  LinkWareMessageBus  D:\Source\LinkWareMessageBus\LinkWareMessageBus.obj 1   
Error   LNK2019 unresolved external symbol __imp__nng_free referenced in function "int __cdecl client(char const *,char const *)" (?client@@YAHPBD0@Z)  LinkWareMessageBus  D:\Source\LinkWareMessageBus\LinkWareMessageBus.obj 1   
Error   LNK2019 unresolved external symbol __imp__nng_pub0_open referenced in function "int __cdecl server(char const *)" (?server@@YAHPBD@Z)   LinkWareMessageBus  D:\Source\LinkWareMessageBus\LinkWareMessageBus.obj 1   
Error   LNK2019 unresolved external symbol __imp__nng_sub0_open referenced in function "int __cdecl client(char const *,char const *)" (?client@@YAHPBD0@Z) LinkWareMessageBus  D:\Source\LinkWareMessageBus\LinkWareMessageBus.obj 1   

These are my VS2017 settings (x64 .lib and x64 project).

enter image description here

I am also attaching the dumpbin of the symbols in the nng.lib file.

What I am suspecting is that VS2017 is not configured properly to find the .lib (Other than adding the path to the linker/additional libraries ) what should I do?

nng.lib symbols


UPDATE

I no longer say this is simple. But I did get further, and maybe you can help get over the finish line. Even though I was telling VS2017 where to find the nng.lib (the path and the name). I tried also putting it in with the kernel32.lib user32.lib and the other mandatory libs.

OK. I am now no longer getting the errors about the nng_xxxx symbols. Rather it is now complaining about symbols that nng.lib is looking for.

See below:

This is the link to a verbose log of the link from VS2017: verbose link log

```

Severity    Code    Description Project File    Line    Suppression State
Error   LNK2019 unresolved external symbol __imp_WSARecvFrom referenced in function nni_win_udp_sysfini LinkWareMessageBus  D:\Source\LinkWareMessageBus\nng.lib(win_udp.c.obj) 1   
Error   LNK2019 unresolved external symbol __imp_WSACleanup referenced in function nni_plat_fini    LinkWareMessageBus  D:\Source\LinkWareMessageBus\nng.lib(win_thread.c.obj)  1   
Error   LNK2001 unresolved external symbol __imp_WSACleanup LinkWareMessageBus  D:\Source\LinkWareMessageBus\nng.lib(win_tcp.c.obj) 1   
Error   LNK2001 unresolved external symbol __imp_WSACleanup LinkWareMessageBus  D:\Source\LinkWareMessageBus\nng.lib(win_udp.c.obj) 1   
Error   LNK2019 unresolved external symbol __imp_bind referenced in function nni_win_tcp_sysfini    LinkWareMessageBus  D:\Source\LinkWareMessageBus\nng.lib(win_tcp.c.obj) 1   
Error   LNK2001 unresolved external symbol __imp_bind   LinkWareMessageBus  D:\Source\LinkWareMessageBus\nng.lib(win_udp.c.obj) 1   
Error   LNK2001 unresolved external symbol __imp_bind   LinkWareMessageBus  D:\Source\LinkWareMessageBus\nng.lib(win_pipe.c.obj)    1   
Error   LNK2019 unresolved external symbol __imp_closesocket referenced in function nni_plat_tcp_ep_init    LinkWareMessageBus  D:\Source\LinkWareMessageBus\nng.lib(win_tcp.c.obj) 1   
Error   LNK2001 unresolved external symbol __imp_closesocket    LinkWareMessageBus  D:\Source\LinkWareMessageBus\nng.lib(win_udp.c.obj) 1   
Error   LNK2001 unresolved external symbol __imp_closesocket    LinkWareMessageBus  D:\Source\LinkWareMessageBus\nng.lib(win_pipe.c.obj)    1   
Error   LNK2019 unresolved external symbol __imp_getsockname referenced in function nni_win_tcp_sysfini LinkWareMessageBus  D:\Source\LinkWareMessageBus\nng.lib(win_tcp.c.obj) 1   
Error   LNK2001 unresolved external symbol __imp_getsockname    LinkWareMessageBus  D:\Source\LinkWareMessageBus\nng.lib(win_udp.c.obj) 1   
Error   LNK2001 unresolved external symbol __imp_getsockname    LinkWareMessageBus  D:\Source\LinkWareMessageBus\nng.lib(win_pipe.c.obj)    1   
Error   LNK2019 unresolved external symbol __imp_listen referenced in function nni_win_tcp_listen   LinkWareMessageBus  D:\Source\LinkWareMessageBus\nng.lib(win_tcp.c.obj) 1   
Error   LNK2001 unresolved external symbol __imp_listen LinkWareMessageBus  D:\Source\LinkWareMessageBus\nng.lib(win_pipe.c.obj)    1   
Error   LNK2019 unresolved external symbol __imp_setsockopt referenced in function nni_plat_tcp_pipe_set_nodelay    LinkWareMessageBus  D:\Source\LinkWareMessageBus\nng.lib(win_tcp.c.obj) 1   
Error   LNK2001 unresolved external symbol __imp_setsockopt LinkWareMessageBus  D:\Source\LinkWareMessageBus\nng.lib(win_udp.c.obj) 1   
Error   LNK2001 unresolved external symbol __imp_setsockopt LinkWareMessageBus  D:\Source\LinkWareMessageBus\nng.lib(win_pipe.c.obj)    1   
Error   LNK2019 unresolved external symbol __imp_socket referenced in function nni_plat_tcp_ep_init LinkWareMessageBus  D:\Source\LinkWareMessageBus\nng.lib(win_tcp.c.obj) 1   
Error   LNK2001 unresolved external symbol __imp_socket LinkWareMessageBus  D:\Source\LinkWareMessageBus\nng.lib(win_udp.c.obj) 1   
Error   LNK2001 unresolved external symbol __imp_socket LinkWareMessageBus  D:\Source\LinkWareMessageBus\nng.lib(win_pipe.c.obj)    1   
Error   LNK2019 unresolved external symbol __imp_WSAStartup referenced in function nni_win_tcp_sysinit  LinkWareMessageBus  D:\Source\LinkWareMessageBus\nng.lib(win_tcp.c.obj) 1   
Error   LNK2001 unresolved external symbol __imp_WSAStartup LinkWareMessageBus  D:\Source\LinkWareMessageBus\nng.lib(win_udp.c.obj) 1   
Error   LNK2019 unresolved external symbol __imp_WSAGetLastError referenced in function nni_plat_tcp_pipe_set_nodelay   LinkWareMessageBus  D:\Source\LinkWareMessageBus\nng.lib(win_tcp.c.obj) 1   
Error   LNK2019 unresolved external symbol __imp_WSAIoctl referenced in function nni_plat_tcp_ep_init   LinkWareMessageBus  D:\Source\LinkWareMessageBus\nng.lib(win_tcp.c.obj) 1   
Error   LNK2019 unresolved external symbol __imp_WSARecv referenced in function nni_win_tcp_sysfini LinkWareMessageBus  D:\Source\LinkWareMessageBus\nng.lib(win_tcp.c.obj) 1   
Error   LNK2019 unresolved external symbol __imp_WSASend referenced in function nni_win_tcp_sysfini LinkWareMessageBus  D:\Source\LinkWareMessageBus\nng.lib(win_tcp.c.obj) 1   
Error   LNK2019 unresolved external symbol inet_ntop referenced in function nni_plat_tcp_ntop   LinkWareMessageBus  D:\Source\LinkWareMessageBus\nng.lib(win_tcp.c.obj) 1   
Error   LNK2019 unresolved external symbol __imp_WSASendTo referenced in function nni_win_udp_sysfini   LinkWareMessageBus  D:\Source\LinkWareMessageBus\nng.lib(win_udp.c.obj) 1   
Error   LNK2019 unresolved external symbol __imp_htons referenced in function resolv_ip LinkWareMessageBus  D:\Source\LinkWareMessageBus\nng.lib(win_resolv.c.obj)  1   
Error   LNK2019 unresolved external symbol __imp_getaddrinfo referenced in function resolv_task LinkWareMessageBus  D:\Source\LinkWareMessageBus\nng.lib(win_resolv.c.obj)  1   
Error   LNK2019 unresolved external symbol __imp_freeaddrinfo referenced in function resolv_task    LinkWareMessageBus  D:\Source\LinkWareMessageBus\nng.lib(win_resolv.c.obj)  1   
Error   LNK2019 unresolved external symbol __imp_accept referenced in function nni_plat_pipe_open   LinkWareMessageBus  D:\Source\LinkWareMessageBus\nng.lib(win_pipe.c.obj)    1   
Error   LNK2019 unresolved external symbol __imp_connect referenced in function nni_plat_pipe_open  LinkWareMessageBus  D:\Source\LinkWareMessageBus\nng.lib(win_pipe.c.obj)    1   
Error   LNK2019 unresolved external symbol __imp_ioctlsocket referenced in function nni_plat_pipe_open  LinkWareMessageBus  D:\Source\LinkWareMessageBus\nng.lib(win_pipe.c.obj)    1   
Error   LNK2019 unresolved external symbol __imp_htonl referenced in function nni_plat_pipe_open    LinkWareMessageBus  D:\Source\LinkWareMessageBus\nng.lib(win_pipe.c.obj)    1   
Error   LNK2019 unresolved external symbol __imp_recv referenced in function nni_plat_pipe_clear    LinkWareMessageBus  D:\Source\LinkWareMessageBus\nng.lib(win_pipe.c.obj)    1   
Error   LNK2019 unresolved external symbol __imp_send referenced in function nni_plat_pipe_raise    LinkWareMessageBus  D:\Source\LinkWareMessageBus\nng.lib(win_pipe.c.obj)    1   
Error   LNK1120 24 unresolved externals LinkWareMessageBus  D:\Source\LinkWareMessageBus\x64\Debug\LinkWareMessageBus.exe   1   

```


Solution

  • The symbols you’re looking for (based on the update) are Winsock functions found in ws2_32.lib.