1

I have an exe written in C (not C++ or C#) to call a dll. It compiles with Clang and I'm linking it from the Visual Studio command line using link.exe. This build is on Windows 7. My command string is:

link.exe SxSv.obj /nologo /subsystem:console /MACHINE:X64 /LIBPATH:"C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Lib\x64\" /OUT:SxSv.exe kernel32.lib 

Link.exe gives me these errors:

SxSv.obj : error LNK2019: unresolved external symbol __imp_LoadLibraryA referenced in function WinMain

SxSv.obj : error LNK2019: unresolved external symbol __imp_GetProcAddress referenced in function WinMain

SxSv.obj : error LNK2019: unresolved external symbol __imp_FreeLibrary referenced in function WinMain

SxSv.obj : error LNK2019: unresolved external symbol __stdio_common_vsprintf referenced in function _vsnprintf_l

LINK : error LNK2001: unresolved external symbol mainCRTStartup
C:\Program Files (x86)\Windows Kits\10\lib\10.0.17763.0\um\x86\uuid.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64'

SxSv.exe : fatal error LNK1120: 5 unresolved externals

The problem seems to be this line:

/LIBPATH:"C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Lib\x64\"

and I think the problem is the Windows SDK that is installed. This computer has Visual Studio 2017 CE installed.

My questions are:

  1. It looks like there is only one SDK for Windows 7, released in 2010. Where would I expect to see it if it is installed?

  2. Can I use it to link a 64-bit exe?

3, There are a lot of uuid.lib files installed on this Windows 7 box. Which one would I use for Windows 7 for a 64-bit exe?⌈

I am doing this from the Visual Studio Developer command line, not from the IDE.

Thanks for any help.

EDIT: the question suggested as the duplicate of this one is very helpful but it's not the complete solution to this problem as it does not explain what libraries to link to. The comment below by Hans Passant helps best. First I will transfer this project to Visual Studio and go from there to find the right libraries to link this to.

RTC222
  • 2,025
  • 1
  • 20
  • 53
  • 2
    Possible duplicate of [What is an undefined reference/unresolved external symbol error and how do I fix it?](https://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix) – Ken White Sep 16 '19 at 17:28
  • Thanks, @Ken White - that article is related to this question, but it's not a duplicate. I know I am not linking to the correct library. My questions here relate specifically to the SDK / library for uuid.lib. – RTC222 Sep 16 '19 at 17:34
  • 1
    I don't see that as being your primary question here, as all of the error messages you reference refer to other libraries not being found, you ask a generic question related to the Windows SDK version, and you ask about being able to use that version of the SDK for linking a 64-bit exe. The mention of `uuid.lib` doesn't come up until the very end of your (inappropriate numbered list of) questions. – Ken White Sep 16 '19 at 17:37
  • I thought the resolution of the final error would also resolve the others. You say (I think) that the other errors are a different library. In that case, I will first concentrate on those. – RTC222 Sep 16 '19 at 17:40
  • 3
    The missing symbols have a 32-bit name decoration, they are not going to be resolved by linking a 64-bit library. So the file is compiled wrong. Where the uuid.lib warning came from is not obvious, but more of the bitness mixup. Using the IDE to avoid simple mistakes like this is always recommended. – Hans Passant Sep 16 '19 at 18:18
  • Thanks @Hans Passant. At this point I have to agree with you. Most of the research I see is in the context of the IDE, not the command line. So I will set up clang in Visual Studio to compile and link there. Thanks once again. – RTC222 Sep 16 '19 at 18:28

0 Answers0