2013-04-26 56 views
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位

+1

显示代码如何将这些字符串传递给相关函数? – deepmax 2013-04-26 22:34:38

+0

如果可能,请勿重新发明轮子,请使用boost文件系统! – 2013-04-26 22:35:48

+0

或者使用['GetShortPathName()'](http://msdn.microsoft.com/en-us/library/windows/desktop/aa364989.aspx)。 – 2013-04-26 22:41:26

回答

2

使用quates为二进制名称/路径为“我的file.exe “