c2lang / c2compiler

the c2 programming language
c2lang.org
Apache License 2.0
704 stars 49 forks source link

Missing "-ldl" in bootstrap/Makefile #125

Closed mingodad closed 2 months ago

mingodad commented 2 months ago

When trying to build this project on Ubuntu 18.04 I'm getting this error:

bootstrap-c2c.sh
setting C2 environment
make: Entering directory 'c2compiler/bootstrap'
---- compiling bootstrap compiler ----
/tmp/ccuOreRQ.o: In function `plugin_mgr_Mgr_free':
c2compiler/bootstrap/bootstrap.c:30747: undefined reference to `dlclose'
/tmp/ccuOreRQ.o: In function `plugin_mgr_Mgr_loadPlugin':
c2compiler/bootstrap/bootstrap.c:30833: undefined reference to `dlopen'
c2compiler/bootstrap/bootstrap.c:30835: undefined reference to `dlerror'
c2compiler/bootstrap/bootstrap.c:30838: undefined reference to `dlsym'
c2compiler/bootstrap/bootstrap.c:30840: undefined reference to `dlerror'
c2compiler/bootstrap/bootstrap.c:30841: undefined reference to `dlclose'
c2compiler/bootstrap/bootstrap.c:30848: undefined reference to `dlclose'
collect2: error: ld returned 1 exit status
Makefile:10: recipe for target 'c2c_bootstrap' failed
make: *** [c2c_bootstrap] Error 1
make: Leaving directory 'c2compiler/bootstrap'

But after adding -ldl to bootstrap/Makefile the it build fine:

diff --git a/bootstrap/Makefile b/bootstrap/Makefile
index d7b7d5ec..5ade415a 100644
--- a/bootstrap/Makefile
+++ b/bootstrap/Makefile
@@ -8,7 +8,7 @@ all: ../output/c2c/c2c

 c2c_bootstrap: bootstrap.c external.h
                @echo "---- compiling bootstrap compiler ----"
-               @$(CC) $(CFLAGS) bootstrap.c -o c2c_bootstrap
+               @$(CC) $(CFLAGS) bootstrap.c -o c2c_bootstrap -ldl

 ../output/c2c/c2c: c2c_bootstrap
                @echo "---- running (bootstrapped) c2c ----"
bvdberg commented 2 months ago

Weird that it builds without that flag on my system...fixed. Thx!