!呜呼啦呼! 2022-12-08 11:03 采纳率: 85.7%
浏览 67
已结题

无法定位程序输入点 于动态链接库opencv_highgui2412d.dll

最近在学习CUDA,我是在windows系统下的visual stdio2019下运行的cuda by example一书中的程序示例遇到的问题,安装的opencv2.4.12,按照一般配置步骤配置好后,执行程序出现以下报错,查看报错的“无法定位程序输入点 于动态链接库opencv_highgui2412d.dll”,该dll我文件在目录下,之前配置的时候环境变量也加了,不知道在路径加进去、文件也有的情况下,为啥会出现这种情况,不管我把这个文件复制到那个路径下,执行都会报这个错。有遇到过同样问题的前辈可以指点一下嘛~

img


opencv环境变量配置好了:

img


Visual stdio2019内的库目录配置,附加依赖项名字也都加进去了:

img

img

程序代码:(就是cuda by example书中第六章例子)

/*
 * Copyright 1993-2010 NVIDIA Corporation.  All rights reserved.
 *
 * NVIDIA Corporation and its licensors retain all intellectual property and
 * proprietary rights in and to this software and related documentation.
 * Any use, reproduction, disclosure, or distribution of this software
 * and related documentation without an express license agreement from
 * NVIDIA Corporation is strictly prohibited.
 *
 * Please refer to the applicable NVIDIA end user license agreement (EULA)
 * associated with this source code for terms and conditions that govern
 * your use of this NVIDIA software.
 *
 */


#include "cuda.h"
#include "D:/exercise/cuda_demo/common/book.h"
#include "D:/exercise/cuda_demo/common/image.h"

#define DIM 1024
#define PI 3.1415926535897932f
#define MAX_TEMP 1.0f
#define MIN_TEMP 0.0001f
#define SPEED   0.25f

 // these exist on the GPU side
texture<float>  texConstSrc;
texture<float>  texIn;
texture<float>  texOut;



// this kernel takes in a 2-d array of floats
// it updates the value-of-interest by a scaled value based
// on itself and its nearest neighbors
__global__ void blend_kernel(float* dst,
    bool dstOut) {
    // map from threadIdx/BlockIdx to pixel position
    int x = threadIdx.x + blockIdx.x * blockDim.x;
    int y = threadIdx.y + blockIdx.y * blockDim.y;
    int offset = x + y * blockDim.x * gridDim.x;

    int left = offset - 1;
    int right = offset + 1;
    if (x == 0)   left++;
    if (x == DIM - 1) right--;

    int top = offset - DIM;
    int bottom = offset + DIM;
    if (y == 0)   top += DIM;
    if (y == DIM - 1) bottom -= DIM;

    float   t, l, c, r, b;
    if (dstOut) {
        t = tex1Dfetch(texIn, top);
        l = tex1Dfetch(texIn, left);
        c = tex1Dfetch(texIn, offset);
        r = tex1Dfetch(texIn, right);
        b = tex1Dfetch(texIn, bottom);

    }
    else {
        t = tex1Dfetch(texOut, top);
        l = tex1Dfetch(texOut, left);
        c = tex1Dfetch(texOut, offset);
        r = tex1Dfetch(texOut, right);
        b = tex1Dfetch(texOut, bottom);
    }
    dst[offset] = c + SPEED * (t + b + r + l - 4 * c);
}

// NOTE - texOffsetConstSrc could either be passed as a
// parameter to this function, or passed in __constant__ memory
// if we declared it as a global above, it would be
// a parameter here: 
// __global__ void copy_const_kernel( float *iptr,
//                                    size_t texOffset )
__global__ void copy_const_kernel(float* iptr) {
    // map from threadIdx/BlockIdx to pixel position
    int x = threadIdx.x + blockIdx.x * blockDim.x;
    int y = threadIdx.y + blockIdx.y * blockDim.y;
    int offset = x + y * blockDim.x * gridDim.x;

    float c = tex1Dfetch(texConstSrc, offset);
    if (c != 0)
        iptr[offset] = c;
}

// globals needed by the update routine
struct DataBlock {
    unsigned char* output_bitmap;
    float* dev_inSrc;
    float* dev_outSrc;
    float* dev_constSrc;
    IMAGE* bitmap;

    cudaEvent_t     start, stop;
    float           totalTime;
    float           frames;
};

void anim_gpu(DataBlock * d, int ticks) {

}

// clean up memory allocated on the GPU
void cleanup(DataBlock * d) {
    cudaUnbindTexture(texIn);
    cudaUnbindTexture(texOut);
    cudaUnbindTexture(texConstSrc);
    HANDLE_ERROR(cudaFree(d->dev_inSrc));
    HANDLE_ERROR(cudaFree(d->dev_outSrc));
    HANDLE_ERROR(cudaFree(d->dev_constSrc));

    HANDLE_ERROR(cudaEventDestroy(d->start));
    HANDLE_ERROR(cudaEventDestroy(d->stop));
}


