I am having trouble finding a grandchild library in a transitive link scenario that we have. Actually, I’m not even sure what the correct terminology for a lot of this is, so I may be overly detailed in the explanation.
I am using:
- cmake version 3.16.4
- on a windows 10 machine
- compiling with Visual Studio 2017
I have a scenario where:
LIB-Bpublicly links with
EXE-D --> LIB-B --> LIB-A
LIB-B links with
LIB-A, that means
EXE-D will need access to both
LIB-B are all exported libraries, as per the example/explanation under CMake’s online help for Importing and Exporting Guide
I used the
PUBLIC scope when linking the child library so that they would be used transitively by downstream linking. (i.e. makes both
LIB-A & B available to
LIB-B compile fine. They’re pretty simple. However, compiling
EXE-D fails with the message
LINK : fatal error LNK1181: cannot open input file 'Lib_A_64.lib' [C:\TEST\ CMAKE-TRANSITIVE-COMPILE\EXE-D\Build\build64\VS2017\Exe_D_64.vcxproj]
I tried some debugging on my own and printed values from the EXE-D
CmakeLists.txt file and I found the following:
Exe_D_64-LINK_LIBRARIES: Lib_B_64 Lib_B_64-IMPORTED: TRUE Lib_B_64-IMPORTED_CONFIGURATIONS: DEBUG;RELEASE;RELWITHDEBINFO Lib_B_64-IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG: CXX Lib_B_64-IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE: CXX Lib_B_64-IMPORTED_LINK_INTERFACE_LANGUAGES_RELWITHDEBINFO: CXX Lib_B_64-IMPORTED_LOCATION_DEBUG: C:/TEMP/CMAKE-TEST/LIB-B/Win-VS2017/lib/Lib_B_64D.lib Lib_B_64-IMPORTED_LOCATION_RELEASE: C:/TEMP/CMAKE-TEST/LIB-B/Win-VS2017/lib/Lib_B_64R.lib Lib_B_64-IMPORTED_LOCATION_RELWITHDEBINFO: C:/TEMP/CMAKE-TEST/LIB-B/Win-VS2017/lib/Lib_B_64RD.lib Lib_B_64-INTERFACE_LINK_LIBRARIES: Lib_A_64
I noticed that the error is that it cannot find
Lib_A_64.lib and Lib_B_64 has
Lib_A_64 as it’s INTERFACE_LINK_LIBRARIES. It feels like I only have half the solution. It has the Lib_A_64 imported library name, but isn’t expanding to it’s location for the downstream linkage.
I also looked at the Visual Studio IDE project parameters for linker input and it pretty much says the same thing.
C:\TEMP\CMAKE-TEST\LIB-B\Win-VS2017\lib\Lib_B_64R.lib Lib_A_64.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib
How do I get transitive linking so that it shares the path of the grandchild library? What are the correct words for describiing this challenge?