Вопрос

Im using Eclipse with the DDT plugin and DMD 2.06 as the compiler. When I try to to use functions like dlopen, dlsym usw I get "unresolved reference" errors, in C and GCC I fixed them by linking with -ldl, -lsdl usw... but the DMD2 compiler doesnt have options like that, is there another way to link with specific libraries?

btw I define the C functions the following way

    extern(C)
    {
        /* From <dlfcn.h>
        *  See http://www.opengroup.org/onlinepubs/007908799/xsh/dlsym.html
        */

        const int RTLD_NOW = 2;

        void *dlopen(const(char)* file, int mode);
        int dlclose(void* handle);
        void *dlsym(void* handle, const(char*) name);
        const(char)* dlerror();
    }

would be happy about any help.

Это было полезно?

Решение

Just pass -L-ldl.

Also, you don't need to redefine all of these. They are available in the core.sys.posix.dlfcn module.

Другие советы

D does have link pragmas:

pragma(lib, "dl");

which will cause DMD to emit "-L-ldl" (or the system-appropriate link flag) to the linker. If the linker is order-sensitive (as ld is), you need to specify the pragmas in the order which you manually pass them.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top