Ronald Pijnacker
2009-Oct-11 20:34 UTC
[LLVMdev] Problems linking shared library with __declspec(dllexport)
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
Anton Korobeynikov
2009-Oct-11 21:21 UTC
[LLVMdev] Problems linking shared library with __declspec(dllexport)
> 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 founddllexport declspec should be put on the function definition, in this example there is nothing to export - dllexport without function body is meaningless. -- With best regards, Anton Korobeynikov Faculty of Mathematics and Mechanics, Saint Petersburg State University
Óscar Fuentes
2009-Oct-11 21:42 UTC
[LLVMdev] Problems linking shared library with __declspec(dllexport)
Anton Korobeynikov <anton at 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. -- Óscar
Ronald Pijnacker
2009-Oct-12 06:47 UTC
[LLVMdev] Problems linking shared library with __declspec(dllexport)
> > 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"); } --- Compiling this gives: $ llvm-gcc -shared -o libfunction.dll function.c Cannot export _someFunction: symbol not found collect2: ld returned 1 exit status Thanks, Ronald
Reasonably Related Threads
- [LLVMdev] Problems linking shared library with __declspec(dllexport)
- [LLVMdev] Problems linking shared library with __declspec(dllexport)
- [LLVMdev] Feedback required on proper dllexport/import implementation
- [LLVMdev] Feedback required on proper dllexport/import implementation
- [LLVMdev] Feedback required on proper dllexport/import implementation