Comments (10)
I see. Thank you for the reproducer!
Unfortunately, the obvious fix of using #ifndef _WIN32
instead of #ifndef _MSC_VER
breaks linking other programs:
libbit7z64_d.a(bufferextractcallback.cpp.obj):bufferextractcallback.cpp:(.rdata$.refptr.IID_IUnknown[.refptr.IID_IUnknown]+0x0): undefined reference to `IID_IUnknown'
collect2.exe: error: ld returned 1 exit status
I remember fixing this exact issue some years ago (24706ff), but that same fix is causing your issue.
So I'll need to come up with a better fix.
Thank you again for reporting this!
from bit7z.
I just pushed a fix to the branch hotfix/v4.0.6
.
Basically, bit7z now defines IID_IUnknown
inside a #ifndef _WIN32
condition, and more importantly, the CMakeLists.txt
conditionally specifies the uuid
library as a link dependency of bit7z, i.e.,
if( MINGW )
target_link_libraries( ${LIB_TARGET} PUBLIC uuid )
endif()
This way, a project using bit7z will link against uuid
, which will provide the (only) definition of IID_IUnknown
.
from bit7z.
Released on v4.0.6
.
from bit7z.
This fixes the issue for me.
File guids.hpp
#ifndef _MSC_VER
+#ifndef __MINGW32__
extern const GUID IID_IUnknown;
+#endif
#endif
File guids.cpp
#ifndef _MSC_VER
+#ifndef __MINGW32__
const GUID IID_IUnknown = {
0x00000000, 0x0000, 0x0000, { 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46 }
};
+#endif
#endif
from bit7z.
Hi!
This is actually quite strange, as I cannot replicate the issue:
cmake_minimum_required( VERSION 3.28 )
project( test_uuid_mingw )
set( CMAKE_CXX_STANDARD 17 )
add_executable( test_uuid_mingw main.cpp )
include( cmake/Dependencies.cmake )
CPMAddPackage(
NAME bit7z
GIT_REPOSITORY "https://github.com/rikyoz/bit7z.git"
GIT_TAG master
OPTIONS
"BIT7Z_BUILD_TESTS false"
"BIT7Z_BUILD_DOCS false"
)
target_link_libraries(${PROJECT_NAME} PRIVATE bit7z)
- CMake output:
-- CPM: Adding package bit7z@ (master)
-- Standard filesystem: NO (using ghc::filesystem)
-- Target Version:
-- Compiler ID: GNU
-- Compiler Version: 13.1.0
-- Architecture: x64
-- Build Type: Debug
-- Language Standard for bit7z: C++14
-- Auto format detection: OFF
-- Regex matching extraction: OFF
-- Use std::byte: OFF
-- Use native string: OFF
-- Generate Position Independent Code: OFF
-- Disable Zip ASCII password check: OFF
-- Disable using std::filesystem: OFF
-- 7-zip version: 23.01
-- Build tests: false
-- Build docs: false
-- Auto prefix long paths: OFF
-- Use the default codepage: OFF
-- Path sanitization: OFF
-- CPM: bit7z: Adding package [email protected] (v23.01)
-- 7-zip source code available at [...]/test_uuid_mingw/cmake-build-debug-mingw-bundled/_deps/7-zip-src
-- CPM: bit7z: Adding package ghc_filesystem@0 (c0dcd0b090da7dffc74b124a6f164f54dbbb5ccb)
-- ghc::filesystem source code available at [...]/test_uuid_mingw/cmake-build-debug-mingw-bundled/_deps/ghc_filesystem-src
-- Enable sanitizers: OFF
-- Configuring done (5.2s)
-- Generating done (0.0s)
-- Build files have been written to: [...]/test_uuid_mingw/cmake-build-debug-mingw-bundled
- Source code:
#include <bit7z/bit7zlibrary.hpp>
#include <bit7z/bitmemcompressor.hpp>
int main() {
bit7z::Bit7zLibrary lib{};
bit7z::BitMemCompressor compressor{lib, bit7z::BitFormat::Zip};
compressor.compressFile({'h', 'e', 'l', 'l', 'o'}, "hello.zip");
return 0;
}
- Build output:
[...]
[57/61] Building CXX object _deps/bit7z-build/CMakeFiles/bit7z64.dir/src/internal/renameditem.cpp.obj
[58/61] Building CXX object _deps/bit7z-build/CMakeFiles/bit7z64.dir/src/internal/stringutil.cpp.obj
[59/61] Building CXX object _deps/bit7z-build/CMakeFiles/bit7z64.dir/src/internal/updatecallback.cpp.obj
[60/61] Linking CXX static library _deps\bit7z-src\lib\x64\libbit7z64_d.a
[61/61] Linking CXX executable test_uuid_mingw.exe
Build finished
from bit7z.
That is really strange, let me try to create a reproducer.
from bit7z.
This main file fails:
Usage of CLSID_*
is the case #include <shobjidl.h>
(https://learn.microsoft.com/en-us/windows/win32/api/shobjidl/)
#include <iostream>
#include <bit7z/bit7zlibrary.hpp>
#include <bit7z/bitmemcompressor.hpp>
#include <shobjidl.h>
int main() {
const auto id = CLSID_FileOpenDialog;
std::cout << id.Data1 << std::endl;
bit7z::Bit7zLibrary lib{};
bit7z::BitMemCompressor compressor{lib, bit7z::BitFormat::Zip};
compressor.compressFile({'h', 'e', 'l', 'l', 'o'}, "hello.zip");
return 0;
}
from bit7z.
Looks like this chain: #include <shobjidl.h>
-> #include <ole2.h>
-> #include <objbase.h>
-> #include <combaseapi.h>
-> #include <unknwnbase.h>
which contains the IID_IUnknown
But I am not sure TBH, couldn't get a smaller reproducer.
from bit7z.
@rikyoz Works as expected! Thanks a lot. đđŒ
from bit7z.
Perfect! You're welcome! đđŒ
from bit7z.
Related Issues (20)
- [Bug]: UpdateMode::Update not working as expected, throwing exception HOT 3
- [Feature Request]: Creation or extraction archive file in one line HOT 1
- [Feature Request]: Support for compressed packages in four formats: ace, img, uue, and war HOT 2
- [Feature Request]: Extracting files whose names contain forbidden characters HOT 1
- Do I need to build 7zip myself? HOT 6
- [Bug]:
- [Bug]: BIT7Z_DISABLE_USE_STD_FILESYSTEM not working HOT 4
- [Bug]: Compile error when bit7z.lib is introduced into the project. HOT 11
- [Feature Request]: Is "tstring_to_path" forgotten here? HOT 1
- [Bug]: HOT 3
- [Feature Request]: Compresses files open for writing by another applications HOT 1
- [Bug]: CreateObject ćœæ°è°çšćŒćžž
- [Bug]: core dump with BitArchiveWriter HOT 9
- [Bug]: Some zip file names are garbled HOT 5
- [Bug]: HOT 3
- [Possible Bug]: BitArchiveReader::items is slow? HOT 6
- [Feature Request]: Link static 7z lib HOT 1
- [Bug]: Inconsistent encoding of string parameter HOT 1
- [Bug]: "Failed to open the output file: The system cannot find the path specified" error when extracting 7z file HOT 3
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 bit7z.