amazon-kinesis-video-streams-webrtc-sdk-c icon indicating copy to clipboard operation
amazon-kinesis-video-streams-webrtc-sdk-c copied to clipboard

[QUESTION] Got build errors "LNK2019: unresolved external symbol" on Windows10 and VS2019

Open nshinya opened this issue 4 years ago • 11 comments

I could not build this SDK on Windows10 due to the error described below.

I think this error is related not to KVS C SDK but libwebsockets and pthreads. But I could not find any crew to solve this error from issues of both KVS C SDK/libwebsockets repositories. How can I solve the error? What prerequisite is short?

I prepared environments referring to README of this SDK and https://libwebsockets.org/git/libwebsockets/tree/READMEs/README.build-windows.md .

I got pthreads modules from http://mirrors.kernel.org/sourceware/pthreads-win32/, chose pthreads-w32-2-9-1-release.zip .

I'm using Visual Studio 2019 Community. I'm running build commands in X64 Native Tools Command Prompt for VS 2019.

build commands I tried are as below (both had same errors): cmake .. -DLWS_HAVE_PTHREAD_H=1 -DLWS_EXT_PTHREAD_INCLUDE_DIR="C:\Program Files (x86)\pthreads\include" -DLWS_EXT_PTHREAD_LIBRARIES="C:\Program Files (x86)\pthreads\lib\x64\libpthreadGC2.a" -DLWS_WITH_MINIMAL_EXAMPLES=1

cmake -G "NMake Makefiles" .. -DLWS_HAVE_PTHREAD_H=1 -DLWS_EXT_PTHREAD_INCLUDE_DIR="C:\Program Files (x86)\pthreads\include" -DLWS_EXT_PTHREAD_LIBRARIES="C:\Program Files (x86)\pthreads\lib\x64\libpthreadGC2.a" -DLWS_WITH_MINIMAL_EXAMPLES=1

** Logging **

I got an error as below.

Creating library websockets.lib and object websockets.exp
close.c.obj : error LNK2019: unresolved external symbol lws_threadpool_wsi_closing referenced in function __lws_close_free_wsi
ops-pipe.c.obj : error LNK2019: unresolved external symbol lws_threadpool_tsi_context referenced in function rops_handle_POLLIN_pipe
..\bin\websockets.dll : fatal error LNK1120: 2 unresolved externals

** Any design considerations/constraints **

I know who wants to use this SDK on Windows10, so I tried to build this SDK on Windows10.

nshinya avatar Oct 05 '21 00:10 nshinya

It looks like this issue has not been active for a long time. If the issue is not resolved, please add an update to the ticket, else it will be automatically resolved in a few days.

github-actions[bot] avatar Oct 13 '21 00:10 github-actions[bot]

It looks build for Windows is tested on CI process, but it marked "This job is allowed to fail". https://app.travis-ci.com/github/awslabs/amazon-kinesis-video-streams-webrtc-sdk-c/jobs/537324170

KVS team, Do you expect fail in Windows build? Is Windows not supported on this SDK?

yuma-m avatar Oct 13 '21 03:10 yuma-m

@nshinya , Can you see if libwebsockets builds standalone on Windows?

@yuma-m , We still do support Windows. The reason we have allowed it to fail on Travis CI is due to the inability to install pthread on the Windows instance travis uses. The build for 1.6.0 was tested manually and the process to build for Windows was updated in the README to allow customers to use our SDK with Windows.

disa6302 avatar Oct 13 '21 17:10 disa6302

@disa6302 Thank you for your reply.

I tried to build libwebsockets standalone on Windows10/VS2019 following this document. I ran following command as described in README, cmake .. -DLWS_HAVE_PTHREAD_H=1 -DLWS_EXT_PTHREAD_INCLUDE_DIR="C:\Program Files (x86)\pthreads\include" -DLWS_EXT_PTHREAD_LIBRARIES="C:\Program Files (x86)\pthreads\lib\x64\libpthreadGC2.a" -DLWS_WITH_MINIMAL_EXAMPLES=1, and I got a different error when I ran the command cmake --build . —config DEBUG.

error C2079: 'ctx' uses undefined struct 'hmac_ctx_st'

I found a related GitHub issue, but it did not work for me.

