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

Failing to build shared libraries on Windows #80

Open
irieger opened this issue Jun 16, 2024 · 2 comments
Open

Failing to build shared libraries on Windows #80

irieger opened this issue Jun 16, 2024 · 2 comments

Comments

@irieger
Copy link
Contributor

irieger commented Jun 16, 2024

Hey,

while working the conan recipe to integrate bmx into the offical conan recipe repository (conan-io/conan-center-index#23955), the CI discovered a problem when trying to build as a shared library for Windows. At first it tried to link a non-existing MXF.lib. After some reading and trying - I normally work only on Linux and macOS - I now got a bit further. As I learned, for Windows symbols need a manual export. So I found that it could be done with a CMake property with. Without that, the required lib would not be created:

set_target_properties(MXF PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE)

With that set for all three libraries, the MXF.lib gets created, but linking fails with:

...
  TextBasedObjectBase.cpp
  TextLocatorBase.cpp
  TimecodeComponentBase.cpp
  TrackBase.cpp
  UTF16TextBasedSetBase.cpp
  UTF8TextBasedSetBase.cpp
  VBIDataDescriptorBase.cpp
  VC2SubDescriptorBase.cpp
  WaveAudioDescriptorBase.cpp
  Auto build dll exports
     Creating library C:/Users/ingmar/.conan2/p/b/bmxac2fb25ee2e96/b/build/_deps/libmxfpp-build/libMXF++/Release/MXF++.
  lib and object C:/Users/ingmar/.conan2/p/b/bmxac2fb25ee2e96/b/build/_deps/libmxfpp-build/libMXF++/Release/MXF++.exp
HeaderMetadata.obj : error LNK2019: unresolved external symbol mxf_get_version referenced in function "public: static s
truct mxfProductVersion __cdecl mxfpp::HeaderMetadata::getToolkitVersion(void)" (?getToolkitVersion@HeaderMetadata@mxfp
p@@SA?AUmxfProductVersion@@XZ) [C:\Users\ingmar\.conan2\p\b\bmxac2fb25ee2e96\b\build\_deps\libmxfpp-build\libMXF++\MXFp
p.vcxproj]
HeaderMetadata.obj : error LNK2019: unresolved external symbol mxf_get_platform_string referenced in function "public:
static class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl mxfpp::HeaderMet
adata::getPlatform(void)" (?getPlatform@HeaderMetadata@mxfpp@@SA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D
@2@@std@@XZ) [C:\Users\ingmar\.conan2\p\b\bmxac2fb25ee2e96\b\build\_deps\libmxfpp-build\libMXF++\MXFpp.vcxproj]
HeaderMetadata.obj : error LNK2019: unresolved external symbol mxf_log referenced in function "public: class mxfpp::Met
adataSet * __cdecl mxfpp::HeaderMetadata::wrap(struct MXFMetadataSet *)" (?wrap@HeaderMetadata@mxfpp@@QEAAPEAVMetadataS
et@2@PEAUMXFMetadataSet@@@Z) [C:\Users\ingmar\.conan2\p\b\bmxac2fb25ee2e96\b\build\_deps\libmxfpp-build\libMXF++\MXFpp.
vcxproj]
Identification.obj : error LNK2019: unresolved external symbol mxf_generate_uuid referenced in function "public: void _
_cdecl mxfpp::Identification::initialise(class std::basic_string<char,struct std::char_traits<char>,class std::allocato
r<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_stri
ng<char,struct std::char_traits<char>,class std::allocator<char> >,struct mxfUUID)" (?initialise@Identification@mxfpp@@
QEAAXV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@00UmxfUUID@@@Z) [C:\Users\ingmar\.conan2\p\b\bmxac2f
b25ee2e96\b\build\_deps\libmxfpp-build\libMXF++\MXFpp.vcxproj]
Identification.obj : error LNK2019: unresolved external symbol mxf_get_timestamp_now referenced in function "public: vo
id __cdecl mxfpp::Identification::initialise(class std::basic_string<char,struct std::char_traits<char>,class std::allo
cator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_
string<char,struct std::char_traits<char>,class std::allocator<char> >,struct mxfUUID)" (?initialise@Identification@mxf
pp@@QEAAXV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@00UmxfUUID@@@Z) [C:\Users\ingmar\.conan2\p\b\bmx
ac2fb25ee2e96\b\build\_deps\libmxfpp-build\libMXF++\MXFpp.vcxproj]
C:\Users\ingmar\.conan2\p\b\bmxac2fb25ee2e96\b\build\_deps\libmxfpp-build\libMXF++\Release\MXF++.dll : fatal error LNK1
120: 5 unresolved externals [C:\Users\ingmar\.conan2\p\b\bmxac2fb25ee2e96\b\build\_deps\libmxfpp-build\libMXF++\MXFpp.v
cxproj]
  Building Custom Rule C:/Users/ingmar/.conan2/p/b/bmxac2fb25ee2e96/b/src/test/CMakeLists.txt
  create_test_essence.cpp
  create_test_essence.vcxproj -> C:\Users\ingmar\.conan2\p\b\bmxac2fb25ee2e96\b\build\test\Release\create_test_essence.
  exe
  Building Custom Rule C:/Users/ingmar/.conan2/p/b/bmxac2fb25ee2e96/b/src/test/CMakeLists.txt
  file_truncate.cpp
  file_truncate.vcxproj -> C:\Users\ingmar\.conan2\p\b\bmxac2fb25ee2e96\b\build\test\Release\file_truncate.exe
  Building Custom Rule C:/Users/ingmar/.conan2/p/b/bmxac2fb25ee2e96/b/src/deps/libMXFpp/tools/gen_classes/CMakeLists.tx
  t
  gen_metadata_classes.cpp
  gen_classes.vcxproj -> C:\Users\ingmar\.conan2\p\b\bmxac2fb25ee2e96\b\build\_deps\libmxfpp-build\tools\gen_classes\Re
  lease\gen_classes.exe
  Building Custom Rule C:/Users/ingmar/.conan2/p/b/bmxac2fb25ee2e96/b/src/tools/CMakeLists.txt
  h264dump.c
  h264dump.vcxproj -> C:\Users\ingmar\.conan2\p\b\bmxac2fb25ee2e96\b\build\tools\Release\h264dump.exe
  Building Custom Rule C:/Users/ingmar/.conan2/p/b/bmxac2fb25ee2e96/b/src/tools/CMakeLists.txt
  j2cdump.c
  j2cdump.vcxproj -> C:\Users\ingmar\.conan2\p\b\bmxac2fb25ee2e96\b\build\tools\Release\j2cdump.exe
  Building Custom Rule C:/Users/ingmar/.conan2/p/b/bmxac2fb25ee2e96/b/src/tools/CMakeLists.txt
  jp2extract.c
  jp2extract.vcxproj -> C:\Users\ingmar\.conan2\p\b\bmxac2fb25ee2e96\b\build\tools\Release\jp2extract.exe
  Building Custom Rule C:/Users/ingmar/.conan2/p/b/bmxac2fb25ee2e96/b/src/tools/CMakeLists.txt
  movdump.cpp
  movdump.vcxproj -> C:\Users\ingmar\.conan2\p\b\bmxac2fb25ee2e96\b\build\tools\Release\movdump.exe
  Building Custom Rule C:/Users/ingmar/.conan2/p/b/bmxac2fb25ee2e96/b/src/tools/CMakeLists.txt
  rdd36dump.c
  rdd36dump.vcxproj -> C:\Users\ingmar\.conan2\p\b\bmxac2fb25ee2e96\b\build\tools\Release\rdd36dump.exe
  Building Custom Rule C:/Users/ingmar/.conan2/p/b/bmxac2fb25ee2e96/b/src/deps/libMXF/test/CMakeLists.txt
  test_datamodel.c
  test_datamodel.vcxproj -> C:\Users\ingmar\.conan2\p\b\bmxac2fb25ee2e96\b\build\_deps\libmxf-build\test\Release\test_d
  atamodel.exe
  Building Custom Rule C:/Users/ingmar/.conan2/p/b/bmxac2fb25ee2e96/b/src/deps/libMXF/test/CMakeLists.txt
  test_essencecontainer.c
  test_essencecontainer.vcxproj -> C:\Users\ingmar\.conan2\p\b\bmxac2fb25ee2e96\b\build\_deps\libmxf-build\test\Release
  \test_essencecontainer.exe
  Building Custom Rule C:/Users/ingmar/.conan2/p/b/bmxac2fb25ee2e96/b/src/deps/libMXF/test/CMakeLists.txt
  test_file.c
  test_file.vcxproj -> C:\Users\ingmar\.conan2\p\b\bmxac2fb25ee2e96\b\build\_deps\libmxf-build\test\Release\test_file.e
  xe
  Building Custom Rule C:/Users/ingmar/.conan2/p/b/bmxac2fb25ee2e96/b/src/deps/libMXF/test/CMakeLists.txt
  test_headermetadata.c
