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

How to build libewf dll for 64 bit? #27

Closed
sk-zeeshan opened this issue Dec 19, 2024 · 18 comments
Closed

How to build libewf dll for 64 bit? #27

sk-zeeshan opened this issue Dec 19, 2024 · 18 comments

Comments

@sk-zeeshan
Copy link

Dear @joachimmetz ,
I went through [https://github.com//issues/10] , I tried building for 64 bit I am getting error at libcfile's makefile and getting exit by status 1 every time, I am using MSYS2 64 bit to build it.
I don't know what is going wrong. I tried to follow the build instruction as well as the steps from the issue 10 but I am not getting anywhere... As discussed earlier in the issues, downloading the libewf.dll from internet is not a good idea either!
Can you please help me with building issue?

@joachimmetz
Copy link
Member

@sk-zeeshan can you provide more details about the issue you are running into?

Also see https://github.com/libyal/libewf/wiki/Building or https://www.nuget.org/packages/libewf/

@sk-zeeshan
Copy link
Author

Hello @joachimmetz ,
I am using Windows 10, 64 bit and using MSYS2 with the same steps from issue 10.
When I use something like --prefix=/mingw64 LDFLAGS="-L/mingw64/lib" CPPFLAGS="-I/mingw64/include", then zlib library issue gets resolved but I don't know why libewf directory is giving error now and exiting with status 1 and also many unreferenced warnings....
When I followed the same from [https://github.com/libyal/libewf/wiki/Building] Its not working either, I know Its my mistake but Is there any way that I can build it somehow, like any steps to follow? Because I tried many things and nothing is working for me....
Can you please provide me updated steps to build it?

@joachimmetz
Copy link
Member

Can you please provide me updated steps to build it?

I'm unable to help you if you don't provide a step-by-step break down of what you are doing and what actual error messages/warning you are getting

@sk-zeeshan
Copy link
Author

sk-zeeshan commented Dec 19, 2024

In C:
I have folder named msys64 in that I have mingw64.

/mingw64 folder structure
----/bin
--------/files and dlls installed from pacman
----/etc
--------/empty
----/include
--------/bzlib.h
--------/zconf.h
--------/zlib.h
----/lib
--------/libewf(repo)
----/share
--------/empty

I have put libewf in lib after unzipping.
I am using libewf-20140608 from legacy/libewf.
When I use MSYS2 which is 64 bit I used the cmd from here: https://github.com/libyal/libewf-legacy/issues/10

CPPFLAGS=-DWINVER=0x0501 ./configure --host=x86_64-w64-mingw32

This gives error for libcfile_file.h:
in line 4689 at internal_file->descriptor:
result = posix_fadvise(
internal_file->descriptor,
0,
0,
advice );

After removing this part and then while trying making it, I get:

ewf_checksum.h:37:30: error: 'uLong' undeclared (first use in this function); did you mean 'ulong'?
37 | (uint32_t) adler32( (uLong) previous_key, (const Bytef *) buffer, (uInt) size );
| ^~~~~
libewf_chunk_data.c:479:39: note: in expansion of macro 'ewf_checksum_calculate'
479 | calculated_checksum = ewf_checksum_calculate(
| ^~~~~~~~~~~~~~~~~~~~~~
libewf_chunk_data.c:482:40: error: expected ')' before numeric constant
482 | 1 );
| ^
ewf_checksum.h:37:37: note: in definition of macro 'ewf_checksum_calculate'
37 | (uint32_t) adler32( (uLong) previous_key, (const Bytef *) buffer, (uInt) size );
| ^~~~~~~~~~~~
ewf_checksum.h:37:27: note: to match this '('
37 | (uint32_t) adler32( (uLong) previous_key, (const Bytef *) buffer, (uInt) size );
| ^
libewf_chunk_data.c:479:39: note: in expansion of macro 'ewf_checksum_calculate'
479 | calculated_checksum = ewf_checksum_calculate(

which is error for zlib header file.

I installed zlib and bzip using pacman!

After this if I use this cmd:
CPPFLAGS=-DWINVER=0x0501 ./configure --host=x86_64-w64-mingw32 --prefix=/mingw64 LDFLAGS="-L/mingw64/lib" CPPFLAGS="-I/mingw64/include"

then I get so many things(I will put some of those lines here):
/usr/lib/gcc/x86_64-pc-msys/13.3.0/../../../../x86_64-pc-msys/bin/ld: ../libuna/.libs/libuna.a(libuna_utf8_string.o): in function libuna_utf8_string_size_from_utf32': /mingw64/lib/libewf/libuna/libuna_utf8_string.c:2261:(.text+0x2982): undefined reference to libuna_unicode_character_copy_from_utf32'
/usr/lib/gcc/x86_64-pc-msys/13.3.0/../../../../x86_64-pc-msys/bin/ld: /mingw64/lib/libewf/libuna/libuna_utf8_string.c:2279:(.text+0x2996): undefined reference to libuna_unicode_character_size_to_utf8' /usr/lib/gcc/x86_64-pc-msys/13.3.0/../../../../x86_64-pc-msys/bin/ld: ../libuna/.libs/libuna.a(libuna_utf8_string.o): in function libuna_utf8_string_with_index_copy_from_utf32':
/mingw64/lib/libewf/libuna/libuna_utf8_string.c:2404:(.text+0x2b52): undefined reference to libuna_unicode_character_copy_from_utf32' /usr/lib/gcc/x86_64-pc-msys/13.3.0/../../../../x86_64-pc-msys/bin/ld: /mingw64/lib/libewf/libuna/libuna_utf8_string.c:2422:(.text+0x2b6e): undefined reference to libuna_unicode_character_copy_to_utf8'
/usr/lib/gcc/x86_64-pc-msys/13.3.0/../../../../x86_64-pc-msys/bin/ld: ../libuna/.libs/libuna.a(libuna_utf8_string.o): in function libuna_utf8_string_compare_with_utf32': /mingw64/lib/libewf/libuna/libuna_utf8_string.c:2533:(.text+0x2e0c): undefined reference to libuna_unicode_character_copy_from_utf32'
/usr/lib/gcc/x86_64-pc-msys/13.3.0/../../../../x86_64-pc-msys/bin/ld: /mingw64/lib/libewf/libuna/libuna_utf8_string.c:2515:(.text+0x2e4d): undefined reference to libuna_unicode_character_copy_from_utf8' /usr/lib/gcc/x86_64-pc-msys/13.3.0/../../../../x86_64-pc-msys/bin/ld: ../libuna/.libs/libuna.a(libuna_utf8_string.o): in function libuna_utf8_string_size_from_utf32_stream':
/mingw64/lib/libewf/libuna/libuna_utf8_string.c:2673:(.text+0x313f): undefined reference to libuna_unicode_character_copy_from_utf32_stream' /usr/lib/gcc/x86_64-pc-msys/13.3.0/../../../../x86_64-pc-msys/bin/ld: /mingw64/lib/libewf/libuna/libuna_utf8_string.c:2692:(.text+0x3157): undefined reference to libuna_unicode_character_size_to_utf8'
/usr/lib/gcc/x86_64-pc-msys/13.3.0/../../../../x86_64-pc-msys/bin/ld: ../libuna/.libs/libuna.a(libuna_utf8_string.o): in function libuna_utf8_string_with_index_copy_from_utf32_stream': /mingw64/lib/libewf/libuna/libuna_utf8_string.c:2888:(.text+0x3495): undefined reference to libuna_unicode_character_copy_from_utf32_stream'
/usr/lib/gcc/x86_64-pc-msys/13.3.0/../../../../x86_64-pc-msys/bin/ld: /mingw64/lib/libewf/libuna/libuna_utf8_string.c:2907:(.text+0x34b5): undefined reference to libuna_unicode_character_copy_to_utf8' /usr/lib/gcc/x86_64-pc-msys/13.3.0/../../../../x86_64-pc-msys/bin/ld: ../libuna/.libs/libuna.a(libuna_utf8_string.o): in function libuna_utf8_string_compare_with_utf32_stream':
/mingw64/lib/libewf/libuna/libuna_utf8_string.c:3099:(.text+0x3927): undefined reference to libuna_unicode_character_copy_from_utf32_stream' /usr/lib/gcc/x86_64-pc-msys/13.3.0/../../../../x86_64-pc-msys/bin/ld: /mingw64/lib/libewf/libuna/libuna_utf8_string.c:3081:(.text+0x3970): undefined reference to libuna_unicode_character_copy_from_utf8'
collect2: error: ld returned 1 exit status
make[1]: *** [Makefile:776: libewf.la] Error 1
make[1]: Leaving directory '/mingw64/lib/libewf/libewf'
make: *** [Makefile:781: all-recursive] Error 1

I am just lost here!
Don't know what to do now...
Any suggestion will be much appreciated!

@joachimmetz
Copy link
Member

I am using libewf-20140608 from legacy/libewf.

why not the latest https://github.com/libyal/libewf-legacy/releases/tag/20140816 ?

not sure if version 20140608 is compatible with current tool chains

I have put libewf in lib after unzipping.

which file did you download the github generated one or the source distribution package? I assume the latter given you were able to run configure, but double checking.

This gives error for libcfile_file.h:
in line 4689 at internal_file->descriptor:
result = posix_fadvise(
internal_file->descriptor,
0,
0,
advice );

any indication in config.log why it thinks this function is available? (look for the function name in config log, you'll see the tests being run to determine if the function is avail)

ewf_checksum.h:37:30: error: 'uLong' undeclared (first use in this function); did you mean 'ulong'?
37 | (uint32_t) adler32( (uLong) previous_key, (const Bytef *) buffer, (uInt) size );

Is zconf.h included by your zlib header?

After this if I use this cmd:

looks like trying to link an incomplete build

have a look at the appveyor configuration maybe that help you determine what is different in your build environment - given that the mingw tests did pass for https://ci.appveyor.com/project/libyal/libewf-legacy/builds/48685822

@sk-zeeshan
Copy link
Author

Hello @joachimmetz ,
I downloaded libewf-2014816.tar.gz and unzipped it.
I read in comments about stable version.
Thank you for the appveyor, I will try everything and get back to you!

@sk-zeeshan
Copy link
Author

Hello @joachimmetz ,
I tried with the latest one... And it built perfectly!
Thank you for your help!!!

@sk-zeeshan
Copy link
Author

Hello @joachimmetz ,
After checking with dependency walker I got this:
Screenshot 2024-12-23 133037
I downloaded zlib and bzip as well while building....
I think I am missing something here, Can you guide me here?

@joachimmetz
Copy link
Member

it is very hard for me to read the screenshot, so standard questions:

  • did you build for the right WINAPI version?
  • are you missing visual C/C++ runtime ?

@sk-zeeshan
Copy link
Author

sk-zeeshan commented Dec 24, 2024

@joachimmetz ,Thank you for pointing that out!

In Msys64, I was using CPPFLAGS=-DWINVER=0x0501, turns out, It is used for WinXP?
Then I changed it to CPPFLAGS=-DWINVER=0x0A00, Because I am using Windows 10, 22H2, OS Build 19045.5247 for building!

Then after make, I got:

libcfile_file.c: In function 'libcfile_file_open_with_error_code':
libcfile_file.c:289:9: error: unknown type name 'FILE_ALIGNMENT_INFO'; did you mean 'FILE_RENAME_INFO'?
289 | FILE_ALIGNMENT_INFO file_alignment_information;
| ^~~~~~~~~~~~~~~~~~~
| FILE_RENAME_INFO
libcfile_file.c:516:27: error: 'FileAlignmentInfo' undeclared (first use in this function)
516 | FileAlignmentInfo,
| ^~~~~~~~~~~~~~~~~
libcfile_file.c:516:27: note: each undeclared identifier is reported only once for each function it appears in
libcfile_file.c:518:43: error: 'FILE_ALIGNMENT_INFO' undeclared (first use in this function); did you mean 'FILE_RENAME_INFO'?
518 | (DWORD) sizeof( FILE_ALIGNMENT_INFO ) );
| ^~~~~~~~~~~~~~~~~~~
| FILE_RENAME_INFO
libcfile_file.c:546:52: error: request for member 'AlignmentRequirement' in something not a structure or union
546 | else if( file_alignment_information.AlignmentRequirement != 0 )
| ^
libcfile_file.c: In function 'libcfile_file_open_wide_with_error_code':
libcfile_file.c:808:9: error: unknown type name 'FILE_ALIGNMENT_INFO'; did you mean 'FILE_RENAME_INFO'?
808 | FILE_ALIGNMENT_INFO file_alignment_information;
| ^~~~~~~~~~~~~~~~~~~
| FILE_RENAME_INFO
libcfile_file.c:1035:27: error: 'FileAlignmentInfo' undeclared (first use in this function)
1035 | FileAlignmentInfo,
| ^~~~~~~~~~~~~~~~~
libcfile_file.c:1037:43: error: 'FILE_ALIGNMENT_INFO' undeclared (first use in this function); did you mean 'FILE_RENAME_INFO'?
1037 | (DWORD) sizeof( FILE_ALIGNMENT_INFO ) );
| ^~~~~~~~~~~~~~~~~~~
| FILE_RENAME_INFO
libcfile_file.c:1065:52: error: request for member 'AlignmentRequirement' in something not a structure or union
1065 | else if( file_alignment_information.AlignmentRequirement != 0 )
| ^
make[1]: *** [Makefile:717: libcfile_file.lo] Error 1
make[1]: Leaving directory '/mingw64/lib/libewf/libcfile'
make: *** [Makefile:827: all-recursive] Error 1

I don't if I am doing anything right anymore........
I am just lost now!!!

@sk-zeeshan
Copy link
Author

What if I build it in Windows 7 Pro, 64 bit, Will I be able to use it in windows 10? Mostly No, Right??
I just want to use it with .Net(C#)!!!
I am still not able to build it..........

@joachimmetz
Copy link
Member

I just want to use it with .Net(C#)!!!

This is the first time you mention building for dotnet, why not start with that?
Might be better to build with visual studio and the dotnet bindings that are provided.

I am just lost now!!!

As I indicated I'm unable to help you if you don't provide a step-by-step break down of what you are doing and what actual error messages/warning you are getting. The more specific you can be the better I can guide you, otherwise you'll have to navigate the ambiguity yourself.

@sk-zeeshan
Copy link
Author

Did you miss this:

In Msys64, I was using CPPFLAGS=-DWINVER=0x0501, turns out, It is used for WinXP?
Then I changed it to CPPFLAGS=-DWINVER=0x0A00, Because I am using Windows 10, 22H2, OS Build 19045.5247 for building!
What should I use as DWINVER?

Also,
The link that you have provided for building instructions, I didn't see anything about .Net Bindings there....

Also,
I put part of error which I got while using CPPFLAGS=-DWINVER=0x0A00, I don't think it would be good if I just copy paste the whole make process.

I am sure the problem is from my end...
Because I even tried it using python libewf and it worked!

But somehow after making I am missing the dependency in dll for which I even tried everything...

If I can make this for .Net It will be much better for me!

@sk-zeeshan
Copy link
Author

sk-zeeshan commented Dec 27, 2024

Hello @joachimmetz,

I was using Windows 10 64 Bit, 22H2, OS Build 19045.5247 for building!
I used libewf-20140816!

I used Msys2(Mingw64) in the process.

First I downloaded the needed things by:

pacman -S gcc make zip unzip autoconf automake gettext-devel libtool mingw-w64-x86_64-gcc msys/bison msys/flex msys/zlib-devel

I built it simply like:

CPPFLAGS=-DWINVER=0x0501 ./configure --host=x86_64-w64-mingw32
make

Then I got libewf-2.dll in Libewf/.libs!

Then I put the below dlls with libewf-2.dll in the same directory:

  1. zlib1.dll (x64)
  2. libwinpthread-1.dll (x64)
  3. libgcc_s_dw2-1.dll (x32) - Not sure if it's needed!

I was using Dependency walker to check the dll!

I found this, and I think this is important: Missing Dll Problem !

So I downloaded the latest tool Dependencies by @lucasg Dependencies Repo, and It didn't show the missing dll problem.

I also ran dumpbin /exports "C:\path\to\libewf-2.dll" command to get function exports to use it in my code!

Can you please clear my 2 doubts?

  1. Should I have used CPPFLAGS=-DWINVER=0x0A00(I got error by this), because I am building and going to use the dll in windows 10?
  2. To use it in .Net with C# are there any different steps to follow, or I can use this directly(maybe by making a wrapper)?

Thank you for helping me till here!

@joachimmetz
Copy link
Member

Should I have used CPPFLAGS=-DWINVER=0x0A00, because I am building and going to use the dll in windows 10?

WINVER is used to set the minimum compatible version of the WinAPI, using 5.1 on Windows 10 should be fine.

To use it in .Net with C# are there any different steps to follow, or I can use this directly(maybe by making a wrapper)?

There is a wrapper, I mentioned this to you in #27 (comment)

@sk-zeeshan
Copy link
Author

Hello @joachimmetz ,
I remember that you told me about the wrapper, but can you please tell me where can I find it?
I didn't see the wrapper in the documentation!

@joachimmetz
Copy link
Member

joachimmetz commented Dec 27, 2024

I didn't see the wrapper in the documentation!

Could be, the documentation is not perfect, the code is here https://github.com/libyal/libewf-legacy/tree/main/ewf.net should build with visual studio. Based on the CI tests should still build but note given I have no use for it might need some tweaking. Also see: https://ci.appveyor.com/project/libyal/libewf-legacy/builds/51212876/job/cqq1ik25ty4jgaia#L198

@sk-zeeshan
Copy link
Author

Thank you so much for guiding me!
I will now start trying.....

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