Share via


error LNK2001: unresolved external symbol __imp__fopen

Question

Thursday, September 22, 2016 10:23 AM

I have a project in visual studio 2008. I tried migrating the same to visual studio 2015. After migrating the same using visual studio 2015 wizard and compiling the project I found lots of  error LNK2001 linking error while compiling.

I have one exe and approximately 20 lib files. I compiled the lib projects , it's getting compiled properly after migration. But issue is with the exe where the lib files are statically linked.

I had ensured that /MD option is same across all the projects including lib and exe , and there is no mixup of crt of different versions. While compiling with VS 2008  , everything works fine. While compiling with vs-2015 it showing errors. Most of the errors are related to function which uses ASCII string like fopen , strlwr_s , _malloc . 

The functions written in lib files are getting exported properly and not showing any error.
Errors are coming only for the system defined functions as below.

error LNK2001: unresolved external symbol _malloc
error LNK2001: unresolved external symbol __imp__modf
error LNK2001: unresolved external symbol __imp__ceil
error LNK2001: unresolved external symbol __imp__fprintf
error LNK2001: unresolved external symbol __imp__wcschr

I went through many articles in google , nothing seems to be working out for me. Please help me in resolving the issues.

Thanks in advance.

All replies (3)

Monday, September 26, 2016 9:06 AM ✅Answered

Hi tushar_kanta_gupta,

Please refer to the following MSDN document to troubleshoot your issue. Please refer to the possible causes and specific causes parts of the following link:

https://msdn.microsoft.com/en-us/library/f6xx1b1z.aspx?f=255&MSPPError=-2147217396

Sincerely,

Oscar

We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place. Click HERE to participate the survey.


Friday, September 23, 2016 6:11 AM

Hi tushar_kanta_gupta,

According to your description, this issue may be caused by the compiler compatibility between VS2008 and VS2015. Please refer to the following link about migrating project to VS2015.

In my side, I could not select VS2008. In order to realize compatibility please refer the part of “What about Visual Studio 2008?” from the following link. We also need to install VS 2010 on the same machine with your VS 2008. This ensures that the appropriate MSBuild scripts that enable targeting VS 2008 are installed (they only ship with VS 2010).

https://blogs.msdn.microsoft.com/vcblog/2016/02/24/stuck-on-an-older-toolset-version-move-to-visual-studio-2015-without-upgrading-your-toolset/

In addition, if this error caused by some lib files, I think we could ignore them, please refer to the following screenshot:

Sincerely,

Oscar

We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place. Click HERE to participate the survey.


Saturday, September 24, 2016 3:26 PM

Dear Oscar
Thanks for the reply. I had vs2010 already installed in my machine. I have all the versions 2005 , 2008 ,2010 and now 2015 community edition.  In fact I tried ignoring some of the library by using same option but nothing worked for me. 

The only concern I am able to see here is I need to make the solution xp compactible. So I am selecting "Visual Studio 2015 - Windows XP (v140_xp)" in platform tool set and our code is compiled in multibyte character set from project properties option. Is either of them going to create any sort of problems ?

Most of the errors are like : 
error LNK2001: unresolved external symbol __imp__strcpy_s
error LNK2001: unresolved external symbol _strcmp
error LNK2001: unresolved external symbol __imp____stdio_common_vsnwprintf_s
error LNK2001: unresolved external symbol __imp__fprintf
error LNK2001: unresolved external symbol __imp___wcslwr_s 

In the lib files those are getting added properly to relevent header files like <string.h> and others prperly. Error are coming when I am compiling exe where I am trying to link those staic library files. There are no mixup of debug/release version and /MS option or /ZI.

Thanks again ..