test_headermetadata.obj : error LNK2019: unresolved external symbol mxf_get_version referenced in function test_create_
and_write [C:\Users\ingmar\.conan2\p\b\bmxac2fb25ee2e96\b\build\_deps\libmxf-build\test\test_headermetadata.vcxproj]
C:\Users\ingmar\.conan2\p\b\bmxac2fb25ee2e96\b\build\_deps\libmxf-build\test\Release\test_headermetadata.exe : fatal er
ror LNK1120: 1 unresolved externals [C:\Users\ingmar\.conan2\p\b\bmxac2fb25ee2e96\b\build\_deps\libmxf-build\test\test_
headermetadata.vcxproj]
  Building Custom Rule C:/Users/ingmar/.conan2/p/b/bmxac2fb25ee2e96/b/src/deps/libMXF/test/CMakeLists.txt
  test_indextable.c
test_indextable.obj : error LNK2019: unresolved external symbol mxf_generate_uuid referenced in function test_create_an
d_write [C:\Users\ingmar\.conan2\p\b\bmxac2fb25ee2e96\b\build\_deps\libmxf-build\test\test_indextable.vcxproj]
C:\Users\ingmar\.conan2\p\b\bmxac2fb25ee2e96\b\build\_deps\libmxf-build\test\Release\test_indextable.exe : fatal error
LNK1120: 1 unresolved externals [C:\Users\ingmar\.conan2\p\b\bmxac2fb25ee2e96\b\build\_deps\libmxf-build\test\test_inde
xtable.vcxproj]
  Building Custom Rule C:/Users/ingmar/.conan2/p/b/bmxac2fb25ee2e96/b/src/deps/libMXF/test/CMakeLists.txt
  test_mxf_cache_file.c
...

As said, I have no clue about Windos peculiarities so maybe it is just a simple thing. For now I changed the Conan recipe to not build shared on Windows.

@philipnbbc
Copy link
Collaborator

Thanks for reporting this and your work to add bmx to Conan!

I don't think bmx has ever had working dynamic link libraries on Windows. I remember trying a couple things when moving over to cmake and I couldn't get it to work. Curious why those particular symbols shown in your build log could not be found. This is something to look at again in future but probably not soon.

@irieger
Copy link
Contributor Author

irieger commented Jun 18, 2024

You're welcome. I have to thank you for the work. The few issue and PR discussion I had so far felt very productive and welcoming.

For now we decided to go with throwing an invalid configuration for shared library build requests to the conan system for bmx which I think is fair for now. That is the usual way in Conan to mark an option not supported based on the configuration (combination of profile settings (OS, compiler etc.) and options the user can select like the shared option, or building with or without CURL for example.

I fully understand that you focus on a real workhorse system. I'm doing the Conan stuff for a side project of mine and there I'm so happy that I decide which platforms to target and only build on Linux and macOS for now which to me feel more natural to develop for. But I admit I'm having a strong opionion on that one popular spyware so many people use. Just wasn't sure if the shared building problem is known. Wasn't it for the conan CI I might have not discovered it.

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

2 participants