Linked Imported Library in Visual Studio Showing NOTFOUND

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Linked Imported Library in Visual Studio Showing NOTFOUND

Dustyn Blasig
Hi All,

I'm trying to debug an issues where an imported shared library is showing up in the linker command as not found, but within the CMake generation the target seems to exist.

# CMakeLists.txt ####################

include(bar.cmake)

add_library(foo SHARED)

if(TARGET bar)
  target_link_libraries(foo PUBLIC bar)
endif()

# bar.cmake #######################

add_library(bar SHARED IMPORTED)

...

On Linux, the link command contains the correct -L<bar path> and -lbar options. However, on Windows (Visual Studio) the linker command has "bar-NOTFOUND" instead of bar.lib as it should, even though bar should only be added as a dependency *if* it exists. 

How can I debug why this would happen? Is there a way to have CMake dump more information about that target?

Thanks!

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: Linked Imported Library in Visual Studio Showing NOTFOUND

Petr Kmoch
Hi Dustyn,

ELF platforms link against .so files, but Windows links against import libraries (.lib files) assocaited with DLLs. Does the target 'bar' have the IMPORTED_IMPLIB property set up correctly? (See https://cmake.org/cmake/help/latest/prop_tgt/IMPORTED_IMPLIB.html )

Petr

On Tue, 16 Apr 2019 at 21:37, Dustyn Blasig <[hidden email]> wrote:
Hi All,

I'm trying to debug an issues where an imported shared library is showing up in the linker command as not found, but within the CMake generation the target seems to exist.

# CMakeLists.txt ####################

include(bar.cmake)

add_library(foo SHARED)

if(TARGET bar)
  target_link_libraries(foo PUBLIC bar)
endif()

# bar.cmake #######################

add_library(bar SHARED IMPORTED)

...

On Linux, the link command contains the correct -L<bar path> and -lbar options. However, on Windows (Visual Studio) the linker command has "bar-NOTFOUND" instead of bar.lib as it should, even though bar should only be added as a dependency *if* it exists. 

How can I debug why this would happen? Is there a way to have CMake dump more information about that target?

Thanks!
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: Linked Imported Library in Visual Studio Showing NOTFOUND

Dustyn Blasig
Ah, thanks, that was it. 

So when I use find_library(), it finds the .lib portion on Windows. Is there a way to find the .dll portion as well? 

Also, if I change the library type to STATIC on Windows, that seems to have the same effect on the linkers command line as leaving it as SHARED but changing the library property from IMPORTED_LOCATION to IMPORTED_IMPLIB. Are there other differences?

If someone has a nice online example of a "best practice" for fining the .dll/.lib/.so portions and setting them up, I'd love to take a look.

Thx!

On Wed, Apr 17, 2019 at 6:50 AM Petr Kmoch <[hidden email]> wrote:
Hi Dustyn,

ELF platforms link against .so files, but Windows links against import libraries (.lib files) assocaited with DLLs. Does the target 'bar' have the IMPORTED_IMPLIB property set up correctly? (See https://cmake.org/cmake/help/latest/prop_tgt/IMPORTED_IMPLIB.html )

Petr

On Tue, 16 Apr 2019 at 21:37, Dustyn Blasig <[hidden email]> wrote:
Hi All,

I'm trying to debug an issues where an imported shared library is showing up in the linker command as not found, but within the CMake generation the target seems to exist.

# CMakeLists.txt ####################

include(bar.cmake)

add_library(foo SHARED)

if(TARGET bar)
  target_link_libraries(foo PUBLIC bar)
endif()

# bar.cmake #######################

add_library(bar SHARED IMPORTED)

...

On Linux, the link command contains the correct -L<bar path> and -lbar options. However, on Windows (Visual Studio) the linker command has "bar-NOTFOUND" instead of bar.lib as it should, even though bar should only be added as a dependency *if* it exists. 

How can I debug why this would happen? Is there a way to have CMake dump more information about that target?

Thanks!
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake