Problems getting an OpenCl example to build in MSVS 2012 express. Not finding header files but paths etc...seem fine

StackOverflow https://stackoverflow.com/questions/18344935

Pregunta

I just started learning C last month and I just installed Microsoft Visual Studio Express 2012 this week; along with the AMD OpenCl SDK. I've followed the installation guides, searched around and everything seems to be setup properly, yet I still can't get this OpenCl example to build.

I'm trying to get an example to run that is in an OpenCL Programming guide book I downloaded from AMD. The problem I keep running into is that it doesn't seem to be able to locate the OpenCl header files.

"Error C1083: Cannot open include file: 'CL/cl_platform.h': No such file or directory 
c:\program files (x86)\amd app\include\cl\cl.h"

I checked the directory to make sure, and yep, the file is there.

For includes I have: #include <C:\Program Files (x86)\AMD APP\include\CL\cl.h

I've tried it as just: #include <Cl\cl.h> and #include <Cl/cl.h>

And the only time VS seems to find it is either with the full path, or as: #include <cl.h>

Otherwise I get: "Error C1083: Cannot open include file: 'CL\cl.h': No such file or directory"

Here's what I have for environmental path variable:

AMDAPPSDKROOT     C:\Program Files (x86)\AMD APP

Path              C:\Program Files (x86)\AMD APP\bin\x86_64

And in VS in C/C++ under Additional Include Directories:

$(AMDAPPSDKROOT)\include

Under Linker Additional Library Directories:

$(AMDAPPSDKROOT)\lib\x86_64

Under Input as Additional Dependencies

OpenCL.lib

And here's the commandline output for the C/C++:

/MP /GS /TC /Qpar /analyze /Wall /Gy /Zc:wchar_t /I"C:\Program Files (x86)\AMD APP\include" /ZI /Gm /Od /Fd"Debug\vc110.pdb" /fp:precise /D "_MBCS" /errorReport:prompt /WX- /Zc:forScope /RTC1 /GR /Gd /Oy- /MDd /openmp /Fa"Debug\" /EHsc /nologo /Fo"Debug\" /Ot /Fp"Debug\OpenClPractice.pch"

And the Linker:

/OUT:"D:\Python\C\OpenClPractice\Debug\OpenClPractice.exe" /MANIFEST /NXCOMPAT /PDB:"D:\Python\C\OpenClPractice\Debug\OpenClPractice.pdb" /DYNAMICBASE "kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib" "comdlg32.lib" "advapi32.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "odbc32.lib" "odbccp32.lib" "OpenCL.lib" /DEBUG /MACHINE:X86 /INCREMENTAL /PGD:"D:\Python\C\OpenClPractice\Debug\OpenClPractice.pgd" /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /ManifestFile:"Debug\OpenClPractice.exe.intermediate.manifest" /ERRORREPORT:PROMPT /NOLOGO /LIBPATH:"C:\Program Files (x86)\AMD APP\lib\x86_64" /TLBID:1

It all looks fine to me, but clearly it isn't or I wouldn't be having this problem. If anyone can help that'd be great.

Thanks!

¿Fue útil?

Solución

To provide an aggregate of the discussion on the comments; it appears the problem was solved by simply creating a new, clean project, adding the relevant directories and linker input manually (without any environment variable expansions) via the Project Properties dialog.

As to the original problem.. I don't really know. The only thing in the command-line argstring that would have likely caused direct trouble was the /TC (compile as C89 code) switch, which was automatically "deduced" by Visual Studio based on the input source file extension (most likely .c in this case). Replacing /TC with /TP (compile as C++ code) should work.

Also, the example source has been said to possibly having used either “ (U+201C), ” (U+201D) or even a ‟ (U+201F) as quotation mark glyphs instead of the correct " (U+0022), which will indeed cause trouble when pasted to the source explorer.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top