Linking Problem with Static Library in Projucer with Visual Studio 2019

In my Projucer I have to following:

But I get this linking error:

1>Done building project "duckout_SharedCode.vcxproj".
2>------ Build started: Project: duckout_VST3, Configuration: Debug x64 ------
2>include_juce_audio_plugin_client_VST3.cpp
2>LINK : warning LNK4044: unrecognized option '/L..\..\LicenseSpringWin\staticMD'; ignored
2>LINK : fatal error LNK1104: cannot open file 'LicenseSpring.obj'
2>Done building project "duckout_VST3.vcxproj" -- FAILED.

It looks like the includes are working, but the linking doesn’t work.

Any ideas how to make this work?

Rather than setting the compiler and linker flags directly, you should use the ‘Header Search Paths’ and ‘Extra Library Search Paths’ fields, which can be found in the settings pane for each build configuration (i.e. the ‘Debug’/‘Release’ list entries on the left side of the Projucer window).

1 Like

Great! That cleared the error. I am using dynamic runtime, but the LicenseSpring library I want to use is static. Will that cause issues?

If you’re linking against a staticlib, the windows runtime must match between the staticlib and whatever it’s being linked to. That means, if the staticlib was built against the dynamic runtime, then your JUCE target should build against the dynamic runtime too. If the staticlib was built against the static runtime, then the JUCE target should use the static runtime. I think in newer versions of VS you should see linker errors if the runtime libraries don’t match.

Ok.

For reference: this is what I did:

I don’t see LicenseSpring.lib and LicenseSpringD.lib in Visual Studio’s Linker->Input->Additional Dependencies.

I would think Juce would put the .lib files there. I am doing this correctly?

No, the libraries you want to link should go in the “External Libraries to Link” field rather than the “Preprocessor Definitions” field.

From doing that I get:

LINK : fatal error LNK1104: cannot open file 'LicenseSpring.obj'

Is my extra library search path formatted correctly?

It looks correctly formatted. My best guess is that the relative path is resolving to an unexpected location. I think that paths are resolved relative to the Builds/VisualStudio2019 folder.

I instead did this:

and it worked. Which is weird because I read that you shouldn’t put files types here.