C/C++ x64 platform and LNK1181 error

René's Avatar

René

10 Oct, 2015 04:11 PM

AppVeyor seems to be made for .net and not so much for C/C++. At least the platform selection for a build matrix uses x86 for 32bit builds even though MSVC uses Win32. I've been able to bypass this by defining x86 in my solution file and "redirecting" to Win32 for use by my vcxproj files.
So my 32bit build is working fine now through said "workaround"

Yet my 64bit builds are currently failing (even though x64 is actually the correct platform name for MSVC)

LINK : fatal error LNK1181: cannot open input file 'advapi32.lib'

It seems like the x64 platform doesn't use the right library path. Or is there an error in my project file / config?

I don't want to provide my own build script and call SetEnv myself... not if there's a way to get this working using "vanilla" AppVeyor settings.

  1. Support Staff 1 Posted by Feodor Fitsner on 11 Oct, 2015 11:46 PM

    Feodor Fitsner's Avatar

    That configuration setting just sets configuration environment variable and it was introduced for VS projects built with MSBuild.

    To setup environment for C++ projects I think you should call C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat during the build and pass required architecture.

  2. 2 Posted by René on 12 Oct, 2015 11:24 AM

    René's Avatar

    I'll likely have to call this batch anyway as I need to build both 32bit and 64bit and combine their output. So even if the platform setting would have worked, I would end up with two archives.. one for 32bit and one 64bit (unless there's an option to serialize the build)
    Yet I hoped to prevent this because it all assumes the path is C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\ and won't work for newer setups... It's just like guessing the correct path which is rather ugly.

    But if I understood you correctly, what I use is also a Visual Studio project that is build through MSBuild. So AppVeyor seems to setup the correct environment for 32bit, shouldn't it be able to also setup the 64bit environment if one chooses the x64 platform?
    It even finds the solution file for me, but can't setup the right environment for 64bit if told so?

  3. Support Staff 3 Posted by Feodor Fitsner on 12 Oct, 2015 06:24 PM

    Feodor Fitsner's Avatar

    AppVeyor do nothing special for C++ projects. My guess is configuration variable set to x86 just worked in this case.

  4. 4 Posted by René on 12 Oct, 2015 09:17 PM

    René's Avatar

    I'm sorry then, I really though it has to call SetEnv / vcvarsall as I have to do (though I'm using WinSDK for Win7 locally)

    AppVeyor just seemed to do all the magic for me by automatically finding the solution file, building it etc. Seemed logical that it also setups the environment for me. (since I can't use said "magic" otherwise)

    I just wish that we had some constant I could rely on.. C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat might work for now, but will fail in the inevitable future and I don't know all the paths Microsoft uses

    Anyway, thank you for your support ;)

  5. 5 Posted by René on 17 Oct, 2015 01:58 PM

    René's Avatar

    just one final note (might help others with similar problems)

    vcvarsall didn't work for me either... that is because my .vcxproj files didn't define a PlatformToolset which caused MSBuild to fall back to v100 for VS2010 compatibility

    yet the v100 toolset seems buggy when trying to compile for x86_64 (amd64) as either RC.exe crashes, or libs can't be found.. (crash with vcvarsall amd64, lib issues with vcvarsall x86_amd64)

    Final solution for me: "C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.cmd" /Release /x64 Compiling with v100 (Windows7.1SDK) toolset without errors or crashes (I don't want a higher VC Runtime dependency)

    Seems like 64bit issues aren't so uncommon...
    http://help.appveyor.com/discussions/questions/213-platform-x86-is-...
    http://help.appveyor.com/discussions/problems/3203-vs2015-and-incor...
    And RDP really helps to inspect build hangs or otherwise weird environments

  6. Support Staff 6 Posted by Feodor Fitsner on 17 Oct, 2015 08:10 PM

    Feodor Fitsner's Avatar

    Thanks for the update and sharing the solution!

  7. Ilya Finkelshteyn closed this discussion on 25 Aug, 2018 02:00 AM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac