HI I am trying to make a dll file that performs its tasks using CUDA library.

Here is a simple version of my code:


#include <iostream>
#include "cuda.h"
#include "cuda_runtime.h"
#include "device_launch_parameters.h"

__global__ void test(int a, int b, int* c)
    *c = a+b;

extern "C" __declspec(dllexport) int sumTEst(int a, int b)
    int c = 0;
    test<<<1,1>>>(a, b, &c);
    return c;
Inline Code Example Here


When I compile this file, there is no problem. But when I build the project which has only file above, an error occurs:

Error   1   error LNK1561: entry point must be defined  C:\svnprojects\IMLibCUDADll\IMLibCUDADll\LINK   IMLibCUDADll

What am I doing wrong? Has anyone done making dll's using GPU?
Thanks in advance..


Recommended Answers

All 2 Replies

A DLL is made for windows.. It is going to require you to specify a main..

int main() for consoles
WinMain for Win32-GUI
DLLMain for DLL's

int WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
        case DLL_PROCESS_ATTACH:

        case DLL_PROCESS_DETACH:
    return true;


you should enclose your file with include guards and attach a macro like this:

(as describe in this page)

#if defined(DLL_PROJECT)

 #define DLLAPI __declspec(dllexport)


 #define DLLAPI __declspec(dllimport)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.