ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
I am experimenting with putting lua (5.1) into cpp and have come across a problem. When I try to load the lualibs I get linker errors. I am using my own makescript (my first so might be the problem). Have also tryed running it with "make LDFLAGS+=-ldl" and I get the same result. Would like some help if anyone know how to fix this. Thanks in advance.
The error:
jakob@jakob-laptop:~/Skrivebord/test projekt$ make
gcc -c Inventory.cpp
gcc -c Printer.cpp
gcc -c Computer.cpp
gcc -c Keyboard.cpp
gcc -c main.cpp
g++ -o main main.o Inventory.o \
Printer.o Computer.o Keyboard.o -llua
/usr/local/lib/liblua.a(loadlib.o): In function `ll_loadfunc':
loadlib.c:(.text+0xa31): undefined reference to `dlsym'
loadlib.c:(.text+0xa7c): undefined reference to `dlopen'
loadlib.c:(.text+0xa89): undefined reference to `dlerror'
loadlib.c:(.text+0xaa1): undefined reference to `dlerror'
/usr/local/lib/liblua.a(loadlib.o): In function `gctm':
loadlib.c:(.text+0x109e): undefined reference to `dlclose'
collect2: ld returned 1 exit status
make: *** [build] Error 1
Your Makefile doesn't try to handle LDFLAGS= parameter. So your "-ldl" is ignored. You can simply add it to "g++ -o main main.o Inventory.o Printer.o Computer.o Keyboard.o -llua" (to get "g++ -o main main.o Inventory.o Printer.o Computer.o Keyboard.o -llua -ldl").
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.