我在Windows上面临一个奇怪的问题 我正在使用一个名为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文件并将其放在没有空格的路径中(短路径)它可以工作
如果我把它放在一个带空格的路径中...它只是崩溃,当我调试它就像内存问题(所以它崩溃了很长的路径)
当我联系图书馆创建者时,他告诉我: “windows getcwd()调用返回一个带有空格”
的不可用路径正如我之前所说的,这个库在Linux上工作正常,在Windows上可能是解决方案
系统:win7 64位
答案 0 :(得分:2)
使用二进制名称/路径的引号作为“my file.exe”