int main(void) {
    DataBlock   data;
    IMAGE bitmap_image(DIM, DIM);
    data.bitmap = &bitmap_image;
    data.totalTime = 0;
    data.frames = 0;
    HANDLE_ERROR(cudaEventCreate(&data.start));
    HANDLE_ERROR(cudaEventCreate(&data.stop));

    int imageSize = bitmap_image.image_size();

    HANDLE_ERROR(cudaMalloc((void**)& data.output_bitmap,
        imageSize));

    // assume float == 4 chars in size (ie rgba)
    HANDLE_ERROR(cudaMalloc((void**)& data.dev_inSrc,
        imageSize));
    HANDLE_ERROR(cudaMalloc((void**)& data.dev_outSrc,
        imageSize));
    HANDLE_ERROR(cudaMalloc((void**)& data.dev_constSrc,
        imageSize));

    HANDLE_ERROR(cudaBindTexture(NULL, texConstSrc,
        data.dev_constSrc,
        imageSize));

    HANDLE_ERROR(cudaBindTexture(NULL, texIn,
        data.dev_inSrc,
        imageSize));

    HANDLE_ERROR(cudaBindTexture(NULL, texOut,
        data.dev_outSrc,
        imageSize));

    // intialize the constant data
    float* temp = (float*)malloc(imageSize);
    for (int i = 0; i < DIM * DIM; i++) {
        temp[i] = 0;
        int x = i % DIM;
        int y = i / DIM;
        if ((x > 300) && (x < 600) && (y > 310) && (y < 601))
            temp[i] = MAX_TEMP;
    }
    temp[DIM * 100 + 100] = (MAX_TEMP + MIN_TEMP) / 2;
    temp[DIM * 700 + 100] = MIN_TEMP;
    temp[DIM * 300 + 300] = MIN_TEMP;
    temp[DIM * 200 + 700] = MIN_TEMP;
    for (int y = 800; y < 900; y++) {
        for (int x = 400; x < 500; x++) {
            temp[x + y * DIM] = MIN_TEMP;
        }
    }
    HANDLE_ERROR(cudaMemcpy(data.dev_constSrc, temp,
        imageSize,
        cudaMemcpyHostToDevice));

    // initialize the input data
    for (int y = 800; y < DIM; y++) {
        for (int x = 0; x < 200; x++) {
            temp[x + y * DIM] = MAX_TEMP;
        }
    }
    HANDLE_ERROR(cudaMemcpy(data.dev_inSrc, temp,
        imageSize,
        cudaMemcpyHostToDevice));
    free(temp);

    int ticks = 0;
    bitmap_image.show_image(30);
    while (1)
    {
        HANDLE_ERROR(cudaEventRecord(data.start, 0));
        dim3    blocks(DIM / 16, DIM / 16);
        dim3    threads(16, 16);
        IMAGE * bitmap = data.bitmap;

        // since tex is global and bound, we have to use a flag to
        // select which is in/out per iteration
        volatile bool dstOut = true;
        for (int i = 0; i < 90; i++)
        {
            float* in, * out;
            if (dstOut)
            {
                in = data.dev_inSrc;
                out = data.dev_outSrc;
            }
            else
            {
                out = data.dev_inSrc;
                in = data.dev_outSrc;
            }
            copy_const_kernel << <blocks, threads >> > (in);
            blend_kernel << <blocks, threads >> > (out, dstOut);
            dstOut = !dstOut;
        }
        float_to_color << <blocks, threads >> > (data.output_bitmap,
            data.dev_inSrc);

        HANDLE_ERROR(cudaMemcpy(bitmap->get_ptr(),
            data.output_bitmap,
            bitmap->image_size(),
            cudaMemcpyDeviceToHost));

        HANDLE_ERROR(cudaEventRecord(data.stop, 0));
        HANDLE_ERROR(cudaEventSynchronize(data.stop));
        float   elapsedTime;
        HANDLE_ERROR(cudaEventElapsedTime(&elapsedTime,
            data.start, data.stop));
        data.totalTime += elapsedTime;
        ++data.frames;
        printf("Average Time per frame:  %3.1f ms\n",
            data.totalTime / data.frames);

        ticks++;
        char key = bitmap_image.show_image(30);
        if (key == 27)
        {
            break;
        }
    }

    cleanup(&data);

    return 0;
}
  • 写回答

1条回答 默认 最新

  • 赵4老师 2022-12-08 13:29
    关注

    就是提示中那个函数在提示中那个dll里面找不到。

    查看xxx.dll中导出了哪些函数:
    dumpbin.exe /exports xxx.dll

    查看“乱码”函数名对应的函数原型:

    #pragma comment(lib,"imagehlp")
    #include <stdio.h>
    #include <windows.h>
    #include <ImageHlp.h>
    char dsn[8192];
    void main(int argc,char **argv) {
        if (argc<2)  {
            printf("Usage:       %s DecorateSymbolName\n  to UnDecorateSymbolName.\n",argv[0]);
            printf("For example: %s ??4COleDateTime@@QAEABV0@N@Z\n",argv[0]);
            printf("public: class COleDateTime const & __thiscall COleDateTime::operator=(double)\n");
            return;
        }
        if (0==UnDecorateSymbolName(argv[1],dsn,8192,UNDNAME_COMPLETE)) {
            printf("UnDecorateSymbolName %s ERROR %08lx!",argv[1],GetLastError());
        } else {
            printf("%s\n",dsn);
        }
    }
    
    
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

问题事件

  • 系统已结题 12月16日
  • 已采纳回答 12月8日
  • 专家修改了标签 12月8日
  • 修改了问题 12月8日
  • 展开全部

悬赏问题

  • ¥170 如图所示配置eNSP
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改
  • ¥20 wireshark抓不到vlan
  • ¥20 关于#stm32#的问题:需要指导自动酸碱滴定仪的原理图程序代码及仿真
  • ¥20 设计一款异域新娘的视频相亲软件需要哪些技术支持
  • ¥15 stata安慰剂检验作图但是真实值不出现在图上
  • ¥15 c程序不知道为什么得不到结果
  • ¥15 键盘指令混乱情况下的启动盘系统重装