带有OpenCL的Visual Studio 14.0 LNK2001(无法解析的外部符号) [英] Visual studio 14.0 LNK2001 (unresolved external symbol ) with OpenCL

查看:124
本文介绍了带有OpenCL的Visual Studio 14.0 LNK2001(无法解析的外部符号)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是OpenCL的新手.当我尝试从Altera网站上获取示例时,出现了以下LNK2001错误

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

我已经添加了libs和head文件的路径.这些错误使我感到困惑.我该怎么解决?

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

----------------------------UPDATE------------------------------

好的,正如哈迪·布雷斯(Hadi Brais)所说,我将其添加到其他依赖项中.并且所有旧错误都消失了.但是有一个新的.

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

我认为,这与OpenCL.lib有关.似乎lib无法看到printf函数.但是我认为printf是用C ++构建的.令人困惑.有人知道如何处理吗?非常感谢!!!

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!!!

推荐答案

更新: 根据此链接中的讨论,此问题是由于在VS2015中重新定义了stdin/stdout/stderr引起的,而Altera OpenCL库是使用VS2010构建的.函数调用的未命中匹配使其在链接阶段失败.

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.

可以包含legacy_stdio_definitions.lib来解决__imp_vfprintf链接,但不能解决__imp__iob_func.

The legacy_stdio_definitions.lib can be included to solve the __imp_vfprintf linking, but not __imp__iob_func.

根据与MS工程师的讨论之一,有两种方法可以克服此问题:1.将lib封装到与Altera使用的同一CRT链接的DLL中. 2.等待新版本的Altera库.

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.

希望这会有所帮助.

只想跟进您的问题. 您是否正在使用Visual Studio 2015运行Altera OpenCL设计? 我收到与您提到的相同的错误.你把它修好了吗? Thx(ps:似乎相同的设计可以在VS2013上运行,但在VS2015上失败)

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)

这篇关于带有OpenCL的Visual Studio 14.0 LNK2001(无法解析的外部符号)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