awslabs / amazon-kinesis-video-streams-webrtc-sdk-c

Amazon Kinesis Video Streams Webrtc SDK is for developers to install and customize realtime communication between devices and enable secure streaming of video, audio to Kinesis Video Streams.
https://awslabs.github.io/amazon-kinesis-video-streams-webrtc-sdk-c/group__PublicMemberFunctions.html
Apache License 2.0
1.01k stars 304 forks source link

[BUG] Cant statically build the project #1096

Closed ecruzolivera closed 3 years ago

ecruzolivera commented 3 years ago

Describe the bug I cant statically build the project, for what i can see i says that cant link against libcap, but in have libcap-dev installed, im under PopOs 20.04 (Ubuntu 20.04)

 apt search libcap-dev
Sorting... Done
Full Text Search... Done
libcap-dev/focal,now 1:2.32-1 amd64 [installed]
  POSIX 1003.1e capabilities (development)

SDK version number version: commit f5b89d4b6e6116a06f0bd2580967142e98ce6f70 (HEAD -> master, origin/master, origin/HEAD)

Open source building Error when libwebsockets links against libcap

make    
[ 67%] Built target kvsWebrtcClient
[ 70%] Built target discoverNatBehavior
[ 83%] Built target kvsWebrtcSignalingClient
[ 85%] Linking C executable kvsWebrtcClientViewer
/usr/bin/ld:  <REDACTED>/aws-kvs/amazon-kinesis-video-streams-webrtc-sdk-c/open-source/lib/libwebsockets.a(unix-caps.c.o): in function `lws_plat_drop_app_privileges':
unix-caps.c:(.text+0x23e): undefined reference to `cap_get_proc'
/usr/bin/ld: unix-caps.c:(.text+0x25a): undefined reference to `cap_set_flag'
/usr/bin/ld: unix-caps.c:(.text+0x262): undefined reference to `cap_set_proc'
/usr/bin/ld: unix-caps.c:(.text+0x282): undefined reference to `cap_free'
/usr/bin/ld: unix-caps.c:(.text+0x2d8): undefined reference to `cap_get_proc'
/usr/bin/ld: unix-caps.c:(.text+0x2f1): undefined reference to `cap_set_flag'
/usr/bin/ld: unix-caps.c:(.text+0x2f9): undefined reference to `cap_set_proc'
/usr/bin/ld: unix-caps.c:(.text+0x319): undefined reference to `cap_free'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/kvsWebrtcClientViewer.dir/build.make:105: kvsWebrtcClientViewer] Error 1
make[1]: *** [CMakeFiles/Makefile2:114: CMakeFiles/kvsWebrtcClientViewer.dir/all] Error 2
make: *** [Makefile:130: all] Error 2

To Reproduce Steps to reproduce the behavior:

cmake .. -DBUILD_STATIC_LIBS=TRUE
make

Expected behavior Statically build successfully

disa6302 commented 3 years ago

Looks like a linking issue and not sure why that is the case. Can you try re-installing libcap-dev?

hassanctech commented 3 years ago

@ecruzolivera I just spun up a fresh Ubuntu 20.04 EC2 instance, ran a few commands like: sudo apt-get install pkg-config cmake build-essential libssl-dev libcurl4-openssl-dev

And then I followed the README steps exactly, create build dir, and I ran the same command:

cmake -DBUILD_STATIC_LIBS=TRUE ../
make

And I had no issues I was able to build it no problems. I'm not sure if this issue is as @disa6302 mentioned due to a bad libcap-dev installation, I never had to directly install that. Maybe try with Ubuntu 20.04 not sure if this could be due to subtle differences in PopOS, that might help narrow down the problem.

I'm removing the bug label since I'm not able to repro this on a fresh Ubuntu 20.04 machine.

ecruzolivera commented 3 years ago

Hi @disa6302 @hassanctech i sudo apt install --reinstall libcap-dev and was able to static compile the library, thanks for the help.

hassanctech commented 3 years ago

Great! It you have further troubles feel free to open a new Issue.