Undefined references with -lcuda -lcudart on Windows

Hi I’m compiling on Windows 10 and is just starting out.
I have been trying to just get something to compile for hours already and no success thus far.
The newest error is loads of undefined references with the flags -lcuda -lcudart
I am obviously missing some library but I don’t really know what.
Any help is appreciated, I’m dying here.

Code (filename=test1.cu)

__global__ void foo(){}

int main()
{
    foo<<<1, 1>>>();
}

Makefile

CC = g++
ALLFLAGS = -L E:\cuda\development\lib\x64 -lcuda -lcudart
CUDAFLAGS = -arch=sm_20

EXEC = program
CUDASOURCES = $(wildcard *.cu)
CUDAOBJECTS = $(CUDASOURCES:.cu=.o)

all: $(CUDAOBJECTS)
        $(CC) $(ALLFLAGS) $(CUDAOBJECTS) -o $(EXEC)

$(CUDAOBJECTS): %.o: %.cu
        nvcc -c $(CUDAFLAGS) $< -o $@

Terminal output

nvcc -c -arch=sm_20 test1.cu -o test1.o
g++ -L E:\cuda\development\lib\x64 -lcuda -lcudart  test1.o -o program
Warning: corrupt .drectve at end of def file
test1.o:(.text$mn+0xf6): undefined reference to `cudaConfigureCall'
test1.o:(.text$mn+0x158): undefined reference to `__cudaUnregisterFatBinary'
test1.o:(.text$mn+0x20f): undefined reference to `__cudaRegisterFunction'
test1.o:(.text$mn+0x22c): undefined reference to `__cudaRegisterFatBinary'
test1.o:(.text$mn+0x27f): undefined reference to `cudaLaunch'
collect2.exe: error: ld returned 1 exit status
makefile:19: recipe for target 'all' failed
mingw32-make: *** [all] Error 1

You shouldn’t use g++ on windows with CUDA

It’s recommended to use cl.exe

g++ is not an officially supported host compiler/toolchain for CUDA on windows. This is covered in the installation guide for CUDA on windows

Ok will try it out, thx

EDIT: excellent advice, but you forgot to say I might want to shoot myself in the head before I start using cl to spare me the pain

EDIT2: I am quitting by the sheer idiocy of how cl works. By following MSDN word by word, it successfully screwed me over and wasted a couple of hours of my life. I believe it is a criminal offense to not warn me that cl is more carcinogenic than a nuclear bomb going off in your face.

How so? I was playing with Windows stuff yesterday and I was able to get a dummy test file with Thrust working. Granted, I wasn’t trying to link against the device runtime or any such thing.

You didn’t say where or how the build failed for you. The following seems to work just fine on my machine:

nvcc -c -arch=sm_20 -o test1.obj test1.cu
cl test1.obj /Feprogram.exe /link /LIBPATH:"c:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v7.5\lib\x64" cudart.lib cuda.lib