Intel® Quartus® Prime Software
Intel® Quartus® Prime Design Software, Design Entry, Synthesis, Simulation, Verification, Timing Analysis, System Design (Platform Designer, formerly Qsys)
16597 Discussions

Problem compiling hello world on Windows

Altera_Forum
Honored Contributor II
5,364 Views

I am attempting to compile and run the hello world design example using the emulator on Windows 7 with Visual Studio 2013. I have AOCL and Quartus installed and the environment configured according to the quick start guide. 

 

The host application compiles successfully using Visual Studio but when I run the executable, a message appears that says "The program can't start because altera_s5_ref_mmd.dll is missing from your computer. Try reinstalling the program to fix this problem." There is a file named altera_s5_ref_mmd.lib located in %ALTERAOCLSDKROOT%\board\s5_ref\windows64\lib but I do not see a dll. I also see the same error when I run aocl diagnose. 

 

Additionally, I am not able to compile the kernel. When I run "aoc -march=emulator -v device/hello_world.cl", this is the output: 

 

aoc: Environment checks are completed successfully. You are now compiling the full flow!! aoc: Selected target board s5_ref aoc: Running OpenCL parser.... aoc: OpenCL parser completed successfully. aoc: Compiling for Emulation .... Error: Optimizer FAILED. Refer hello_world/hello_world.log for details.  

 

Here is the contents of hello_world.log: 

 

Microsoft (R) Incremental Linker Version 12.00.21005.1 Copyright (C) Microsoft Corporation. All rights reserved. Creating library libkernel.lib and object libkernel.exp libkernel.obj : error LNK2019: unresolved external symbol printf referenced in function hello_world libkernel.obj : error LNK2019: unresolved external symbol ldexp referenced in function _ZL6lengthDv4_d libkernel.obj : error LNK2019: unresolved external symbol sinf referenced in function _Z8__tg_sinf libkernel.obj : error LNK2019: unresolved external symbol cosf referenced in function _Z8__tg_cosf libkernel.obj : error LNK2019: unresolved external symbol tanf referenced in function _Z8__tg_tanf libkernel.obj : error LNK2019: unresolved external symbol sin referenced in function _Z8__tg_tand libkernel.obj : error LNK2019: unresolved external symbol cos referenced in function _Z8__tg_tand libkernel.obj : error LNK2019: unresolved external symbol asinf referenced in function _Z9__tg_asinf libkernel.obj : error LNK2019: unresolved external symbol acosf referenced in function _Z9__tg_acosf libkernel.obj : error LNK2019: unresolved external symbol atanf referenced in function _Z9__tg_atanf libkernel.obj : error LNK2019: unresolved external symbol exp referenced in function _Z10__tg_sinhff libkernel.obj : error LNK2019: unresolved external symbol expf referenced in function _Z10__tg_coshff libkernel.obj : error LNK2019: unresolved external symbol logf referenced in function _Z8__tg_logf libkernel.obj : error LNK2019: unresolved external symbol log referenced in function _Z10__tg_log10d libkernel.obj : error LNK2019: unresolved external symbol floorf referenced in function _Z10__tg_truncf libkernel.obj : error LNK2019: unresolved external symbol ceilf referenced in function _Z10__tg_truncf LINK : error LNK2001: unresolved external symbol _DllMainCRTStartup libkernel.dll : fatal error LNK1120: 17 unresolved externals  

 

I have set %LIB% to "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\lib". 

 

The output of "aocl link-config" is 

 

/libpath:C:\altera\14.0\hld\board\s5_ref/windows64/lib /libpath:c:/altera/14.0/hld/host/windows64/lib alterahalmmd.lib altera_s_ref_mmd.lib alteracl.lib acl_emulator_kernel_rt.lib pkg_editor.lib libelf.lib acl_hostxml.lib 

 

Any assistance is appreciated.
0 Kudos
15 Replies
Altera_Forum
Honored Contributor II
1,246 Views

Hi, 

after days of struggling with very same problems I've finally solved both of them. 

First of all I'd like to address a problem with emulation. You have to set LIB variable to "(...)\Microsoft Visual Studio 10.0\VC\lib\amd64" ("amd64" is essential). However, after adding it you'd probably get an error regarding the "kernel32.lib" file. Thus you have to add additional path to LIB variable. "Kernel32.lib" file is located in "X:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Lib\x64" directory and this is the directory you have to add to LIB variable. 

I have to mention that I was using VS2010 Professional with SP1, yet, VS2013 should probably do fine as well (as long as you add proper paths to LIB variable). 

 

The altera_s5_ref_mmd.lib file is located in X:\altera\14.0\hld\board\(YOUR_BOARD)\windows64\bin, so make sure you add this directory to the PATH variable. You run "aocl install" afterwards and hopefully "aocl diagnose" won't return any errors. 

Then, again, after compiling successfully with "-march=emulator" flag, you shouldn't be surprised to have another error after host program execution (obviously, after building it with VS). This time it should be the "wdapi1021.dll" file. I just copied it form X:\altera\14.0\hld\board\s5_ref\windows64\driver directory to X:\Windows\System32. 

 

After all these steps I successfully managed to run emulation. I may have forgotten about something and if so, please post an error you got and I may recall a solution to it.
0 Kudos
Altera_Forum
Honored Contributor II
1,246 Views

I had the same linker errors and chris.lark's answer didn't solve it for me. What worked for me is: 1) Do NOT manually add the link.exe location to the PATH environment variable 2) call the altera/15.1/hld/init_opencl.bat file which sets up the environment. The init script checks if link.exe is found and if it is, it assumes that the visual studio environment has been set up correctly. Only if link.exe is not found, it will "guess" the visual studio installation (looking for VS10, VS11, VS12 in that order) and then call the visual studio script vcvars64.bat which (supposedly) sets some env variables to point to the right places. (Alternatively, you can of course put the link.exe in PATH and call the vcvars64.bat manually, instead of the init_opencl.bat, to keep the guesswork out of the build step).

0 Kudos
Altera_Forum
Honored Contributor II
1,246 Views

This path environment really giving alot of issues.

0 Kudos
Altera_Forum
Honored Contributor II
1,246 Views

 

--- Quote Start ---  

I had the same linker errors and chris.lark's answer didn't solve it for me. What worked for me is: 1) Do NOT manually add the link.exe location to the PATH environment variable 2) call the altera/15.1/hld/init_opencl.bat file which sets up the environment. The init script checks if link.exe is found and if it is, it assumes that the visual studio environment has been set up correctly. Only if link.exe is not found, it will "guess" the visual studio installation (looking for VS10, VS11, VS12 in that order) and then call the visual studio script vcvars64.bat which (supposedly) sets some env variables to point to the right places. (Alternatively, you can of course put the link.exe in PATH and call the vcvars64.bat manually, instead of the init_opencl.bat, to keep the guesswork out of the build step). 

--- Quote End ---  

 

 

I get the following error when I run the init_opencl.bat script:  

 

--- Quote Start ---  

 

VisualStudio's link.exe is not on the path. Guessing its location. 

\Microsoft was unexpected at this time. 

 

--- Quote End ---  

0 Kudos
Altera_Forum
Honored Contributor II
1,246 Views

Thanks a lot, Chris! I could build the aocx file after following your steps, but wanted to post a couple of observations.  

 

--- Quote Start ---  

I have to mention that I was using VS2010 Professional with SP1, yet, VS2013 should probably do fine as well (as long as you add proper paths to LIB variable). 

 

--- Quote End ---  

 

I had to point to the 64-bit version of link etc; i.e. add C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\amd64 to PATH (note \amd64).  

 

 

--- Quote Start ---  

The altera_s5_ref_mmd.lib file is located in X:\altera\14.0\hld\board\(YOUR_BOARD)\windows64\bin, so make sure you add this directory to the PATH variable. You run "aocl install" afterwards and hopefully "aocl diagnose" won't return any errors. 

 

--- Quote End ---  

 

In my case, "aocl install" returned "install: completed successfully" but "aocl diagnose" returned DIAGNOSTIC_FAILED for the reason:  

Unable to open the kernel mode driver.
0 Kudos
Altera_Forum
Honored Contributor II
1,246 Views

 

--- Quote Start ---  

After all these steps I successfully managed to run emulation. I may have forgotten about something and if so, please post an error you got and I may recall a solution to it. 

--- Quote End ---  

 

 

I could build the Mandelbrot example successfully, but get the following error when I run it from the directory where the AOCX file is.  

 

 

--- Quote Start ---  

 

c:\altera\examples\mandelbrot\device> ..\bin\mandelbrot.exe 

Using platform: Altera SDK for OpenCL 

Using 1 devices: 

EmulatorDevice : Emulated Device 

Using AOCX: mandelbrot_kernel.aocx 

AOCX file 'mandelbrot_kernel.aocx' does not exist. 

ERROR: CL_INVALID_PROGRAM 

Location: ..\common\src\AOCLUtils\opencl.cpp:368 

Failed to load binary file 

 

--- Quote End ---  

0 Kudos
Altera_Forum
Honored Contributor II
1,246 Views

