Linker problems: cannot find 'dlsym' 'dlopen' 'dlerror' 'dlclose'
Hi everyone
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
Makefile:
build:
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
clean:
rm -rf *.o
rm -rf *~
rm -rf *.gch
rm -f main
main.cpp:
#include "Inventory.h"
#include "Stock.h"
#include "Printer.h"
#include "Computer.h"
#include "Keyboard.h"
#include <iostream>
using namespace std;
//experiment
extern "C"
{
#include "lua.h"
#include "lualib.h"
#include "lauxlib.h"
}
int main(int argc, char** argv) {
for ( int n = 1; n<argc; ++n ) {
const char* file = argv[n];
lua_State *L = lua_open();
luaL_openlibs(L);
cout << "-- Loading file: " << file << endl;
lua_close(L);
cout << endl;
}
}
Last edited by Jarrax; 04-19-2009 at 09:31 AM.
|