msquic icon indicating copy to clipboard operation
msquic copied to clipboard

QuicAddrSetFamily & QuicAddrSetPort not found

Open kdzapp opened this issue 3 years ago • 4 comments

Describe the bug

Looks like I can't call QuicAddrSetFamily() or QuicAddrSetPort() on MacOS. Didn't see those functions in the header files in the release either.

Affected OS

  • [ ] All
  • [ ] Windows Server 2022
  • [ ] Windows 11, version 22H2
  • [ ] Windows 11, version 21H2
  • [ ] Windows Insider Preview (specify affected build below)
  • [ ] Ubuntu
  • [ ] Debian
  • [X] Other (specify below)

Additional OS information

macOS Monterey

MsQuic version

release/2.0

Steps taken to reproduce bug

  1. Download release 2.0 for mac universal
  2. Download sample.c on Mac
  3. Compile gcc ./lib/msquic/msquic.dylib ./src/main.c -o ./bin/main.o

Expected behavior

It should successfully compile.

Actual outcome

It fails with the following output:

gcc ./lib/msquic/msquic.dylib ./src/main.c -o ./bin/main.o
Undefined symbols for architecture x86_64:
  "_QuicAddrSetFamily", referenced from:
      _RunServer in main-02bc1a.o
  "_QuicAddrSetPort", referenced from:
      _RunServer in main-02bc1a.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [main.o] Error 1

Additional details

No response

kdzapp avatar Aug 24 '22 06:08 kdzapp

The definition should be in msquic_posix.h. I'm not sure why you're getting a compile error.

nibanks avatar Aug 24 '22 13:08 nibanks

It’s failing because of the way inline works in c is funky, and clang actually cares that is is correct.

https://github.com/microsoft/msquic/blob/main/src/platform/inline.c

See the comments on here. You can fix it by copying the 2 definitions for those functions from that file into the sample code

ThadHouse avatar Aug 24 '22 16:08 ThadHouse

This worked! Thank you @ThadHouse -- it would be helpful if this gotchya were in the documentation somewhere. Or possibly even including the definitions in the release zip? Not sure, but thanks either way.

kdzapp avatar Aug 24 '22 19:08 kdzapp

Feel free to suggest a PR!

nibanks avatar Aug 24 '22 19:08 nibanks

Closing this issue from lack of progress.

nibanks avatar May 08 '23 22:05 nibanks

Hi,

See the comments on here. You can fix it by copying the 2 definitions for those functions from that file into the sample code

You can do that, or you can also compile your program with no (or less) optimizations, this might not be what you want but you can: gcc -O1 sample.c -o sample -lmsquic

iiztp avatar Jul 02 '24 09:07 iiztp