I copied the aocx file and the exe in the same directory, and can run the host program, but it can’t find any OpenCL devices! 

 

--- Quote Start ---  

 

…  

MMD ERROR: can't load the WinDriver library 

ERROR: CL_DEVICE_NOT_FOUND 

Location: ..\common\src\AOCLUtils\opencl.cpp:354 

Query for number of devices failed 

 

--- Quote End ---  

 

 

I think the “aocl install” command is buggy (reports success but “aocl diagnose” finds issues;-)  

From an Administrator command prompt:  

 

 

--- Quote Start ---  

 

C:\windows\system32>aocl install 

aocl install: Running install from C:\altera\15.0\hld\board\s5_ref/windows64/lib 

exec 

+------------------------------------------------------+ 

+ Installing kernel driver module... + 

+------------------------------------------------------+ 

 

WDREG utility v10.21. Build Aug 31 2010 14:21:54 

 

Processing HWID *WINDRVR6 

Installing a signed driver package for *WINDRVR6 

LOG ok: 1, ENTER: DriverPackageInstallA 

LOG ok: 1, ENTER: DriverPackageInstallW 

LOG ok: 1, Looking for Model Section [DeviceList.NTamd64]... 

LOG ok: 1, RETURN: DriverPackageInstallW (0xE000024B) 

LOG ok: 1, RETURN: DriverPackageInstallA (0xE000024B) 

difx_install_preinstall_inf: err e000024b, last event 0, last error 0. UNKNOWN 

install: completed successfully 

 

+------------------------------------------------------+ 

+ Installing board drivers... + 

+------------------------------------------------------+ 

 

WDREG utility v10.21. Build Aug 31 2010 14:21:54 

 

Processing HWID PCI\VEN_1172&DEV_D800&SUBSYS_00051172&REV_01 

Installing a non-signed driver package for PCI\VEN_1172&DEV_D800&SUBSYS_00051172 

&REV_01 

Device node (hwid:PCI\VEN_1172&DEV_D800&SUBSYS_00051172&REV_01): does not exist 

and is not configured. Pre-installing. 

LOG ok: 1, ENTER: DriverPackagePreinstallA 

LOG ok: 1, ENTER: DriverPackagePreinstallW 

LOG ok: 1, RETURN: DriverPackagePreinstallW (0xE000022F) 

LOG ok: 1, RETURN: DriverPackagePreinstallA (0xE000022F) 

difx_install_preinstall_inf: err e000022f, last event 0, last error 0. UNKNOWN 

install: completed successfully 

 

--- Quote End ---  

 

 

I had run "aocl uninstall" before this to start from a clean slate. But apparently the driver was not installed, despite the last message.  

 

 

--- Quote Start ---  

 

C:\windows\system32>aocl diagnose 

aocl diagnose: Running diagnose from C:\altera\15.0\hld\board\s5_ref/windows64/l 

ibexec 

 

Unable to open the kernel mode driver. 

 

Please make sure you have properly installed the driver. To install the driver, 

run 

aocl install 

 

DIAGNOSTIC_FAILED 

 

--- Quote End ---  

0 Kudos
Altera_Forum
Honored Contributor II
1,246 Views

 

--- Quote Start ---  

I copied the aocx file and the exe in the same directory, and can run the host program, but it can’t find any OpenCL devices! 

 

 

I think the “aocl install” command is buggy (reports success but “aocl diagnose” finds issues;-)  

From an Administrator command prompt:  

 

 

 

I had run "aocl uninstall" before this to start from a clean slate. But apparently the driver was not installed, despite the last message. 

--- Quote End ---  

 

 

Facing the exact same problem here. 

"Unable to open the kernel mode driver. 

 

Please make sure you have properly installed the driver. To install the driver, run 

aocl install" 

 

Any follow up or help please? Thanks
0 Kudos
Altera_Forum
Honored Contributor II
1,246 Views

Hi, 

 

are you still facing the issue? Please copy the output from aocl install here. Then we can go from there.
0 Kudos
Altera_Forum
Honored Contributor II
1,246 Views

Yes, I think it's because I don't have the board support package for cyclone V GT, and writing one is seems like a huge challenge. 

 

A problem I am more concern about is: https://stackoverflow.com/questions/44211574/compiling-opencl-code-using-altera-aoc-unresolved-external-symbol
0 Kudos
Altera_Forum
Honored Contributor II
1,246 Views

So yes, if there is no BSP (Board Support Package) and therefore no driver you cannot install the board and you will see errors if you are trying to do so. 

 

The problem shown in that link is related to your Visual Studio Version? Which one are you using? If you are using Microsoft Visual Studio 15 or higher take a look here to resolve it: https://stackoverflow.com/questions/31242820/visual-studio-14-0-lnk2001-unresolved-external-symbol-with-opencl 

 

Cheers, 

fade
0 Kudos
Altera_Forum
Honored Contributor II
1,246 Views

 

--- Quote Start ---  

Hi, 

after days of struggling with very same problems I've finally solved both of them. 

First of all I'd like to address a problem with emulation. You have to set LIB variable to "(...)\Microsoft Visual Studio 10.0\VC\lib\amd64" ("amd64" is essential). However, after adding it you'd probably get an error regarding the "kernel32.lib" file. Thus you have to add additional path to LIB variable. "Kernel32.lib" file is located in "X:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Lib\x64" directory and this is the directory you have to add to LIB variable. 

I have to mention that I was using VS2010 Professional with SP1, yet, VS2013 should probably do fine as well (as long as you add proper paths to LIB variable). 

 

The altera_s5_ref_mmd.lib file is located in X:\altera\14.0\hld\board\(YOUR_BOARD)\windows64\bin, so make sure you add this directory to the PATH variable. You run "aocl install" afterwards and hopefully "aocl diagnose" won't return any errors. 

Then, again, after compiling successfully with "-march=emulator" flag, you shouldn't be surprised to have another error after host program execution (obviously, after building it with VS). This time it should be the "wdapi1021.dll" file. I just copied it form X:\altera\14.0\hld\board\s5_ref\windows64\driver directory to X:\Windows\System32. 

 

After all these steps I successfully managed to run emulation. I may have forgotten about something and if so, please post an error you got and I may recall a solution to it. 

--- Quote End ---  

 

 

Thanks for your answer very much. I got a same problem and now solved it with your method.
0 Kudos
Altera_Forum
Honored Contributor II
1,246 Views

I have the same problem but the message is a little bit different: 

 

aoc: Environment checks are completed successfully. 

You are now compiling the full flow!! 

aoc: Selected target board a10gx 

aoc: Running OpenCL parser.... 

aoc: OpenCL parser completed successfully. 

aoc: Compiling for Emulation .... 

Error: Linker FAILED. 

Refer hello_world/hello_world.log for details. 

 

I try everything to fix the linker problem but I don´t find solution. 

I´m using Quartus Primer Pro 17.0, windows 10 and Visual Studio Community 2017. 

Can somebody help me please?
0 Kudos
Altera_Forum
Honored Contributor II
1,246 Views

I am also having issues with running hello_world. My issue is I can use VS2010 to build host.exe and aol to build the hello_world.aocx but when I run host.exe, get the error 

 

......... 

Command queue out of order? = false 

Command queue profiling enabled? = true 

Using AOCX: hello_world_emu.aocx 

Context callback: Invalid binary. 

ERROR: CL_INVALID_BINARY 

Location: ..\common\src\AOCLUtils\opencl.cpp:392 

Failed to create program with binary 

 

The error code returned by createProgramFromBinary() call is -42 (CL_INVALID_BINARY) 

 

I use following command to generate the aocx file 

 

aoc -v -march=emulator --board c5soc hello_world.cl -o hello_world_emu.aocx 

aoc: Environment checks are completed successfully. 

You are now compiling the full flow!! 

aoc: Selected target board c5soc 

aoc: Running OpenCL parser.... 

aoc: OpenCL parser completed successfully. 

aoc: Compiling for Emulation .... 

aoc: Emulator Compilation completed successfully. 

Emulator flow is successful. 

To execute emulated kernel, invoke host with 

env CL_CONTEXT_EMULATOR_DEVICE_ALTERA=1 <host_program> 

For multi device emulations replace the 1 with the number of devices you wish to emulate 

 

Any suggestions why createProgramFromBinary is failing?
0 Kudos
Altera_Forum
Honored Contributor II
1,246 Views

 

--- Quote Start ---  

I have the same problem but the message is a little bit different: 

 

aoc: Environment checks are completed successfully. 

You are now compiling the full flow!! 

aoc: Selected target board a10gx 

aoc: Running OpenCL parser.... 

aoc: OpenCL parser completed successfully. 

aoc: Compiling for Emulation .... 

Error: Linker FAILED. 

Refer hello_world/hello_world.log for details. 

 

I try everything to fix the linker problem but I don´t find solution. 

I´m using Quartus Primer Pro 17.0, windows 10 and Visual Studio Community 2017. 

Can somebody help me please? 

--- Quote End ---  

 

You could post the log but you should see if your PATH environment variable is point to: 

C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\ (LINK.EXE is here) 

Replace it by this: 

C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\amd64 

 

Hope it solves :)
0 Kudos
Reply