tags:

views:

587

answers:

2

I am trying to write a C program that uses dlysm, and I keep getting an undefined deference to dlysm. I think I need to set my -ldl flags but I have no idea how to do this. I am very new to linux and setting variables. If this is what I need to do can someone help me out with the commands?

+1  A: 

Pass -ldl as a param to the compiler.

Example:

gcc myprog.c -o app -ldl
Kknd
+1  A: 

-l library options are used at link time.

If you compile just one source file (gcc -o program program.c), then you both compile and link in one go. Just add the -ldl.

If you compile multiple object (*.o) files, and then link them together, specify the -ldl option to the linker (ld).

See also man ld and man cc

gnud
I get this error user@ubuntu8041:~$ gcc -Wall -g -o mymalloc mymalloc.c -ldl/usr/lib/gcc/i486-linux-gnu/4.2.4/../../../../lib/crt1.o: In function `_start':(.text+0x18): undefined reference to `main'collect2: ld returned 1 exit status
This says that you didn't define a main() function; the runtime library requires a main to run your program.
Ben Combee