gdraheim / zziplib

The ZZIPlib provides read access on ZIP-archives and unpacked data. It features an additional simplified API following the standard Posix API for file access
Other
62 stars 50 forks source link

Need a Cross compile example #163

Open staticmem opened 4 months ago

staticmem commented 4 months ago

I'm ok with .configure scripts from the older releases and while I can build the current zziplib using Cmake to create a Makefile and then using the traditional make command for the current host I don't know what I need to do to cross compile with Cmake.

Do I have to edit the CMakeLists.txt file every time the target changes and if so what needs to change?

I would like one simple example. Let's say I want to use "x86_64-w64-mingw32" to create a Windows build. I have a location in /opt to place the target files.

How would I go about this?

gdraheim commented 4 months ago

There is a working example in the source code - "testbuilds.py test_250" and "testbuilds.py test_260".

I just made it working, and I wanted to have a test with conan as well, so it may not contain all the answers you need. Cmake itself should allow for anything needed to crosscompile. As I was using automake without conan in the past, I need to learn more about that myself.

staticmem commented 4 months ago

I really have no idea what to do with it, I run this...

$ cd zziplib-master

$ ./testbuilds.py test_250
WARNING:TESTING:     windows-static-x64 compiles fine but segfaults on linking an .exe
----------------------------------------------------------------------
Ran 1 test in 0.000s

OK (skipped=1)

I don't think it does any compiling as it just returns straight away.

I would have thought something like this was required:

https://earthly.dev/blog/cmake-gcc-cross-compile/

At this stage I think I'll have to use zziplib-0.13.69.tar.gz and install the files myself and copy the __*.h files to the include directory which has worked around the issue in the past (I found some notes I had for that). That release has worked for me in the past and I'm just after something that can be cross compiled easily.

gdraheim commented 4 months ago

The "testbuilds.py" requires an active docker service as it uses a containerized crossgcc. I do not expect anyone to preinstall a compiler on the host to get some tests running. If you like then you can look into the respective dockerfile that is used by the test.

https://github.com/gdraheim/zziplib/blob/master/testbuilds/windows-shared-x64.dockerfile

staticmem commented 4 months ago

Way too involved and complicated for me I'm afraid. Even a .configure script that many packages use only requires one line to cross compile so I'm not sure why Cmake is taking over the traditional way of doing things.

Thanks anyway.

gdraheim commented 4 months ago

Well, cmake is better for use in IDEs. And I will certainly remove the automake-configure script in the near future.

As for myself, I do a lot of devops-consulting and Conan is the tool for versioning and better release-managment. This is required in a lot of places even getting into the "reproducible builds" domain. The industry is changing.