Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Altera_Forum
Honored Contributor I
903 Views

Visual studio 14.0 LNK2001 (unresolved external symbol ) with OpenCL

I am new to OpenCL. When I tried the examples from the website of Altera, I got LNK2001 errors as follows 

 

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 

 

I have already added path of the libs and head files. It seems that the OpenCL.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!!!
0 Kudos
1 Reply
Altera_Forum
Honored Contributor I
58 Views

I have had success compiling the vector_add test code with Visual Studio v14.0 (aka 2015)  

 

1) change Project vector_add properties Additional Depenancies "OpenCL.lib;legacy_stdio_definitions.lib;%(AdditionalDependencies)"  

2) change the main.cpp program, at top of file after includes 

FILE _iob[] = { *stdin, *stdout, *stderr };  

extern "C" FILE * __cdecl __iob_func(void) { return _iob; }  

extern "C" void __imp__set_output_format(void) {}; 

 

This may break other things, but the vector_add test works with these changes. (refs https://stackoverflow.com/questions/31242820 , https://stackoverflow.com/questions/30412951 )
Reply