memtestCL icon indicating copy to clipboard operation
memtestCL copied to clipboard

Unable to build under Windows

Open gmemstr opened this issue 3 years ago • 1 comments

Latest build tools from Visual Studio, MSVC v143 & Windows 11 SDK. Using CUDA 8.0 from the archive. Results in the following

PS G:\Projects\memtestCL> nmake -f Makefiles\Makefile.windows

Microsoft (R) Program Maintenance Utility Version 14.30.30706.0
Copyright (C) Microsoft Corporation.  All rights reserved.

        cl -MT -Ox -EHsc -DWINDOWS -DCURL_STATICLIB -D_CRT_SECURE_NO_DEPRECATE -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0"\include memtestCL_core.obj memtestCL_cli.cpp -link "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0"\lib\x64\OpenCL.lib Ws2_32.lib -OUT:memtestCL.exe
Microsoft (R) C/C++ Optimizing Compiler Version 19.30.30706 for x86
Copyright (C) Microsoft Corporation.  All rights reserved.

memtestCL_cli.cpp
Microsoft (R) Incremental Linker Version 14.30.30706.0
Copyright (C) Microsoft Corporation.  All rights reserved.

/out:memtestCL_core.exe
"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\lib\x64\OpenCL.lib"
Ws2_32.lib
-OUT:memtestCL.exe
memtestCL_core.obj
memtestCL_cli.obj
memtestCL_core.obj : error LNK2019: unresolved external symbol _clGetDeviceInfo@20 referenced in function "public: __thiscall memtestState::memtestState(struct _cl_context *,struct _cl_device_id *)" (??0memtestState@@QAE@PAU_cl_context@@PAU_cl_device_id@@@Z)
memtestCL_cli.obj : error LNK2001: unresolved external symbol _clGetDeviceInfo@20
memtestCL_core.obj : error LNK2019: unresolved external symbol _clCreateContext@24 referenced in function __catch$?allocate@memtestMultiTester@@UAEII@Z$0
memtestCL_cli.obj : error LNK2001: unresolved external symbol _clCreateContext@24
memtestCL_core.obj : error LNK2019: unresolved external symbol _clRetainContext@4 referenced in function "public: __thiscall memtestFunctions::memtestFunctions(struct _cl_context *,struct _cl_device_id *,struct _cl_command_queue *)" (??0memtestFunctions@@QAE@PAU_cl_context@@PAU_cl_device_id@@PAU_cl_command_queue@@@Z)
memtestCL_cli.obj : error LNK2001: unresolved external symbol _clRetainContext@4
memtestCL_core.obj : error LNK2019: unresolved external symbol _clReleaseContext@4 referenced in function "public: __thiscall memtestFunctions::~memtestFunctions(void)" (??1memtestFunctions@@QAE@XZ)
memtestCL_cli.obj : error LNK2001: unresolved external symbol _clReleaseContext@4
memtestCL_core.obj : error LNK2019: unresolved external symbol _clCreateCommandQueue@20 referenced in function "public: __thiscall memtestState::memtestState(struct _cl_context *,struct _cl_device_id *)" (??0memtestState@@QAE@PAU_cl_context@@PAU_cl_device_id@@@Z)
memtestCL_core.obj : error LNK2019: unresolved external symbol _clRetainCommandQueue@4 referenced in function "public: __thiscall memtestFunctions::memtestFunctions(struct _cl_context *,struct _cl_device_id *,struct _cl_command_queue *)" (??0memtestFunctions@@QAE@PAU_cl_context@@PAU_cl_device_id@@PAU_cl_command_queue@@@Z)
memtestCL_core.obj : error LNK2019: unresolved external symbol _clReleaseCommandQueue@4 referenced in function "public: __thiscall memtestFunctions::~memtestFunctions(void)" (??1memtestFunctions@@QAE@XZ)
memtestCL_core.obj : error LNK2019: unresolved external symbol _clCreateBuffer@24 referenced in function "public: unsigned int __thiscall memtestState::allocate(unsigned int)" (?allocate@memtestState@@QAEII@Z)
memtestCL_core.obj : error LNK2019: unresolved external symbol _clReleaseMemObject@4 referenced in function "public: __thiscall memtestState::~memtestState(void)" (??1memtestState@@QAE@XZ)
memtestCL_core.obj : error LNK2019: unresolved external symbol _clCreateProgramWithSource@20 referenced in function "public: __thiscall memtestFunctions::memtestFunctions(struct _cl_context *,struct _cl_device_id *,struct _cl_command_queue *)" (??0memtestFunctions@@QAE@PAU_cl_context@@PAU_cl_device_id@@PAU_cl_command_queue@@@Z)
memtestCL_core.obj : error LNK2019: unresolved external symbol _clReleaseProgram@4 referenced in function "public: __thiscall memtestFunctions::~memtestFunctions(void)" (??1memtestFunctions@@QAE@XZ)
memtestCL_core.obj : error LNK2019: unresolved external symbol _clBuildProgram@24 referenced in function "public: __thiscall memtestFunctions::memtestFunctions(struct _cl_context *,struct _cl_device_id *,struct _cl_command_queue *)" (??0memtestFunctions@@QAE@PAU_cl_context@@PAU_cl_device_id@@PAU_cl_command_queue@@@Z)
memtestCL_core.obj : error LNK2019: unresolved external symbol _clGetProgramInfo@20 referenced in function "public: __thiscall memtestFunctions::memtestFunctions(struct _cl_context *,struct _cl_device_id *,struct _cl_command_queue *)" (??0memtestFunctions@@QAE@PAU_cl_context@@PAU_cl_device_id@@PAU_cl_command_queue@@@Z)
memtestCL_core.obj : error LNK2019: unresolved external symbol _clGetProgramBuildInfo@24 referenced in function "public: __thiscall memtestFunctions::memtestFunctions(struct _cl_context *,struct _cl_device_id *,struct _cl_command_queue *)" (??0memtestFunctions@@QAE@PAU_cl_context@@PAU_cl_device_id@@PAU_cl_command_queue@@@Z)
memtestCL_core.obj : error LNK2019: unresolved external symbol _clCreateKernel@12 referenced in function "public: __thiscall memtestFunctions::memtestFunctions(struct _cl_context *,struct _cl_device_id *,struct _cl_command_queue *)" (??0memtestFunctions@@QAE@PAU_cl_context@@PAU_cl_device_id@@PAU_cl_command_queue@@@Z)
memtestCL_core.obj : error LNK2019: unresolved external symbol _clReleaseKernel@4 referenced in function "public: __thiscall memtestFunctions::~memtestFunctions(void)" (??1memtestFunctions@@QAE@XZ)
memtestCL_core.obj : error LNK2019: unresolved external symbol _clSetKernelArg@16 referenced in function "protected: int __thiscall memtestFunctions::setKernelArgs(struct _cl_kernel * &,int,unsigned int const *,void const * *)const " (?setKernelArgs@memtestFunctions@@IBEHAAPAU_cl_kernel@@HPBIPAPBX@Z)
memtestCL_core.obj : error LNK2019: unresolved external symbol _clGetKernelInfo@20 referenced in function "protected: int __thiscall memtestFunctions::setKernelArgs(struct _cl_kernel * &,int,unsigned int const *,void const * *)const " (?setKernelArgs@memtestFunctions@@IBEHAAPAU_cl_kernel@@HPBIPAPBX@Z)
memtestCL_core.obj : error LNK2019: unresolved external symbol _clGetKernelWorkGroupInfo@24 referenced in function "public: unsigned int __thiscall memtestFunctions::max_workgroup_size(void)const " (?max_workgroup_size@memtestFunctions@@QBEIXZ)
memtestCL_core.obj : error LNK2019: unresolved external symbol _clGetEventInfo@20 referenced in function "int __cdecl softwaitForEvents(unsigned int,struct _cl_event * const *,struct _cl_command_queue * const *,unsigned int,unsigned int)" (?softwaitForEvents@@YAHIPBQAU_cl_event@@PBQAU_cl_command_queue@@II@Z)
memtestCL_core.obj : error LNK2019: unresolved external symbol _clReleaseEvent@4 referenced in function "int __cdecl softwaitForEvents(unsigned int,struct _cl_event * const *,struct _cl_command_queue * const *,unsigned int,unsigned int)" (?softwaitForEvents@@YAHIPBQAU_cl_event@@PBQAU_cl_command_queue@@II@Z)
memtestCL_core.obj : error LNK2019: unresolved external symbol _clFlush@4 referenced in function "int __cdecl softwaitForEvents(unsigned int,struct _cl_event * const *,struct _cl_command_queue * const *,unsigned int,unsigned int)" (?softwaitForEvents@@YAHIPBQAU_cl_event@@PBQAU_cl_command_queue@@II@Z)
memtestCL_core.obj : error LNK2019: unresolved external symbol _clEnqueueReadBuffer@36 referenced in function "public: unsigned int __thiscall memtestFunctions::verifyConstant(unsigned int,unsigned int,struct _cl_mem *,unsigned int,unsigned int,struct _cl_mem *,unsigned int *,int &)const " (?verifyConstant@memtestFunctions@@QBEIIIPAU_cl_mem@@II0PAIAAH@Z)
memtestCL_core.obj : error LNK2019: unresolved external symbol _clEnqueueCopyBuffer@36 referenced in function __catch$?allocate@memtestState@@QAEII@Z$0
memtestCL_core.obj : error LNK2019: unresolved external symbol _clEnqueueNDRangeKernel@36 referenced in function "public: struct _cl_event * __thiscall memtestFunctions::writeConstant(unsigned int,unsigned int,struct _cl_mem *,unsigned int,unsigned int,int &)const " (?writeConstant@memtestFunctions@@QBEPAU_cl_event@@IIPAU_cl_mem@@IIAAH@Z)
memtestCL_cli.obj : error LNK2019: unresolved external symbol _clGetPlatformIDs@12 referenced in function "void __cdecl initialize_CL(struct _cl_platform_id * &,struct _cl_context * &,struct _cl_device_id * &,int &,int &)" (?initialize_CL@@YAXAAPAU_cl_platform_id@@AAPAU_cl_context@@AAPAU_cl_device_id@@AAH3@Z)
memtestCL_cli.obj : error LNK2019: unresolved external symbol _clGetPlatformInfo@20 referenced in function "void __cdecl initialize_CL(struct _cl_platform_id * &,struct _cl_context * &,struct _cl_device_id * &,int &,int &)" (?initialize_CL@@YAXAAPAU_cl_platform_id@@AAPAU_cl_context@@AAPAU_cl_device_id@@AAH3@Z)
memtestCL_cli.obj : error LNK2019: unresolved external symbol _clGetDeviceIDs@24 referenced in function "void __cdecl initialize_CL(struct _cl_platform_id * &,struct _cl_context * &,struct _cl_device_id * &,int &,int &)" (?initialize_CL@@YAXAAPAU_cl_platform_id@@AAPAU_cl_context@@AAPAU_cl_device_id@@AAH3@Z)
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\lib\x64\OpenCL.lib : warning LNK4272: library machine type 'x64' conflicts with target machine type 'x86'
memtestCL.exe : fatal error LNK1120: 28 unresolved externals
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.30.30705\bin\HostX86\x86\cl.EXE"' : return code '0x2'
Stop.

I'm unsure how I can resolve this myself, since it's midnight and I don't do a lot of C++, much less with CUDA and Windows SDKs.

gmemstr avatar Nov 30 '21 23:11 gmemstr

The problem is that by default, the build is configured to use the NVIDIA 64 version of the OpenCL.lib, but cl in visual studio command prompt defaults to 64 bits. Clean your solution and rebuild using the x64 Native Tools Command Prompt. If you want to skip this, I'll attach the compiled binary here. memtestCL.zip

fedacking avatar Mar 21 '23 05:03 fedacking