emscripten-core / emscripten-core/emscripten

Undefined symbol when compiling OpenCV's VideoCapture

Open
#14,588 1 comment 1 reaction 0 assignees View on GitHub
Dominant language
C++
Stars
27.6k
Forks
3.6k
Avg merge
1d 1h
Merged PRs (30d)
105

Description

I was trying to use OpenCV's video capture on C++ side of wsam, but compiler can't find a symbol. Minimal `video.cc` example as below

```
#include

int main() {
cv::VideoCapture("./video.mp4");
}
```

I can compile with g++ (version 12.0.5):
```
g++ -O3 `pkg-config --cflags --libs opencv4` -std=c++17 video.cc
```

But when using emcc (version 2.0.25)
```
emcc -O3 `pkg-config --cflags --libs opencv4` -std=c++17 video.cc
```

I got an error
```
error: undefined symbol: _ZN2cv12VideoCaptureC1ERKNSt3__212basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEi (referenced by top-level compiled C/C++ code)
warning: Link with `-s LLD_REPORT_UNDEFINED` to get more information on undefined symbols
warning: To disable errors for undefined symbols use `-s ERROR_ON_UNDEFINED_SYMBOLS=0`
warning: __ZN2cv12VideoCaptureC1ERKNSt3__212basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEi may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
Error: Aborting compilation due to previous errors
```

Searched over the Internet, saw a few similar questions (same undefined symbols), but couldn't find an answer.

Can anyone share some ideas about solving this issue? Really appreciate the help!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.