Didn't you get the same error when you test building libwebsockets manually on Windows? If not, could you elaborate on how you are testing the build on Windows?

nshinya avatar Oct 18 '21 15:10 nshinya

I'm getting the same issues as @nshinya, exact same LNK2019 errors popping up, and Libwebsockets is building standalone on Windows10/VS2019, however I didn't get the following error message.

error C2079: 'ctx' uses undefined struct 'hmac_ctx_st'

The only errors I have been getting are the aforementioned LNK2019 errors, listed below.

close.obj : error LNK2019: unresolved external symbol lws_threadpool_wsi_closing referenced in function __lws_close_free_wsi

ops-pipe.obj : error LNK2019: unresolved external symbol lws_threadpool_tsi_context referenced in function rops_handle_POLLIN_pipe

What can we do to resolve these errors?

TristynTorriani avatar Oct 19 '21 18:10 TristynTorriani

@TristynTorriani ,

We need time to look into it and see if we can reproduce this on Windows. Moving to pending research. Also, just to confirm, what version of the SDK are you using?

@nshinya , can you also add information on the SDK version you are using?

disa6302 avatar Oct 19 '21 18:10 disa6302

@disa6302 Thank you for researching this issue. On my environment, SDK versions information is as follows:

About KVS C SDK build,

  • KVS C SDK: v1.6.0
  • dependencies: pthreads-w32-2-9-1-release.zip

About libwebsockets standalone build test,

  • libwebsockets: github commit id=5757c82ed7e70a67ead26a058f0413b89f34b745
  • openssl: github commit id=d5d95daba59adc41ab60ea86acd513f255fca3c0

OS: Windows 10 20H2 19042.1288 VisualStudio: 2019 16.11.2

nshinya avatar Oct 21 '21 07:10 nshinya

@nshinya @TristynTorriani did you solve it, I'm trying to build it in windows too and I have the same error:

close.obj : error LNK2019: unresolved external symbol lws_threadpool_wsi_closing referenced in function __lws_close_free_wsi

pablocordova avatar Jan 20 '22 19:01 pablocordova

@nshinya @TristynTorriani I also see this same problem on 1.7.2. When linking with prebuilt binaries instead, I have further issues (have posted a question here)

vulkan101 avatar Apr 07 '22 17:04 vulkan101

Has there been any change regarding this issue? I am seeing the same build error with my kinesis SDK configuration on Win64 VS2017 setup. Modified my bat file as:

call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Auxiliary\Build\vcvars64.bat" mkdir build cd build cmd.exe /c cmake -G "NMake Makefiles" .. cmake -G "NMake Makefiles" -DBUILD_TEST=TRUE -DOPENSSL_ROOT_DIR="E:/vcpkg/installed/x64-windows" -DLWS_HAVE_PTHREAD_H=1 -DLWS_EXT_PTHREAD_INCLUDE_DIR="C:\pthread\include" -DLWS_EXT_PTHREAD_LIBRARIES="C:\pthread\lib\x64\pthreadVC2.lib" -DLWS_WITH_MINIMAL_EXAMPLES=1 .. nmake

and receiving the errors: close.c.obj : error LNK2019: unresolved external symbol lws_threadpool_wsi_closing referenced in function __lws_close_free_wsi ops-pipe.c.obj : error LNK2019: unresolved external symbol lws_threadpool_tsi_context referenced in function rops_handle_POLLIN_pipe ..\bin\websockets.dll : fatal error LNK1120: 2 unresolved externals

mehmetcy84 avatar Jun 30 '22 10:06 mehmetcy84

Setting -DLWS_WITH_THREADPOOL=0 (changed from 1 to 0) in .\amazon-kinesis-video-streams-webrtc-sdk-c\CMake\Dependencies\libwebsockets-CMakeLists.txt and attempting again, the build succeeded. Though I am not sure at what cost I managed to build the SDK by disabling the threadpool.

mehmetcy84 avatar Jun 30 '22 14:06 mehmetcy84

Are there any news regarding this issue?

mehmetcy84 avatar Dec 02 '22 15:12 mehmetcy84

Hi, this build has been fixed in the CI. You may have to install gstreamer and strawberryperl to use it. You can refer to the steps for a clean build in the develop's ci.yml

niyatim23 avatar Jul 28 '23 18:07 niyatim23