CMake build exports no XXX_64 functions
Brought to you by:
sobukus
Hi, i'm trying to update Vcpkg's mpg123 port.
mpg123 itself builds successfully, but i've got regression with libopenmpt (libmpg123 is dependency):
libopenmpt.lib(SampleFormatMP3.cpp.obj) : error LNK2019: unresolved external symbol mpg123_open_handle_64 referenced in function "public: bool __cdecl OpenMPT::CSoundFile::ReadMP3Sample(unsigned short,class OpenMPT::detail::FileReader<class OpenMPT::FileReaderTraitsStdStream> &,bool)" (?ReadMP3Sample@CSoundFile@OpenMPT@@QEAA_NGAEAV?$FileReader@VFileReaderTraitsStdStream@OpenMPT@@@detail@2@_N@Z) libopenmpt.lib(SampleFormatMP3.cpp.obj) : error LNK2019: unresolved external symbol mpg123_length_64 referenced in function "public: bool __cdecl OpenMPT::CSoundFile::ReadMP3Sample(unsigned short,class OpenMPT::detail::FileReader<class OpenMPT::FileReaderTraitsStdStream> &,bool)" (?ReadMP3Sample@CSoundFile@OpenMPT@@QEAA_NGAEAV?$FileReader@VFileReaderTraitsStdStream@OpenMPT@@@detail@2@_N@Z) libopenmpt.lib(SampleFormatMP3.cpp.obj) : error LNK2019: unresolved external symbol mpg123_replace_reader_handle_64 referenced in function "public: bool __cdecl OpenMPT::CSoundFile::ReadMP3Sample(unsigned short,class OpenMPT::detail::FileReader<class OpenMPT::FileReaderTraitsStdStream> &,bool)" (?ReadMP3Sample@CSoundFile@OpenMPT@@QEAA_NGAEAV?$FileReader@VFileReaderTraitsStdStream@OpenMPT@@@detail@2@_N@Z)
I guess the problem is large file handling, something is lost when porting Visual Studio solution to CMake project.
I've tried to build shared library manally (VS Code + CMakeTools + VS2019), here is result:
[main] Building folder: mpg123-1.27.0 libmpg123 [build] Starting build [proc] Executing command: "c:/Program Files/CMake/bin/cmake.exe" --build d:/source/repos/mpg123-1.27.0/build --config Release --target libmpg123 -j 8 -- [build] [1/1 100% :: 0.169] Linking C shared library src\libmpg123\mpg123.dll [build] FAILED: src/libmpg123/mpg123.dll src/libmpg123/mpg123.lib [build] cmd.exe /C "cd . && "C:\Program Files\CMake\bin\cmake.exe" -E vs_link_dll --intdir=src\libmpg123\CMakeFiles\libmpg123.dir --rc=C:\PROGRA~2\WI3CF2~1\10\bin\100190~1.0\x64\rc.exe --mt=C:\PROGRA~2\WI3CF2~1\10\bin\100190~1.0\x64\mt.exe --manifests -- C:\PROGRA~2\MICROS~1\2019\COMMUN~1\VC\Tools\MSVC\1428~1.299\bin\Hostx64\x64\link.exe /nologo src\compat\CMakeFiles\compat.dir\D_\source\repos\mpg123-1.27.0\src\compat\compat.c.obj src\compat\CMakeFiles\compat.dir\D_\source\repos\mpg123-1.27.0\src\compat\compat_str.c.obj src\libmpg123\dct36_x86_64.S.obj src\libmpg123\dct64_x86_64_float.S.obj src\libmpg123\synth_x86_64_float.S.obj src\libmpg123\synth_x86_64_s32.S.obj src\libmpg123\synth_stereo_x86_64_float.S.obj src\libmpg123\synth_stereo_x86_64_s32.S.obj src\libmpg123\dct36_avx.S.obj src\libmpg123\dct64_avx_float.S.obj src\libmpg123\synth_stereo_avx_float.S.obj src\libmpg123\synth_stereo_avx_s32.S.obj src\libmpg123\getcpuflags_x86_64.S.obj src\libmpg123\synth_x86_64_accurate.S.obj src\libmpg123\synth_stereo_x86_64_accurate.S.obj src\libmpg123\synth_stereo_avx_accurate.S.obj src\libmpg123\CMakeFiles\libmpg123.dir\D_\source\repos\mpg123-1.27.0\src\libmpg123\parse.c.obj src\libmpg123\CMakeFiles\libmpg123.dir\D_\source\repos\mpg123-1.27.0\src\libmpg123\frame.c.obj src\libmpg123\CMakeFiles\libmpg123.dir\D_\source\repos\mpg123-1.27.0\src\libmpg123\format.c.obj src\libmpg123\CMakeFiles\libmpg123.dir\D_\source\repos\mpg123-1.27.0\src\libmpg123\dct64.c.obj src\libmpg123\CMakeFiles\libmpg123.dir\D_\source\repos\mpg123-1.27.0\src\libmpg123\equalizer.c.obj src\libmpg123\CMakeFiles\libmpg123.dir\D_\source\repos\mpg123-1.27.0\src\libmpg123\id3.c.obj src\libmpg123\CMakeFiles\libmpg123.dir\D_\source\repos\mpg123-1.27.0\src\libmpg123\optimize.c.obj src\libmpg123\CMakeFiles\libmpg123.dir\D_\source\repos\mpg123-1.27.0\src\libmpg123\readers.c.obj src\libmpg123\CMakeFiles\libmpg123.dir\D_\source\repos\mpg123-1.27.0\src\libmpg123\tabinit.c.obj src\libmpg123\CMakeFiles\libmpg123.dir\D_\source\repos\mpg123-1.27.0\src\libmpg123\libmpg123.c.obj src\libmpg123\CMakeFiles\libmpg123.dir\D_\source\repos\mpg123-1.27.0\src\libmpg123\index.c.obj src\libmpg123\CMakeFiles\libmpg123.dir\D_\source\repos\mpg123-1.27.0\src\libmpg123\icy.c.obj src\libmpg123\CMakeFiles\libmpg123.dir\D_\source\repos\mpg123-1.27.0\src\libmpg123\icy2utf8.c.obj src\libmpg123\CMakeFiles\libmpg123.dir\D_\source\repos\mpg123-1.27.0\src\libmpg123\layer1.c.obj src\libmpg123\CMakeFiles\libmpg123.dir\D_\source\repos\mpg123-1.27.0\src\libmpg123\layer2.c.obj src\libmpg123\CMakeFiles\libmpg123.dir\D_\source\repos\mpg123-1.27.0\src\libmpg123\layer3.c.obj src\libmpg123\CMakeFiles\libmpg123.dir\D_\source\repos\mpg123-1.27.0\src\libmpg123\lfs_alias.c.obj src\libmpg123\CMakeFiles\libmpg123.dir\D_\source\repos\mpg123-1.27.0\src\libmpg123\ntom.c.obj src\libmpg123\CMakeFiles\libmpg123.dir\D_\source\repos\mpg123-1.27.0\src\libmpg123\synth_8bit.c.obj src\libmpg123\CMakeFiles\libmpg123.dir\D_\source\repos\mpg123-1.27.0\src\libmpg123\synth.c.obj src\libmpg123\CMakeFiles\libmpg123.dir\D_\source\repos\mpg123-1.27.0\src\libmpg123\synth_s32.c.obj src\libmpg123\CMakeFiles\libmpg123.dir\D_\source\repos\mpg123-1.27.0\src\libmpg123\synth_real.c.obj src\libmpg123\CMakeFiles\libmpg123.dir\D_\source\repos\mpg123-1.27.0\src\libmpg123\stringbuf.c.obj src\libmpg123\CMakeFiles\libmpg123.dir\D_\source\repos\mpg123-1.27.0\src\libmpg123\feature.c.obj src\libmpg123\CMakeFiles\libmpg123.dir\D_\source\repos\mpg123-1.27.0\src\libmpg123\dither.c.obj /out:src\libmpg123\mpg123.dll /implib:src\libmpg123\mpg123.lib /pdb:src\libmpg123\mpg123.pdb /dll /version:0.0 /machine:x64 /INCREMENTAL:NO shlwapi.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib && cmd.exe /C "cd /D D:\source\repos\mpg123-1.27.0\build\src\libmpg123 && "C:\Program Files\PowerShell\7\pwsh.exe" -noprofile -executionpolicy Bypass -file D:/source/repos/vcpkg/scripts/buildsystems/msbuild/applocal.ps1 -targetBinary D:/source/repos/mpg123-1.27.0/build/src/libmpg123/mpg123.dll -installedDir D:/source/repos/vcpkg/installed/x64-windows-static/bin -OutVariable out"" [build] LINK: command "C:\PROGRA~2\MICROS~1\2019\COMMUN~1\VC\Tools\MSVC\1428~1.299\bin\Hostx64\x64\link.exe /nologo src\compat\CMakeFiles\compat.dir\D_\source\repos\mpg123-1.27.0\src\compat\compat.c.obj src\compat\CMakeFiles\compat.dir\D_\source\repos\mpg123-1.27.0\src\compat\compat_str.c.obj src\libmpg123\dct36_x86_64.S.obj src\libmpg123\dct64_x86_64_float.S.obj src\libmpg123\synth_x86_64_float.S.obj src\libmpg123\synth_x86_64_s32.S.obj src\libmpg123\synth_stereo_x86_64_float.S.obj src\libmpg123\synth_stereo_x86_64_s32.S.obj src\libmpg123\dct36_avx.S.obj src\libmpg123\dct64_avx_float.S.obj src\libmpg123\synth_stereo_avx_float.S.obj src\libmpg123\synth_stereo_avx_s32.S.obj src\libmpg123\getcpuflags_x86_64.S.obj src\libmpg123\synth_x86_64_accurate.S.obj src\libmpg123\synth_stereo_x86_64_accurate.S.obj src\libmpg123\synth_stereo_avx_accurate.S.obj src\libmpg123\CMakeFiles\libmpg123.dir\D_\source\repos\mpg123-1.27.0\src\libmpg123\parse.c.obj src\libmpg123\CMakeFiles\libmpg123.dir\D_\source\repos\mpg123-1.27.0\src\libmpg123\frame.c.obj src\libmpg123\CMakeFiles\libmpg123.dir\D_\source\repos\mpg123-1.27.0\src\libmpg123\format.c.obj src\libmpg123\CMakeFiles\libmpg123.dir\D_\source\repos\mpg123-1.27.0\src\libmpg123\dct64.c.obj src\libmpg123\CMakeFiles\libmpg123.dir\D_\source\repos\mpg123-1.27.0\src\libmpg123\equalizer.c.obj src\libmpg123\CMakeFiles\libmpg123.dir\D_\source\repos\mpg123-1.27.0\src\libmpg123\id3.c.obj src\libmpg123\CMakeFiles\libmpg123.dir\D_\source\repos\mpg123-1.27.0\src\libmpg123\optimize.c.obj src\libmpg123\CMakeFiles\libmpg123.dir\D_\source\repos\mpg123-1.27.0\src\libmpg123\readers.c.obj src\libmpg123\CMakeFiles\libmpg123.dir\D_\source\repos\mpg123-1.27.0\src\libmpg123\tabinit.c.obj src\libmpg123\CMakeFiles\libmpg123.dir\D_\source\repos\mpg123-1.27.0\src\libmpg123\libmpg123.c.obj src\libmpg123\CMakeFiles\libmpg123.dir\D_\source\repos\mpg123-1.27.0\src\libmpg123\index.c.obj src\libmpg123\CMakeFiles\libmpg123.dir\D_\source\repos\mpg123-1.27.0\src\libmpg123\icy.c.obj src\libmpg123\CMakeFiles\libmpg123.dir\D_\source\repos\mpg123-1.27.0\src\libmpg123\icy2utf8.c.obj src\libmpg123\CMakeFiles\libmpg123.dir\D_\source\repos\mpg123-1.27.0\src\libmpg123\layer1.c.obj src\libmpg123\CMakeFiles\libmpg123.dir\D_\source\repos\mpg123-1.27.0\src\libmpg123\layer2.c.obj src\libmpg123\CMakeFiles\libmpg123.dir\D_\source\repos\mpg123-1.27.0\src\libmpg123\layer3.c.obj src\libmpg123\CMakeFiles\libmpg123.dir\D_\source\repos\mpg123-1.27.0\src\libmpg123\lfs_alias.c.obj src\libmpg123\CMakeFiles\libmpg123.dir\D_\source\repos\mpg123-1.27.0\src\libmpg123\ntom.c.obj src\libmpg123\CMakeFiles\libmpg123.dir\D_\source\repos\mpg123-1.27.0\src\libmpg123\synth_8bit.c.obj src\libmpg123\CMakeFiles\libmpg123.dir\D_\source\repos\mpg123-1.27.0\src\libmpg123\synth.c.obj src\libmpg123\CMakeFiles\libmpg123.dir\D_\source\repos\mpg123-1.27.0\src\libmpg123\synth_s32.c.obj src\libmpg123\CMakeFiles\libmpg123.dir\D_\source\repos\mpg123-1.27.0\src\libmpg123\synth_real.c.obj src\libmpg123\CMakeFiles\libmpg123.dir\D_\source\repos\mpg123-1.27.0\src\libmpg123\stringbuf.c.obj src\libmpg123\CMakeFiles\libmpg123.dir\D_\source\repos\mpg123-1.27.0\src\libmpg123\feature.c.obj src\libmpg123\CMakeFiles\libmpg123.dir\D_\source\repos\mpg123-1.27.0\src\libmpg123\dither.c.obj /out:src\libmpg123\mpg123.dll /implib:src\libmpg123\mpg123.lib /pdb:src\libmpg123\mpg123.pdb /dll /version:0.0 /machine:x64 /INCREMENTAL:NO shlwapi.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST /MANIFESTFILE:src\libmpg123\mpg123.dll.manifest" failed (exit code 1120) with the following output: [build] Creating library src\libmpg123\mpg123.lib and object src\libmpg123\mpg123.exp [build] lfs_alias.c.obj : error LNK2019: unresolved external symbol mpg123_open_fixed referenced in function mpg123_open_fixed_32 [build] lfs_alias.c.obj : error LNK2019: unresolved external symbol mpg123_open referenced in function mpg123_open_32 [build] lfs_alias.c.obj : error LNK2019: unresolved external symbol mpg123_open_fd referenced in function mpg123_open_fd_32 [build] lfs_alias.c.obj : error LNK2019: unresolved external symbol mpg123_open_handle referenced in function mpg123_open_handle_32 [build] lfs_alias.c.obj : error LNK2019: unresolved external symbol mpg123_decode_frame referenced in function mpg123_decode_frame_32 [build] lfs_alias.c.obj : error LNK2019: unresolved external symbol mpg123_framebyframe_decode referenced in function mpg123_framebyframe_decode_32 [build] lfs_alias.c.obj : error LNK2019: unresolved external symbol mpg123_framepos referenced in function mpg123_framepos_32 [build] lfs_alias.c.obj : error LNK2019: unresolved external symbol mpg123_tell referenced in function mpg123_tell_32 [build] lfs_alias.c.obj : error LNK2019: unresolved external symbol mpg123_tellframe referenced in function mpg123_tellframe_32 [build] lfs_alias.c.obj : error LNK2019: unresolved external symbol mpg123_tell_stream referenced in function mpg123_tell_stream_32 [build] lfs_alias.c.obj : error LNK2019: unresolved external symbol mpg123_seek referenced in function mpg123_seek_32 [build] lfs_alias.c.obj : error LNK2019: unresolved external symbol mpg123_feedseek referenced in function mpg123_feedseek_32 [build] lfs_alias.c.obj : error LNK2019: unresolved external symbol mpg123_seek_frame referenced in function mpg123_seek_frame_32 [build] lfs_alias.c.obj : error LNK2019: unresolved external symbol mpg123_timeframe referenced in function mpg123_timeframe_32 [build] lfs_alias.c.obj : error LNK2019: unresolved external symbol mpg123_index referenced in function mpg123_index_32 [build] lfs_alias.c.obj : error LNK2019: unresolved external symbol mpg123_set_index referenced in function mpg123_set_index_32 [build] lfs_alias.c.obj : error LNK2019: unresolved external symbol mpg123_position referenced in function mpg123_position_32 [build] lfs_alias.c.obj : error LNK2019: unresolved external symbol mpg123_framelength referenced in function mpg123_framelength_32 [build] lfs_alias.c.obj : error LNK2019: unresolved external symbol mpg123_length referenced in function mpg123_length_32 [build] lfs_alias.c.obj : error LNK2019: unresolved external symbol mpg123_set_filesize referenced in function mpg123_set_filesize_32 [build] lfs_alias.c.obj : error LNK2019: unresolved external symbol mpg123_replace_reader referenced in function mpg123_replace_reader_32 [build] lfs_alias.c.obj : error LNK2019: unresolved external symbol mpg123_replace_reader_handle referenced in function mpg123_replace_reader_handle_32 [build] src\libmpg123\mpg123.dll : fatal error LNK1120: 22 unresolved externals [build] ninja: build stopped: subcommand failed. [build] Build finished with exit code 1
Actually … it's the non-suffixed symbols not being exported and they are missed by the alias functions.
This is a 32 bit build, right?
Ah … you showed two differing cases. Yeas, definitely something off with LFS handling.
Last edit: Thomas Orgis 2021-05-29
No, it is x64 build.
In attached CMakeCache.txt:
CMAKE_C_COMPILER:FILEPATH=C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.28.29910/bin/Hostx64/x64/cl.exe
Also … looking at your CI stuff … seems like a lot is broken right now. The ARM build wants to include dct64_x86_64.S?! Where do we start?
Because MACHINE is detected as amd64.
As i said before in #298,
CMAKE_SYSTEM_PROCESSOR
check is not good way to detect target processor architecture.I don't remember getting a proper alternative to querying the processor. Can you specify this when calling cmake like giving --host/--target to autoconf? Do we need another manual override?
Addendum: Do you know how serious Microsoft is with warnings/misunderstandings like these?
The code in question passes a negated uint64_t into an int64_t argument … seemed fine so far?
If code is correct just ignore that. We had ~1000 warnings in libsndfile like "blah-blah, conversion from type to another type, presicion may be lost".
If you want to feel the pain add
-Wconversion
to gcc.Ah, yeah, there is a reason why it is not part of
-Wall
. Got it.x86 build fails faster with:
Note that deleted Visual Studio solution exports these symbols.
On Windows platform you can skip all these
off_t
and_FILE_OFFSET_BITS
checks, it is useless, just assume 64-bit offsets are supported by default. Windows has non-standard extensions fro that:_fseeki64
,_ftelli64
and company. Note that they don't useoff_t
which is always 32-bit.So at least on Linux/x64, I get the alias symbols:
Your manual build seems confused. I see this in CMakeCache.txt:
So … which one is it? My cache has one of them set t o 1. You need
LFS_SENSITIVE
being true to include the wrapper functions (see ports/cmake/src/libmpg123/CMakeLists.txt). And where is your?
Why not?
First
LFS_INSENSITIVE
fails becauseoff_t
is 32-bit on Windows. Than secondLFS_SENSITIVE
test fails because it is the same test with_FILE_OFFSET_BITS=64
set. But this define is ignored,off_t
is still 32-bit.OK, about the large file support: You are saying that with MSVC
So that is a different mode than what you get in a mingw environment, I suppose.
The whole trouble only arises because I had off_t creep into the API. And normally, that type varies depending on build setup. If we say the platform (MSVC build) adheres to the above 2 points, I'd actually have to modify the API to take int64_t, always?
We might have a look at what the old MSVC port did. But I imagine that it just disabled all largefile stuff. It also used the mpg123.h.in in a wrapping.
Maybe we're fine with just inserting
in the header? I think this effects to what the MSVC build did. It defined
MPG123_NO_CONFIGURE
, which also skipped the largename stuff. The libmpg123 build itself should useNO_LFS_ALIAS
and falseLFS_SENSITIVE
, then.It would just not support large files, then, which is not that big a deal. A second step would be to add a MSVC mode to libmpg123 so that it does use the i64 functions internally and offers API with int64_t and 32 bit off_t, mirroring quite exactly what it does now on Unix and mingw.
If i add
MPG123_NO_LARGENAME
x64 build now fails with the same error as x86:That looks like progress;-) This seems to be a logic issue in src/libout123/modules/win32_wasapi.c, then. JonY last updated it in mingw where we do our official Windows binaries. The branch with
_MSC_VER
needs fixing.Btw, this is the old envelope over mpg123.h: http://scm.orgis.org/view/mpg123/tags/1.26.5/ports/MSVC%2B%2B/mpg123.h?view=markup
This includes
mpg123_topen()
andmpg123_tclose()
prototypes. They are defined inhttp://scm.orgis.org/view/mpg123/tags/1.26.5/ports/MSVC%2B%2B/msvc.c?view=markup
We forgot that stuff for an actual MSVC build. Well, the latter is not essential, I presume … things should work via UTF8 arguments … but you might prefer that.
I cannot help you much with that, as I don't work in MSVC and couldn't test anything. I can give pointers. We could intergrate the msvc.c back into the codebase and have the cmake build reference it inside MSVC, well just like the project file did before.
The wrapping of the header could be avoided by some more .in replacing, I guess.
(Btw:
LFS_INSENSITIVE
failing because off_t is always 32 bit … I'd assume that is being insensitive, exactly. So the build should proceed without wrappers and without alias, it needs NO_LFS_ALIAS defined for CMake)Completly untested fix for
'mpg123_PKEY_Device_FriendlyName': undeclared identifier
:Now i have:
😄
We're getting closer. I activated JonY, who does the Windows stuff (mingw). We're on it … hopefully we get this settled together.
Those symbols are in src/compat/compat.c, are those compiled in MSVC?
Edit: those are in src/compat/compat_str.c not compat.c.
Last edit: Jonathan Yong 2021-05-29
I just checked in the macro fix for src/libout123/modules/win32_wasapi.c into trunk, can you test that out?
I'm testing it right now
Each
add_library()
for an output module inports/cmake/src/libout123/modules/CMakeLists.txt
needs$<TARGET_OBJECTS:compat_str>
to get the win32 string functions. Well, most don't need it, but the windows ones do.You could of course disable modules and have only one audio API built into libout123. Then also the str functions should be there.