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

Does not compile under MSVC #91

Closed
neheb opened this issue Dec 31, 2021 · 13 comments
Closed

Does not compile under MSVC #91

neheb opened this issue Dec 31, 2021 · 13 comments

Comments

@neheb
Copy link
Contributor

neheb commented Dec 31, 2021

When linking against libmatroska, linking errors occur:

src_KaxTracks.cpp.obj : error LNK2001: unresolved external symbol "protected: static unsigned __int64 const libebml::EbmlDate::UnixEpochDelay" (?UnixEpochDelay@EbmlDate@libebml@@1_KB)
src_KaxInfoData.cpp.obj : error LNK2001: unresolved external symbol "protected: static unsigned __int64 const libebml::EbmlDate::UnixEpochDelay" (?UnixEpochDelay@EbmlDate@libebml@@1_KB)
src_KaxSeekHead.cpp.obj : error LNK2001: unresolved external symbol "protected: static unsigned __int64 const libebml::EbmlDate::UnixEpochDelay" (?UnixEpochDelay@EbmlDate@libebml@@1_KB)
src_KaxSegment.cpp.obj : error LNK2001: unresolved external symbol "protected: static unsigned __int64 const libebml::EbmlDate::UnixEpochDelay" (?UnixEpochDelay@EbmlDate@libebml@@1_KB)
src_KaxSemantic.cpp.obj : error LNK2001: unresolved external symbol "protected: static unsigned __int64 const libebml::EbmlDate::UnixEpochDelay" (?UnixEpochDelay@EbmlDate@libebml@@1_KB)
src_KaxCluster.cpp.obj : error LNK2001: unresolved external symbol "protected: static unsigned __int64 const libebml::EbmlDate::UnixEpochDelay" (?UnixEpochDelay@EbmlDate@libebml@@1_KB)
src_KaxContexts.cpp.obj : error LNK2001: unresolved external symbol "protected: static unsigned __int64 const libebml::EbmlDate::UnixEpochDelay" (?UnixEpochDelay@EbmlDate@libebml@@1_KB)
src_KaxCues.cpp.obj : error LNK2001: unresolved external symbol "protected: static unsigned __int64 const libebml::EbmlDate::UnixEpochDelay" (?UnixEpochDelay@EbmlDate@libebml@@1_KB)
src_KaxCuesData.cpp.obj : error LNK2001: unresolved external symbol "protected: static unsigned __int64 const libebml::EbmlDate::UnixEpochDelay" (?UnixEpochDelay@EbmlDate@libebml@@1_KB)
src_KaxAttached.cpp.obj : error LNK2001: unresolved external symbol "protected: static unsigned __int64 const libebml::EbmlDate::UnixEpochDelay" (?UnixEpochDelay@EbmlDate@libebml@@1_KB)
src_KaxAttachments.cpp.obj : error LNK2001: unresolved external symbol "protected: static unsigned __int64 const libebml::EbmlDate::UnixEpochDelay" (?UnixEpochDelay@EbmlDate@libebml@@1_KB)
src_KaxBlock.cpp.obj : error LNK2001: unresolved external symbol "protected: static unsigned __int64 const libebml::EbmlDate::UnixEpochDelay" (?UnixEpochDelay@EbmlDate@libebml@@1_KB)
src_KaxBlockData.cpp.obj : error LNK2001: unresolved external symbol "protected: static unsigned __int64 const libebml::EbmlDate::UnixEpochDelay" (?UnixEpochDelay@EbmlDate@libebml@@1_KB)
src_KaxTracks.cpp.obj : error LNK2001: unresolved external symbol "public: static class libebml::EbmlCallbacks const libebml::EbmlCrc32::ClassInfos" (?ClassInfos@EbmlCrc32@libebml@@2VEbmlCallbacks@2@B)
src_KaxInfoData.cpp.obj : error LNK2001: unresolved external symbol "public: static class libebml::EbmlCallbacks const libebml::EbmlCrc32::ClassInfos" (?ClassInfos@EbmlCrc32@libebml@@2VEbmlCallbacks@2@B)
src_KaxSeekHead.cpp.obj : error LNK2001: unresolved external symbol "public: static class libebml::EbmlCallbacks const libebml::EbmlCrc32::ClassInfos" (?ClassInfos@EbmlCrc32@libebml@@2VEbmlCallbacks@2@B)
src_KaxSegment.cpp.obj : error LNK2001: unresolved external symbol "public: static class libebml::EbmlCallbacks const libebml::EbmlCrc32::ClassInfos" (?ClassInfos@EbmlCrc32@libebml@@2VEbmlCallbacks@2@B)
src_KaxSemantic.cpp.obj : error LNK2001: unresolved external symbol "public: static class libebml::EbmlCallbacks const libebml::EbmlCrc32::ClassInfos" (?ClassInfos@EbmlCrc32@libebml@@2VEbmlCallbacks@2@B)
src_KaxCluster.cpp.obj : error LNK2001: unresolved external symbol "public: static class libebml::EbmlCallbacks const libebml::EbmlCrc32::ClassInfos" (?ClassInfos@EbmlCrc32@libebml@@2VEbmlCallbacks@2@B)
src_KaxContexts.cpp.obj : error LNK2001: unresolved external symbol "public: static class libebml::EbmlCallbacks const libebml::EbmlCrc32::ClassInfos" (?ClassInfos@EbmlCrc32@libebml@@2VEbmlCallbacks@2@B)
src_KaxCues.cpp.obj : error LNK2001: unresolved external symbol "public: static class libebml::EbmlCallbacks const libebml::EbmlCrc32::ClassInfos" (?ClassInfos@EbmlCrc32@libebml@@2VEbmlCallbacks@2@B)
src_KaxCuesData.cpp.obj : error LNK2001: unresolved external symbol "public: static class libebml::EbmlCallbacks const libebml::EbmlCrc32::ClassInfos" (?ClassInfos@EbmlCrc32@libebml@@2VEbmlCallbacks@2@B)
src_KaxAttached.cpp.obj : error LNK2001: unresolved external symbol "public: static class libebml::EbmlCallbacks const libebml::EbmlCrc32::ClassInfos" (?ClassInfos@EbmlCrc32@libebml@@2VEbmlCallbacks@2@B)
src_KaxAttachments.cpp.obj : error LNK2001: unresolved external symbol "public: static class libebml::EbmlCallbacks const libebml::EbmlCrc32::ClassInfos" (?ClassInfos@EbmlCrc32@libebml@@2VEbmlCallbacks@2@B)
src_KaxBlock.cpp.obj : error LNK2001: unresolved external symbol "public: static class libebml::EbmlCallbacks const libebml::EbmlCrc32::ClassInfos" (?ClassInfos@EbmlCrc32@libebml@@2VEbmlCallbacks@2@B)
src_KaxBlockData.cpp.obj : error LNK2001: unresolved external symbol "public: static class libebml::EbmlCallbacks const libebml::EbmlCrc32::ClassInfos" (?ClassInfos@EbmlCrc32@libebml@@2VEbmlCallbacks@2@B)
src_KaxContexts.cpp.obj : error LNK2001: unresolved external symbol "public: static class libebml::EbmlCallbacks const libebml::EbmlHead::ClassInfos" (?ClassInfos@EbmlHead@libebml@@2VEbmlCallbacks@2@B)
src_KaxSegment.cpp.obj : error LNK2001: unresolved external symbol "public: static class libebml::EbmlCallbacks const libebml::EbmlHead::ClassInfos" (?ClassInfos@EbmlHead@libebml@@2VEbmlCallbacks@2@B)
subprojects\libmatroska-release-1.6.3\libmatroska.dll : fatal error LNK1120: 3 unresolved externals

