Comments (11)
Chiming in since I narrowed it down to this commit in the bug report mentioned above...
I'll admit I'm also a little lost on mingw specifics, but mingw-w64 gcc supports a -municode
option (gcc docs) that properly defines the UNICODE (and other) preprocessor macros and uses the correct startup code (that supports unicode) when linking. I tested this with a rudimentary patch that added -municode
to the linker args only for avifdec/enc and it did allow them to link successfully. I have not run any tests against the resulting binaries at this time to check unicode input is functional, though. Compiling with MSVC likely doesn't need any of this, since it seems to be a mingw target specific issue.
Below is my rudimentary patch. The conditional should probably be modified to only apply to a mingw-w64 target since gcc docs mention it's the only target that supports -municode
(and I have no idea what, if anything, can be done for mingw-w32 targets). I also just used PUBLIC for target_link_options
for testing purposes, but can/should probably be changed as well. There may be a better way to fix this, but I don't know libavif nor mingw-w64 well enough to suggest alternatives.
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9d28ae3..a47eec0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -793,6 +793,10 @@ if(AVIF_BUILD_APPS)
set_target_properties(avifdec PROPERTIES LINKER_LANGUAGE "CXX")
endif()
target_link_libraries(avifdec avif_apps)
+ if(WIN32 AND MINGW)
+ target_link_options(avifenc PUBLIC "SHELL:-municode")
+ target_link_options(avifdec PUBLIC "SHELL:-municode")
+ endif()
if(NOT SKIP_INSTALL_APPS AND NOT SKIP_INSTALL_ALL)
install(
from libavif.
If we use the -municode
solution, we should also add -DUNICODE
and possibly also -D_UNICODE
for all compilers on Windows, so that all compilers on Windows define the UNICODE
macro when compiling libavif.
from libavif.
basically :
- if only wmain() is used (no other unicode version of functions) :
-municode
is sufficient - if unicode version of functions are used (like CreateFile, which would be replaced with CreateFileW), -DUNICODE should be passed to the compiler
if I'm not mistaken, the commit only uses wmain() explicitely and convert argv to UTF8 with WideCharToMultiByte(), so -municode
should be sufficient, and works for me btw. But passing -DUNICODE and -D_UNICODE will not hurt and will avoid possible future errors if unicode version of functions are wanted (unless you explicitely use the unicode version, like CreateFileW() instead of just CreateFile())
from libavif.
Vincent: Could you take a look at this? Thanks.
LigH: I am not familiar with MSYS2/MinGW. The current main branch of libavif uses wmain()
instead of main()
as the starting point of the avifdec.c, avifenc.c, and are_images_equal.cc programs on Windows so that we can receive the command-line arguments as wchar_t
strings. It is common to do this in Windows applications, so there must be a way to build this kind of program in MSYS2/MinGW. Do you know what the trick is? Thanks.
from libavif.
Unfortunately, I am not at all a C/C++ developer. Just a halfwit running the script and interpreting error messages. But the MABS team has a good amount of experience, too...
from libavif.
Note that you don't need "WIN32 AND MINGW", checking for MINGW is sufficient (implies WIN32).
from libavif.
Hi, we are actually trying something simpler to deal with UTF8 and it reverts the commit you are mentioning: does #1752 work for you? Thx
from libavif.
Hi, we are actually trying something simpler to deal with UTF8 and it reverts the commit you are mentioning: does #1752 work for you? Thx
Unfortunately not, since mt.exe is only provided by the Windows SDK (which may not be installed or in the path) and there doesn't seem to be an equivalent in msys/mingw.
from libavif.
maybe more informations here : https://sourceforge.net/p/mingw-w64/wiki2/Unicode%20apps/
from libavif.
and to finish : visual studio solutions sets unicode by default
from libavif.
Thx for the pointers. Would #1802 work for MINGW then ?
from libavif.
Related Issues (20)
- Sample HDR AVIF decoded to JPG shows incorrect colors HOT 8
- How to build a dynamic library that statically links all dependencies? HOT 1
- Ignore and skip FullBoxes with an unrecognized version
- How to build the.A use of iOS platform? HOT 2
- Make libyuv package-friendly dependency HOT 2
- Roll YCgCo-R out HOT 1
- Add Homebrew install instructions and avifdec/avifenc examples to README HOT 6
- autoconf etc. HOT 1
- avifImageRGBToYUV should set color space to default values HOT 2
- Findrav1e.cmake ignores library dependencies listed in the generated pkgconfig file HOT 5
- [Function Request] avifenc supports svt and rav1e encoder options key-value HOT 2
- MSYS/MinGW32: Linking error, undefined references to Nt file functions HOT 2
- Noticeable color shift HOT 6
- Does CVE-2024-1580 affect libavif with dav1d decoder? HOT 1
- Static build issues on MSYS2 HOT 4
- sharpyuv conversion failed HOT 2
- libavif.a should not be a combined archive library HOT 6
- Not able to build static build on amazon linux 2023 HOT 9
- GIF encodes with wrong frame rate HOT 14
- Avif-alpha is working as expected HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from libavif.