dllexport/dllimport requires external linkage

The cuda code compiles the cuda project and reports an error:

dllexport/dllimport requires external linkage

header

extern C LIB_EXPORTS_API void _cdecl func()

source

static void func()

At this time, func will report dllexport/dllimport requires external linkage error, and only the dll file is finally generated, but no lib file.
solution:

Remove the static keyword before the function declaration in source.
reference: https://stackoverflow.com/questions/9458595/export-function-to-dll-without-class

Original link: https://blog.csdn.net/u014786409/article/details/123566464

The following is reproduced from:

export function to DLL without class - Programmer Sought

Is there a way to export just one function to the DLL cos in the tutorial they always export the class stuff,

  1. static __declspec(dllexport) double Add(double a,double b);

In the above class, the above statement does not cause any problems, but no class ti gives

  1. dllexport/dllimport requires external linkage

Solution

The problem is the "static" qualifier. You need to remove it because it means false in this context . Try just:

  1. __declspec(dllexport) double Add(double a,double b);

This is what you need in your header file when compiling the DLL . Now to access the function from a program that uses the DLL , you need to have a header file :

  1. double Add(double a,double b);

If you use #ifdefs, you can use the same header file for both purposes :

  1. #ifndef MYDLL_EXPORT
  2. #define MYDLL_EXPORT
  3. #endif
  4. MYDLL_EXPORT double Add(double a,double b);

Summarize

The above is the whole content of c-export function to DLL without class , which is collected for you by the programming house . I hope this article can help you solve the program development problem encountered by c-export function to DLL without class .

If you think the content of the programming home website is not bad, you are welcome to recommend the programming home website to your programmer friends.

Guess you like

Origin blog.csdn.net/jacke121/article/details/127356112