Archived

This forum has been archived. Please start a new discussion on GitHub.

Error with Visual Studio 2015 using nuget package in debug mode only

I just recently upgraded to visual studio 2015 and tried using the nuget package manager for the first time. I successfully installed the ice package using Install-Package zeroc.ice.v140. I also have the ice builder add on. My project compiles fine in release configuration, but in debug configuration the compiler can not find the ice37d.lib. So I added the path to it using the Additional Library Directories option and it links, but now when it runs it cannot find the debug dlls. I have added the bin/debug/x64 directory to my Environment path, but it still does not find the dll during debuging. I did not have to manually add any of this when building the release configuration, and it just worked. Any ideas what I am doing wrong?

Comments

  • xdm
    xdm La Coruña, Spain
    edited August 2017

    Hi Adam,

    I guess that is because your project doesn't set <UseDebugLibraries>true</UseDebugLibraries> for debug configurations. Projects created with recent version of visual studio alway set this property for debug configurations and Ice NuGet packages use it to set the correct library path. If you look at one of the demo projects provided with Ice you can see all have this

    <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
    <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
        ...
        <UseDebugLibraries>false</UseDebugLibraries>
    </PropertyGroup>
    <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
        ...
        <UseDebugLibraries>true</UseDebugLibraries>
    </PropertyGroup>
    <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
        ...
        <UseDebugLibraries>false</UseDebugLibraries>
    </PropertyGroup>
    <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
        ...
        <UseDebugLibraries>true</UseDebugLibraries>
    </PropertyGroup>
    

    See for example https://github.com/zeroc-ice/ice-demos/blob/master/cpp98/Ice/bidir/msbuild/client/client.vcxproj#L33-L55

    This is documented under Nuget Package Details in Using the NuGet Packages

    Let us know if that solves your problem.

    Cheers,
    José

  • I added the useDebugLibraries option to my Debug|x64 configuration, and the behavior is still the same. It seems like you want me to set the UseDebugLibraries to false for the debug configuration. I tried it both ways with the same result. What is strange is even when I add the directory to my debug environment path it still does not find the dlls.

    <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> <ConfigurationType>Application</ConfigurationType> <PlatformToolset>v140</PlatformToolset> <UseDebugLibraries>true</UseDebugLibraries> </PropertyGroup>

  • xdm
    xdm La Coruña, Spain

    Sorry I mean to set it to true. Can you check what is the Link command being use, I just check with our demos and it is

    C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\link.exe /ERRORREPORT:PROMPT /OUT:"..\..\client.exe" /INCREMENTAL /NOLOGO /LIBPATH:"D:\3.7\ice-demos\cpp11\packages\zeroc.ice.v140.3.7.0\build\native\lib\Win32\Debug" setargv.obj kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /manifest:embed /DEBUG:FASTLINK /PDB:"..\..\client.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /IMPLIB:"..\..\client.lib" /MACHINE:X86 /FIXED:NO Win32\Debug\Client.obj
    

    For example build\native\lib\Win32\Debug is add to the Library search path for Debug Win32 builds

  • xdm
    xdm La Coruña, Spain

    You might also want to review the Additional Library Directories setting to ensure it inherit the parent settings. For example that is what I see with our demos

  • Here is my debug linker command line. It does link but only because I added the ice path manually. Still does not run because it cannot find the ice dlls. Maybe my qt add in is doing something funny?

    /OUT:"T:\Documents and Settings\akal\My Documents\Visual Studio 2015\Projects\GigeViewer\x64\Debug\\GigeViewer.exe" /MANIFEST /NXCOMPAT /PDB:"T:\Documents and Settings\akal\My Documents\Visual Studio 2015\Projects\GigeViewer\x64\Debug\GigeViewer.pdb" /DYNAMICBASE "PVStream64.lib" "PvGUI64_VC9.lib" "PvBase64.lib" "PvBuffer64.lib" "PvDevice64.lib" "PvGenICam64.lib" "PvStreamRaw64.lib" "Ws2_32.lib" "qtmaind.lib" "Qt5Cored.lib" "Qt5Guid.lib" "Qt5Widgetsd.lib" "kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib" "comdlg32.lib" "advapi32.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "odbc32.lib" "odbccp32.lib" /DEBUG /MACHINE:X64 /INCREMENTAL /PGD:"T:\Documents and Settings\akal\My Documents\Visual Studio 2015\Projects\GigeViewer\x64\Debug\GigeViewer.pgd" /SUBSYSTEM:WINDOWS /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /ManifestFile:"x64\Debug\GigeViewer.exe.intermediate.manifest" /ERRORREPORT:PROMPT /NOLOGO /LIBPATH:"T:\Documents and Settings\akal\My Documents\Visual Studio 2015\Projects\GigeViewer\packages\zeroc.ice.v140.3.7.0\build\native\lib\x64\Debug" /LIBPATH:"C:\Program Files (x86)\Pleora Technologies Inc\eBUS SDK\\Libraries" /LIBPATH:"P:\Qt\Qt5.6.2\5.6\msvc2015_64\lib" /TLBID:1

    here is my release linker command line, which works with no intervention, and does not include anything about the ice library.

    /OUT:"T:\Documents and Settings\akal\My Documents\Visual Studio 2015\Projects\GigeViewer\x64\Release\\GigeViewer.exe" /MANIFEST /NXCOMPAT /PDB:"T:\Documents and Settings\akal\My Documents\Visual Studio 2015\Projects\GigeViewer\x64\Release\GigeViewer.pdb" /DYNAMICBASE "PVStream64.lib" "PvGUI64_VC9.lib" "PvBase64.lib" "PvBuffer64.lib" "PvDevice64.lib" "PvGenICam64.lib" "PvStreamRaw64.lib" "Ws2_32.lib" "qtmain.lib" "Qt5Core.lib" "Qt5Gui.lib" "Qt5Widgets.lib" "kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib" "comdlg32.lib" "advapi32.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "odbc32.lib" "odbccp32.lib" /MACHINE:X64 /PGD:"T:\Documents and Settings\akal\My Documents\Visual Studio 2015\Projects\GigeViewer\x64\Release\GigeViewer.pgd" /SUBSYSTEM:WINDOWS /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /ManifestFile:"x64\Release\GigeViewer.exe.intermediate.manifest" /ERRORREPORT:PROMPT /NOLOGO /LIBPATH:"C:\Program Files (x86)\Pleora Technologies Inc\eBUS SDK\\Libraries" /LIBPATH:"P:\Qt\Qt5.6.2\5.6\msvc2015_64\lib" /TLBID:1

    I do have inherit from parrent enabled, but there is nothing inherited in the debug or release configuration like your example.

    here is my path where I add the bin\x64\debug directory but it still cannot find the dlls

  • xdm
    xdm La Coruña, Spain

    I do have inherit from parrent enabled, but there is nothing inherited in the debug or release configuration like your example.

    Sounds like something in your project overwrites it

    You don't need to hardcode the package path try to use $(IceHome) instead

    PATH=$(IceHome)\build\native\bin\$(Platform)\$(Configuration)
    

    That being said your PATH configuration looks correct and it is not clear to me why the DLL is not found.

    What dll is actually not found ice37d.dll? Did you try to run the application from the command line with that PATH?

  • adam3914
    edited August 2017

    I uninstalled the windows installer version of ice from my machine, and removed the directory from the main path. Now it seems to be working fine. I don't need to manually include any directorys and it works as it should. Removing that and adding the <UseDebugLibraries>true</UseDebugLibraries>seems to have fixed my problem.

    Is the UseDebugLibraries property something the nuget installer can do on it's own in the future?

  • xdm
    xdm La Coruña, Spain

    Hi Adam,

    I'm glad you get it working, but is not clear to me why having the MSI installed cause this. The PATH setting should have overwrite the system path. I will try to reproduce the issue.

    Is the UseDebugLibraries property something the nuget installer can do on it's own in the future?

    We plan to improve this in 3.7.1 so that the library search PATH doesn't depend on this property, but we still use it for setting the PATH as we need to know if the project use Release or Debug DLLs, we will check how we can improve this.

    Cheers,
    José