for UnixEpochDelay, defining it directly fixes the error. I'm not sure about the others.

@robUx4
Copy link
Contributor

robUx4 commented Jan 2, 2022

These are all "global variables" or rather class static variables. Are you building as libebml/libmatroska as a DLLs or static libraries ? AFAIK it's not possible in a clean way to share global variables between DLLs on Windows.

mkvtoolnix and VLC use libebml and libmatroska as static libraries on Windows so they don't have this problem. Our CMake build file system also uses a static library by default on Windows and when compiled with BUILD_SHARED_LIBS set these static variables are not exported, even when using EBML_DLL_API in their definition.

@neheb
Copy link
Contributor Author

neheb commented Jan 2, 2022

shared lib, aka dll. I’ll try static.

@neheb
Copy link
Contributor Author

neheb commented Jan 2, 2022

Partial fix: #94

@neheb
Copy link
Contributor Author

neheb commented Jan 2, 2022

static compilation works.

@robUx4
Copy link
Contributor

robUx4 commented Jan 9, 2022

Does #94 fix the whole DLL issue ? It seems the EbmlCrc32::ClassInfos is defined by DEFINE_EBML_CLASS_GLOBAL.

EbmlVoid is also defined that way so it should have the same problem (when compiling the test samples).

We could also move these lines in the header files, as in #94 and hopefully that would fix the issue

DEFINE_EBML_CLASS_GLOBAL(EbmlCrc32, 0xBF, 1, "EBMLCrc32\0ratamadabapa")
DEFINE_EBML_CLASS_GLOBAL(EbmlVoid, 0xEC, 1, "EBMLVoid")

@neheb
Copy link
Contributor Author

neheb commented Jan 9, 2022

#94 is only a partial fix.

@neheb
Copy link
Contributor Author

neheb commented Mar 21, 2022

@robUx4 fun MSVC issue now...

 Found ninja-1.10.2 at "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE\CommonExtensions\Microsoft\CMake\Ninja\ninja.EXE"
WARNING: msvc does not support C++11; attempting best effort; setting the standard to C++14

I guess libebml should be bumped to C++14 now.

@neheb
Copy link
Contributor Author

neheb commented Jun 25, 2022

Through some unexplained reason, this no longer fails. Closing.

@neheb neheb closed this as completed Jun 25, 2022
@neheb
Copy link
Contributor Author

neheb commented Jun 25, 2022

never mind

@neheb neheb reopened this Jun 25, 2022
@neheb
Copy link
Contributor Author

neheb commented Sep 29, 2022

I think the issue is me not implementing hidden visibility properly. I can't reproduce this after fixing.

@neheb neheb closed this as completed Sep 29, 2022
@neheb neheb reopened this Sep 30, 2022
@neheb
Copy link
Contributor Author

neheb commented Sep 30, 2022

Thought MinGW not having issues indicates MSVC would not have issues.

@robUx4
Copy link
Contributor

robUx4 commented Oct 2, 2022

It does build under MSVC as you can see here https://github.com/Matroska-Org/libebml/actions/workflows/windows.yaml
This is only testing static library though.

@robUx4
Copy link
Contributor

robUx4 commented Oct 8, 2022

Fully tested and working after Matroska-Org/libmatroska#79

@robUx4 robUx4 closed this as completed Oct 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants