I am new to OpenCL. When I tried the examples from the website of Altera, I got several LNK2001 errors as follows
Severity Code Description Project File Line
Error LNK2001 unresolved external symbol __imp_sprintf hello_world C:\Users\S_KW\OpenCL\hello_world\alteracl.lib(acl_hal_mmd.obj) 1
Error LNK2001 unresolved external symbol __imp___iob_func hello_world C:\Users\S_KW\OpenCL\hello_world\alteracl.lib(acl_hal_mmd.obj) 1
Error LNK2001 unresolved external symbol __imp_fprintf hello_world C:\Users\S_KW\OpenCL\hello_world\alteracl.lib(acl_hal_mmd.obj) 1
Error LNK2001 unresolved external symbol __imp_sprintf hello_world C:\Users\S_KW\OpenCL\hello_world\alteracl.lib(acl_mem.obj) 1
Error LNK2001 unresolved external symbol __imp___iob_func hello_world C:\Users\S_KW\OpenCL\hello_world\alteracl.lib(acl_offline_hal.obj) 1
Error LNK2001 unresolved external symbol __imp__set_output_format hello_world C:\Users\S_KW\OpenCL\hello_world\alteracl.lib(acl_printf.obj) 1
Error LNK2001 unresolved external symbol __imp_fprintf hello_world C:\Users\S_KW\OpenCL\hello_world\alteracl.lib(acl_profiler.obj) 1
Error LNK2001 unresolved external symbol __imp_sprintf hello_world C:\Users\S_KW\OpenCL\hello_world\alteracl.lib(acl_program.obj) 1
Error LNK2001 unresolved external symbol __imp___iob_func hello_world C:\Users\S_KW\OpenCL\hello_world\alteracl.lib(acl_support.obj) 1
Error LNK2001 unresolved external symbol __imp_vsprintf hello_world C:\Users\S_KW\OpenCL\hello_world\alteracl.lib(acl_support.obj) 1
Error LNK2001 unresolved external symbol __imp_vsnprintf hello_world C:\Users\S_KW\OpenCL\hello_world\alteracl.lib(acl_support.obj) 1
Error LNK2001 unresolved external symbol __imp_vfprintf hello_world C:\Users\S_KW\OpenCL\hello_world\alteracl.lib(acl_support.obj) 1
Error LNK2001 unresolved external symbol __imp___iob_func hello_world C:\Users\S_KW\OpenCL\hello_world\alteracl.lib(acl_threadsupport.obj) 1
Error LNK1120 8 unresolved externals hello_world C:\Users\S_KW\OpenCL\hello_world\bin\hello_world.exe 1
Error IntelliSense: argument of type "void (*)(const char *errinfo, const void *, size_t, void *)" is incompatible with parameter of type "void (__stdcall *)(const char *, const void *, size_t, void *)" hello_world c:\Users\S_KW\OpenCL\hello_world\host\src\main.cpp 145
Warning LNK4044 unrecognized option '/LC:\Users\S_KW\arrow_c5sockit_bsp\arm32\lib'; ignored hello_world C:\Users\S_KW\OpenCL\hello_world\LINK 1
Warning LNK4044 unrecognized option '/lalterahalmmd'; ignored hello_world C:\Users\S_KW\OpenCL\hello_world\LINK 1
Warning LNK4044 unrecognized option '/lalterammdpcie'; ignored hello_world C:\Users\S_KW\OpenCL\hello_world\LINK 1
Error LNK2001 unresolved external symbol __imp_vsnprintf hello_world C:\Users\S_KW\OpenCL\hello_world\MSVCRT.lib(vsnprintf.obj) 1
Error LNK2001 unresolved external symbol __imp__vsnprintf hello_world C:\Users\S_KW\OpenCL\hello_world\MSVCRT.lib(vsnprintf.obj) 1
Error LNK2001 unresolved external symbol __imp___iob_func hello_world C:\Users\S_KW\OpenCL\hello_world\pkg_editor.lib(pkg_editor.obj) 1
Error LNK2001 unresolved external symbol __imp_fprintf hello_world C:\Users\S_KW\OpenCL\hello_world\pkg_editor.lib(pkg_editor.obj) 1
I have already added path of the libs and head files. I am confused by those errors. What can I do to solve this?
----------------------------UPDATE------------------------------
OK, as Hadi Brais said, I added it to additional dependencies. And all of the old errors are gone. But there comes a new one.
Severity Code Description Project File Line
Error LNK1120 1 unresolved externals hello_world C:\Users\S_KW\OpenCL\hello_world\bin\hello_world.exe 1
Error LNK2001 unresolved external symbol __imp_sprintf hello_world C:\Users\S_KW\OpenCL\hello_world\OpenCL.lib(icd_windows.obj) 1
Warning LNK4044 unrecognized option '/LC:\Users\S_KW\arrow_c5sockit_bsp\arm32\lib'; ignored hello_world C:\Users\S_KW\OpenCL\hello_world\LINK 1
Warning LNK4044 unrecognized option '/lalterahalmmd'; ignored hello_world C:\Users\S_KW\OpenCL\hello_world\LINK 1
Warning LNK4044 unrecognized option '/lalterammdpcie'; ignored hello_world C:\Users\S_KW\OpenCL\hello_world\LINK 1
This one has something to do with OpenCL.lib, I think. It seems that the lib cannot see the printf function. But I think the printf is built in C++. It is confusing. Someone know how to handle this? Thank you very much!!!
Update: according to the discussion in this link, this issue is caused by the re-definition of the stdin/stdout/stderr in VS2015, and the Altera OpenCL libs were build with VS2010. The miss match of the function call makes it failed at linking stage.
The legacy_stdio_definitions.lib can be included to solve the __imp_vfprintf linking, but not __imp__iob_func.
According to one of the discussion with a MS engineer, there are two ways you can overcome this: 1. encapsulate the lib into a DLL that is linked with the same CRT that was used by Altera. 2. wait for newer release of the libs from Altera.
Hope this can help.
just would like to follow up your issue. Are you running Altera OpenCL designs with Visual Studio 2015? I get the same error as you mentioned. Have you got it fixed yet? Thx (ps: it seems the same design can run with VS2013 but failed on VS2015)