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

Help with musl cmake toolchain file #196

Open
Fabian188 opened this issue Jan 1, 2025 · 3 comments
Open

Help with musl cmake toolchain file #196

Fabian188 opened this issue Jan 1, 2025 · 3 comments

Comments

@Fabian188
Copy link

I built a cross compiler on Linux via
TARGET = x86_64-linux-musl
without any issues and installed in to the default local output directory.

I'm currently struggling to use it for my cmake project (with it's external projects).

Does anyone have a cmake toolchain file?

Thanks

@rofl0r
Copy link
Contributor

rofl0r commented Jan 1, 2025

i don't have a "toolchain file", but a skeleton to use cmake with any cross-compiler:

https://github.com/sabotage-linux/sabotage/blob/master/KEEP/pkg_skel/cmake

just export CROSS_COMPILE to x86_64-linux-musl-, add the directory containing x86_64-linux-musl-gcc to PATH, and export CC/CXX like CC="x86_64-linux-musl-gcc -isystem /path/to/musl-prefix/include -L /path/to/musl-prefix/lib"

@Fabian188
Copy link
Author

Thanks for your response. I guess I did most beside setting the path.

It works for other dependencies (muparser and metis) but fails for zlib:

It seems the error is from
/usr/bin/cmake -E cmake_symlink_library libz.so.1.3 libz.so.1 libz.so
I need to dig deeper ...

[ 37%] Building C object CMakeFiles/zlib.dir/zutil.c.o
/home/fwein/code/musl/output/bin/x86_64-linux-musl-gcc --sysroot=/home/fwein/code/musl/output/x86_64-linux-musl -DZLIB_DLL -D_LARGEFILE64_SOURCE=1 -I/home/fwein/code/cfs/release_musl/cfsdeps/zlib/src/zlib-build -I/home/fwein/code/cfs/release_musl/cfsdeps/zlib/src/zlib -m64 -O3  -w -Wno-everything -O3 -DNDEBUG -fPIC -MD -MT CMakeFiles/zlib.dir/zutil.c.o -MF CMakeFiles/zlib.dir/zutil.c.o.d -o CMakeFiles/zlib.dir/zutil.c.o -c /home/fwein/code/cfs/release_musl/cfsdeps/zlib/src/zlib/zutil.c
[ 40%] Linking C shared library libz.so
/usr/bin/cmake -E cmake_link_script CMakeFiles/zlib.dir/link.txt --verbose=1
/home/fwein/code/musl/output/bin/x86_64-linux-musl-gcc --sysroot=/home/fwein/code/musl/output/x86_64-linux-musl -fPIC  -m64 -O3  -w -Wno-everything -O3 -DNDEBUG -Wl,--version-script,"/home/fwein/code/cfs/release_musl/cfsdeps/zlib/src/zlib/zlib.map" -Wl,-rpath-link=/home/fwein/code/musl/output/x86_64-linux-musl/lib -shared -Wl,-soname,libz.so.1 -o libz.so.1.3 CMakeFiles/zlib.dir/adler32.c.o CMakeFiles/zlib.dir/compress.c.o CMakeFiles/zlib.dir/crc32.c.o CMakeFiles/zlib.dir/deflate.c.o CMakeFiles/zlib.dir/gzclose.c.o CMakeFiles/zlib.dir/gzlib.c.o CMakeFiles/zlib.dir/gzread.c.o CMakeFiles/zlib.dir/gzwrite.c.o CMakeFiles/zlib.dir/inflate.c.o CMakeFiles/zlib.dir/infback.c.o CMakeFiles/zlib.dir/inftrees.c.o CMakeFiles/zlib.dir/inffast.c.o CMakeFiles/zlib.dir/trees.c.o CMakeFiles/zlib.dir/uncompr.c.o CMakeFiles/zlib.dir/zutil.c.o 
/usr/bin/cmake -E cmake_symlink_library libz.so.1.3 libz.so.1 libz.so
/usr/bin/cmake: error while loading shared libraries: /usr/lib64/libc.so: invalid ELF header

@Fabian188
Copy link
Author

I came a step further: I set LD_LIBRARY_PATH to the musl lib dir, where libc is located and got the error:

`/usr/bin/cmake: /home/fwein/code/musl/output/x86_64-linux-musl/lib/libstdc++.so.6: version GLIBCXX_3.4.30' not found (required by /usr/bin/cmake)``

unsetting LD_LIBRARY_PATH again and building again finished zlib.

That is clearly not a solution but might be a hint. I'm currently stuck in building hdf5 in cross compiler mode.

Probably one shall simply close the issue?

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