c++ - "cannot open output file filename.exe: Permission denied" -
i have learned c++ , trying make program using windows.h header. using dev-c++ compiler , getting 3 errors can't find solution to.
these errors:
cannot open output file filename.exe: permission denied
[error] ld returned 1 exit status recipe target 'filename.exe' failed
here code:
#include <windows.h&$62 #include <iostream> #include <fstream> #include <string> #include <vector> using namespace std; hwnd textfield; /* input window goes */ lresult callback wndproc(hwnd hwnd, uint message, wparam wparam, lparam lparam) { switch(message) { case wm_create: createwindow("static", "docjoin document combiner", ws_visible | ws_child | ws_border, 20,20,300,25, hwnd,null,null,null); break; /* upon destruction, tell main thread stop */ case wm_destroy: { postquitmessage(0); break; } /* other messages (a lot of them) processed using default procedures */ default: return defwindowproc(hwnd, message, wparam, lparam); } return 0; } /* 'main' function of win32 gui programs: execution starts */ int winapi winmain(hinstance hinstance, hinstance hprevinstance, lpstr lpcmdline, int ncmdshow) { wndclassex wc; /* properties struct of our window */ hwnd hwnd; /* 'handle', hence h, or pointer our window */ msg msg; /* temporary location messages */ /* 0 out struct , set stuff want modify */ memset(&wc,0,sizeof(wc)); wc.cbsize = sizeof(wndclassex); wc.lpfnwndproc = wndproc; /* send messages */ wc.hinstance = hinstance; wc.hcursor = loadcursor(null, idc_arrow); /* white, color_window #define system color, try ctrl+clicking */ wc.hbrbackground = (hbrush)(color_window+1); wc.lpszclassname = "windowclass"; wc.hicon = loadicon(null, idi_application); /* load standard icon */ wc.hiconsm = loadicon(null, idi_application); /* use name "a" use project icon */ if(!registerclassex(&wc)) { messagebox(null, "window registration failed!","error!",mb_iconexclamation|mb_ok); return 0; } hwnd = createwindowex(ws_ex_clientedge,"windowclass","docjoin",ws_visible|ws_overlappedwindow, cw_usedefault, /* x */ cw_usedefault, /* y */ 683, /* width */ 730, /* height */ null,null,hinstance,null); if(hwnd == null) { messagebox(null, "window creation failed!","error!",mb_iconexclamation|mb_ok); return 0; } /* heart of our program input processed , sent wndproc. note getmessage blocks code flow until receives something, loop not produce unreasonably high cpu usage */ while(getmessage(&msg, null, 0, 0) > 0) { /* if no error received... */ translatemessage(&msg); /* translate key codes chars if present */ dispatchmessage(&msg); /* send wndproc */ } return msg.wparam;
}
and here makefile.win:
# project: projectname
# makefile created dev-c++ 5.6.3
cpp = g++.exe cc = gcc.exe windres = windres.exe obj = main.o linkobj = main.o libs = -l"[...]" -l"[...]" -static-libgcc -mwindows -g3 incs = -i"[...]" -i"[...]" -i"[...]" cxxincs = -i"[..]" -i"[...]" -i"[...]" -i"[...]" bin = filename.exe cxxflags = $(cxxincs) -g3 cflags = $(incs) -g3 rm = rm.exe -f .phony: all-before all-after clean clean-custom all: all-before $(bin) all-after clean: clean-custom ${rm} $(obj) $(bin) $(bin): $(obj) $(cpp) $(linkobj) -o $(bin) $(libs) main.o: main.cpp $(cpp) -c main.cpp -o main.o $(cxxflags)
i spent 3 hours doing research , troubleshooting , stumped. first time using c++ compiler, meaning first program.
you have change file location.
note: not save file in program files
& program files (x86)
in microsoft windows.
you can use path example c:\user\.....
Comments
Post a Comment