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

Building shared library on Windows with MSVC+cmake gives lots of linker warnings #995

Open
sveinse opened this issue Jan 1, 2025 · 0 comments

Comments

@sveinse
Copy link
Contributor

sveinse commented Jan 1, 2025

Describe the bug

Building portaudio on Windows with MSVC & cmake as a shared library gives lots of warnings about export symbols defined multiple times. An example of the warning:

<path>/build/portaudio/build/portaudio.dir/Debug/exports.def : warning LNK4197:
export 'Pa_WriteStream' specified multiple times; using first specification
[<path>\build\portaudio\build\portaudio.vcxproj]

To Reproduce

  1. Install MSVC Visual Studio or similar on Windows.

  2. Check out portaudio code from git

  3. Configure and build on windows.

     cd portaudio
     $cmake -G "Visual Studio 17 2022" -A x64 \
         -DCMAKE_BUILD_TYPE=RelWithDebInfo \
         -DPA_BUILD_SHARED_LIBS=ON -S . -B build
     $cmake --build build --config RelWithDebInfo
    

($cmake is a shortcut to the cmake provided by MSVC, which on my system is c:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\Cmake\bin\cmake.exe)

Expected behavior

Successful build without any warnings

Actual behavior

Observe 57 warnings during linking, for each of the exported symbol from PA. It doesn't look like the warning actually affects the output and the generated shared library seems to work as expected.

Desktop (please complete the following information):

  • OS: Windows 11. Compiling all Windows Host APIs
  • PortAudio version: git master commit aa1cfb0

Additional context

A fix for the problem is given by the following patch:

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1b9ce82..725cac8 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -458,7 +458,7 @@ set_target_properties(portaudio PROPERTIES
   PUBLIC_HEADER "${PORTAUDIO_PUBLIC_HEADERS}"
   MACOSX_FRAMEWORK_IDENTIFIER com.portaudio
   FRAMEWORK_VERSION A
-  WINDOWS_EXPORT_ALL_SYMBOLS TRUE
+  WINDOWS_EXPORT_ALL_SYMBOLS FALSE
   VERSION ${PROJECT_VERSION}
   SOVERSION 2
 )

believe using WINDOWS_EXPORT_ALL_SYMBOLS TRUE is not wanted since portaudio define the symbols in cmake\portaudio.def.in. If this is wanted, a PR can be made.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant