Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
11 years ago

Problem compiling hello world on Windows

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.

15 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    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
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    --- 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.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    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?
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    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?
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    --- 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 :)