emscripten-core / emscripten-core/emscripten

Bug: when compiling executable, emcc "forgets" provided needed library

Open
#21,667 8 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
27.6k
Forks
3.6k
Avg merge
1d 1h
Merged PRs (30d)
105

Description

Reproducing:

```
// src/foo.c
#include
#include

void bar();

void foo() {
printf("Foo \n");
bar();
}
```

```
// src/bar.c
#include
#include

void bar() {
printf("Bar \n");
}
```

```
// src/main.c
void foo();

int main()
{
foo();
return 0;
}
```

Compilation:
```
emcc -o src/bar.o -c -fPIC -DPIC src/bar.c
emcc -o bar.so -sSIDE_MODULE=2 -sEXPORTED_FUNCTIONS=_bar src/bar.o

emcc -o src/foo.o -fPIC -DPIC -c src/foo.c
emcc -o foo.so src/foo.o -sEXPORTED_FUNCTIONS=_foo -sSIDE_MODULE=2 bar.so

emcc -o src/main.o -c -fPIC -DPIC src/main.c
emcc -o main src/main.o -sMAIN_MODULE -sFETCH foo.so bar.so
```

This will throw the error:
```
emcc: error: foo.so: shared library dependency not found: `bar.so`
```
Expected: The file should compile without any errors. Since bar.so is
provided.

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.