Hi all,
I am trying to use llvm-gcc to link shared libraries on windows/mingw32.
When I try to link libraries that contain functions declared with
__declspec(dllexport) someFunction();
I get the link error:
Cannot export _someFunction: symbol not found
Removing the declspec directive solves the problem, but this is not a
very feasible solution for me.
Using 'regular' gcc does not have this problem.
Should I consider this a bug?
Thanks,
Ronald
I am trying to use llvm-gcc to link shared libraries on windows/mingw32.
When I try to link libraries that contain functions declared with
__declspec(dllexport) someFunction();
I get the link error:
Cannot export _someFunction: symbol not found
dllexport declspec should be put on the function definition, in this
example there is nothing to export - dllexport without function body
is meaningless.
Anton Korobeynikov <anton@korobeynikov.info> writes:
I am trying to use llvm-gcc to link shared libraries on windows/mingw32.
When I try to link libraries that contain functions declared with
__declspec(dllexport) someFunction();
I get the link error:
Cannot export _someFunction: symbol not found
dllexport declspec should be put on the function definition, in this
example there is nothing to export - dllexport without function body
is meaningless.
This is not correct.
The compiler remembers the dllexport declspec and when it finds the
definition, it applies it.
It works on MSVC++ and MinGW's gcc.
> I am trying to use llvm-gcc to link shared libraries on windows/mingw32.
> When I try to link libraries that contain functions declared with
> __declspec(dllexport) someFunction();
>
> I get the link error:
>
> Cannot export _someFunction: symbol not found
dllexport declspec should be put on the function definition, in this
example there is nothing to export - dllexport without function body
is meaningless.
Ok, you're right.
The declaration is actually there in the function definition.
Sorry to provide a broken example.
Here is a more acurate one:
--- function.c
__declspec(dllexport) someFunction()
{
printf("Hi\n");
}
$ llvm-gcc -shared -o libfunction.dll function.c
Cannot export _someFunction: symbol not found
collect2: ld returned 1 exit status
Right, this is a bug introduced recently - we need to emit linker
directive with unmangled, but decorated name...