Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiling on Windows (MSVC) results in invalid pkg-config files #1658

Closed
2 tasks done
btgoodwin opened this issue May 25, 2021 · 3 comments
Closed
2 tasks done

Compiling on Windows (MSVC) results in invalid pkg-config files #1658

btgoodwin opened this issue May 25, 2021 · 3 comments
Labels
bug This issue is a bug. closed-for-staleness

Comments

@btgoodwin
Copy link

Confirm by changing [ ] to [x] below to ensure that it's a bug:

Describe the bug

The cmake/platform/windows.cmake:15 sets CMAKE_RUNTIME_OUTPUT_DIRECTORY to the ${CMAKE_CURRENT_BINARY_DIR}/bin with the comment that it's to collect the runtime outputs including dlls into one directory to avoid copying them when using MSVC. The toolchains/pkg-config.pc.in template configures the Libs to point at libdir, which is set to @CMAKE_INSTALL_PREFIX@/@LIBRARY_DIRECTORY@. When a downstream project attempts to use pkg-config to locate the libraries, they're not found because the package config file says to look in lib but the libraries are actually in bin.

SDK version number

1.9.24 (main branch, hash 9be7f32)

Platform/OS/Hardware/Device

Windows 10

To Reproduce (observed behavior)

git clone --recursive https://github.com/aws/aws-sdk-cpp
cd aws-sdk-cpp
cmake  -B build -DCMAKE_INSTALL_PREFIX:PATH=C:/aws-cpp-sdk-all -DCMAKE_BUILD_TYPE=Debug -DENABLE_TESTING=false
cmake --build build -j --config Debug
cmake --install build --config Debug

Then checking pkg-config (provided by gstreamer in my case):

> set PKG_CONFIG_PATH=c:\aws-cpp-sdk-all\lib\pkgconfig
> pkg-config --msvc-syntax --libs aws-cpp-sdk-sts
/libpath:C:/aws-cpp-sdk-all/lib aws-cpp-sdk-sts.lib aws-cpp-sdk-core.lib

If we check that path, we find neither of those .lib files:

> dir c:\aws-cpp-sdk-all\lib
 Volume in drive C is OSDisk
 Volume Serial Number is ABCD-EFGH

 Directory of c:\aws-cpp-sdk-all\lib

05/25/2021  08:42 AM    <DIR>          .
05/25/2021  08:42 AM    <DIR>          ..
05/25/2021  08:42 AM    <DIR>          aws-c-auth
05/25/2021  08:25 AM            34,288 aws-c-auth.lib
05/25/2021  08:42 AM    <DIR>          aws-c-cal
05/25/2021  08:25 AM            15,808 aws-c-cal.lib
05/25/2021  08:42 AM    <DIR>          aws-c-common
05/25/2021  08:25 AM           133,838 aws-c-common.lib
05/25/2021  08:42 AM    <DIR>          aws-c-compression
05/25/2021  08:25 AM             4,366 aws-c-compression.lib
05/25/2021  08:42 AM    <DIR>          aws-c-event-stream
05/25/2021  08:25 AM            29,080 aws-c-event-stream.lib
05/25/2021  08:42 AM    <DIR>          aws-c-http
05/25/2021  08:25 AM            67,200 aws-c-http.lib
05/25/2021  08:42 AM    <DIR>          aws-c-io
05/25/2021  08:25 AM            62,826 aws-c-io.lib
05/25/2021  08:42 AM    <DIR>          aws-c-mqtt
05/25/2021  08:25 AM            27,654 aws-c-mqtt.lib
05/25/2021  08:42 AM    <DIR>          aws-c-s3
05/25/2021  08:25 AM            26,280 aws-c-s3.lib
05/25/2021  08:42 AM    <DIR>          aws-checksums
05/25/2021  08:25 AM             3,114 aws-checksums.lib
05/25/2021  08:42 AM    <DIR>          aws-crt-cpp
05/25/2021  08:25 AM           373,552 aws-crt-cpp.lib
05/25/2021  08:49 AM    <DIR>          cmake
05/25/2021  08:49 AM    <DIR>          pkgconfig
              11 File(s)        778,006 bytes
              15 Dir(s)  670,642,892,800 bytes free

Instead, each are over in c:\aws-cpp-sdk-all\bin. This results in linker errors related to apparently-missing files as seen here.

Expected behavior

The generated package config files should match the installation environment. In this case, either install the libraries into lib or generate a package config with flags pointed to bin, where the files are actually installed.

Logs/output

See above.

Additional context
Add any other context about the problem here.

@btgoodwin btgoodwin added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels May 25, 2021
@KaibaLopez
Copy link
Contributor

Hi @btgoodwin ,
Yea we are working on this problem, I'll let you know as soon as we have a fix.

@KaibaLopez KaibaLopez removed the needs-triage This issue or PR still needs to be triaged. label May 25, 2021
@btgoodwin
Copy link
Author

I gave the this patch a whirl today. It temporarily changes the LIBRARY_DIRECTORY in this special case for specifically producing the package config file and then reverts it back. The package config files now point to bin, which got my downstream dependency (amazon-s3-gst-plugin) to detect and attempt to link the packages. Now we're failing to link against _g_intern_static_string and others...baby steps, but this is something in the right direction perhaps:

From d60ed3b81cc537a2045f70be130385d39f2b6199 Mon Sep 17 00:00:00 2001
From: Thomas Goodwin <thomas.goodwin@laerdal.com>
Date: Tue, 25 May 2021 15:34:16 -0400
Subject: [PATCH] cmake/utilities.cmake: change LIBRARY_DIRECTORY for DLLs

DLL platforms install shared libraries into bin, not lib,
so we need to produce .pc files that correctly point to
the installed library location (#1658).

Signed-off-by: Thomas Goodwin <thomas.goodwin@laerdal.com>
---
 cmake/utilities.cmake | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/cmake/utilities.cmake b/cmake/utilities.cmake
index 00d8f44faa..964c3dcf02 100644
--- a/cmake/utilities.cmake
+++ b/cmake/utilities.cmake
@@ -33,7 +33,12 @@ endfunction(enable_unity_build)
 
 macro(setup_install)
     if(SIMPLE_INSTALL)
+        set(TEMP_LIBRARY_DIRECTORY "${LIBRARY_DIRECTORY}")
+        if (PLATFORM_WINDOWS AND BUILD_SHARED_LIBS)
+            set(LIBRARY_DIRECTORY "bin")
+        endif()
         configure_file("${AWS_NATIVE_SDK_ROOT}/toolchains/pkg-config.pc.in" "${PROJECT_NAME}.pc" @ONLY)
+        set(LIBRARY_DIRECTORY "${TEMP_LIBRARY_DIRECTORY}")
 
         install( TARGETS ${PROJECT_NAME}
                 EXPORT "${PROJECT_NAME}-targets"
-- 
2.30.2.windows.1

@github-actions
Copy link

Greetings! Sorry to say but this is a very old issue that is probably not getting as much attention as it deservers. We encourage you to check if this is still an issue in the latest release and if you find that this is still a problem, please feel free to open a new one.

@github-actions github-actions bot added closing-soon This issue will automatically close in 4 days unless further comments are made. closed-for-staleness and removed closing-soon This issue will automatically close in 4 days unless further comments are made. labels May 26, 2022
@github-actions github-actions bot closed this as completed Jun 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. closed-for-staleness
Projects
None yet
Development

No branches or pull requests

2 participants