0
我在窗口上面臨一個奇怪的問題我正在使用一個名爲STDCL的庫,它在Linux上運行得很好,但在Windows上如果輸出有錯誤。 exe文件的路徑得到了「空間」從窗口上的「空間」的文件路徑訪問數據
例如:
c:\my file\my file.exe //won't work
c:\my_file\my file.exe //will work
c:\my file\my file.exe //won't work
// and it is accessing data from dll(any where) containing STDCL library
c:\my_file\my file.exe //will work
// and it is accessing data from dll(any where) containing STDCL library
我得到的源代碼,編譯庫 或有更簡單的方法來強制接受我的.dll
裏面的.exe文件的路徑編輯:樣本代碼
/* hello_stdcl.c */
#include <stdio.h>
#include <stdcl.h>
int main()
{
stdcl_init(); // this is only necessary for Windows
cl_uint n = 64;
#if(1)
/* use default contexts, if no GPU use CPU */
CLCONTEXT* cp = (stdgpu)? stdgpu : stdcpu;
unsigned int devnum = 0;
void* clh = clopen(cp,"matvecmult.cl",CLLD_NOW);
cl_kernel krn = clsym(cp,clh,"matvecmult_kern",0);
/* allocate OpenCL device-sharable memory */
cl_float* aa = (float*)clmalloc(cp,n*n*sizeof(cl_float),0);
cl_float* b = (float*)clmalloc(cp,n*sizeof(cl_float),0);
cl_float* c = (float*)clmalloc(cp,n*sizeof(cl_float),0);
clndrange_t ndr = clndrange_init1d(0, n, 64);
/* initialize vectors a[] and b[], zero c[] */
int i,j;
for(i=0;i<n;i++) for(j=0;j<n;j++) aa[i*n+j] = 1.1f*i*j;
for(i=0;i<n;i++) b[i] = 2.2f*i;
for(i=0;i<n;i++) c[i] = 0.0f;
/* define the computational domain and workgroup size */
//clndrange_t ndr = clndrange_init1d(0, n, 64);
/* non-blocking sync vectors a and b to device memory (copy to GPU)*/
clmsync(cp,devnum,aa,CL_MEM_DEVICE|CL_EVENT_NOWAIT);
clmsync(cp,devnum,b,CL_MEM_DEVICE|CL_EVENT_NOWAIT);
/* set the kernel arguments */
clarg_set(cp,krn,0,n);
clarg_set_global(cp,krn,1,aa);
clarg_set_global(cp,krn,2,b);
clarg_set_global(cp,krn,3,c);
/* non-blocking fork of the OpenCL kernel to execute on the GPU */
clfork(cp,devnum,krn,&ndr,CL_EVENT_NOWAIT);
/* non-blocking sync vector c to host memory (copy back to host) */
clmsync(cp,0,c,CL_MEM_HOST|CL_EVENT_NOWAIT);
/* force execution of operations in command queue (non-blocking call) */
clflush(cp,devnum,0);
/* block on completion of operations in command queue */
clwait(cp,devnum,CL_ALL_EVENT);
for(i=0;i<n;i++) printf("%d %f %f\n",i,b[i],c[i]);
clfree(aa);
clfree(b);
clfree(c);
clclose(cp,clh);
#endif
system("pause");
}
編輯2:
當我編譯上面的代碼......拍攝效果.exe文件,並把它放在一個路徑沒有空格(短路徑),它的工作原理
如果我把它在一個空間的路徑...它只是崩潰,當我調試它像內存問題(所以它與長途徑崩潰)
當我聯繫圖書館的創造者,他告訴我:「窗口getcwd()調用返回空間不可用的路徑「
,因爲我之前說這個庫可以在Linux很好,什麼可能是這種解決方案在Windows
系統:WIN7 64位
顯示代碼如何將這些字符串傳遞給相關函數? – deepmax 2013-04-26 22:34:38
如果可能,請勿重新發明輪子,請使用boost文件系統! – 2013-04-26 22:35:48
或者使用['GetShortPathName()'](http://msdn.microsoft.com/en-us/library/windows/desktop/aa364989.aspx)。 – 2013-04-26 22:41:26