I have tried everything I can find on this forum but cannot set a relative path for a .lib file for Visual Studio 2022. It works if I copy and paste the lib file into \Builds\VisualStudio2022\ and just put LibName.lib in “External Libraries To Link” but I don’t want to put the lib file a temp build directory.
I understand from all the threads I have read I should be able to put something in “Extra Linker Flags” to tell it a relative directory to search.
The Projucer folder is typically two folders back from \Builds\VisualStudio2022\ so in theory this should mean something like:
I don’t know what you tried, but a heads up that PROJECT_DIR is not the jucer folder, but the Builds/VisualStudio2022/.
To debug those issues it is best to check the actual compiler call in the build output.
2>LINK : fatal error LNK1104: cannot open file 'OpenCL.lib'
/../../
2>LINK : warning LNK4044: unrecognized option '/../../'; ignored
2>LINK : fatal error LNK1104: cannot open file 'OpenCL.lib'
etc.
Which of these is supposed to work if the lib is two folders up from the VisualStudio2022 folder in the same place as my Projucer file?
Again, I have just OpenCL.lib under “External Libraries to Link” which works when in the VisualStudio2022 folder but I don’t know how to have it two folders up and still work.
Didn’t see that but just tried now and it also doesn’t work.
I tried with OpenCL.lib under External Libraries to Link and then under Extra Library Search Paths I put for both Debug and Release as I am not sure of syntax each of these possibilities (one at a time or both together):
${PROJECT_DIR}../../
${PROJECT_DIR}/../../
I get still: 2>LINK : fatal error LNK1104: cannot open file 'OpenCL.lib'
This file is clearly there two folders up from VisualStudio2022 with my Projucer as I have checked repeatedly also. There seems to be no way to designate the path to it though.
Sometimes I need to bring in the big guns to debug something like this, and I turn to Process Monitor from MS/SysInternals. It’s a great tool for monitoring things like the file system, and I use it to see where VS is looking for a file that it can’t seem to find. If you set it up to monitor for OpenCL.lib and run your build, you will see where it IS looking, and should be able to adjust your settings to fix the issue.
In projucer you can set the lib path relative to the generated XCode project. To make it work super easy make sure the lib has “lib” as the prefix of the filename name but omit the prefix when specifying it in projucer. For example to link to libABC.a just specify ABC as the lib you want to link and this works for me.