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 a universal (x86-64 and ARM64) library for macOS #2176

Open
dixlorenz opened this issue May 8, 2024 · 0 comments
Open

How to build a universal (x86-64 and ARM64) library for macOS #2176

dixlorenz opened this issue May 8, 2024 · 0 comments

Comments

@dixlorenz
Copy link

On my M1 (current OS, current Xcode) I tried

./configure CC="gcc -arch x86_64 -arch arm64"

and the result looked good, at least the library was about twice as big and my program using libarchive.a did run. But the same command on an Intel Mac (same OS, same compiler, practically the same setup) stopped with an error:

checking for libxml-2.0... yes
checking for xmlInitParser in -lxml2... no
configure: error: in `/Users/dlorenz/Downloads/libarchive-3.7.4':
configure: error: Missing xml2 library

Just using ./configure worked fine on that machine, but obviously does not create a universal library.

I tried installing from macports, but that won't result in a universal binary.

I tried simply coping the universal library and the 2 headers over to the intel Machine, but when trying to compile my program with it, I got the "Undefined symbols for architecture x86_64" errors below.

Undefined symbols for architecture x86_64:
"_BZ2_bzDecompress", referenced from:
_bzip2_filter_read in libarchive.a[x86_64]40
_extract_pack_stream in libarchive.a[x86_64]54
_rd_contents in libarchive.a[x86_64]69
_archive_read_format_zip_read_data in libarchive.a[x86_64]70
"_BZ2_bzDecompressEnd", referenced from:
_bzip2_filter_read in libarchive.a[x86_64]40
_bzip2_filter_close in libarchive.a[x86_64]40
_archive_read_format_7zip_cleanup in libarchive.a[x86_64]54
_extract_pack_stream in libarchive.a[x86_64]54
_init_decompression in libarchive.a[x86_64]54
_xar_cleanup in libarchive.a[x86_64]69
_rd_contents_init in libarchive.a[x86_64]69
...
"_BZ2_bzDecompressInit", referenced from:
_bzip2_filter_read in libarchive.a[x86_64]40
_bzip2_filter_read in libarchive.a[x86_64]40
_init_decompression in libarchive.a[x86_64]54
_init_decompression in libarchive.a[x86_64]54
_rd_contents_init in libarchive.a[x86_64]69
_rd_contents_init in libarchive.a[x86_64]69
_archive_read_format_zip_read_data in libarchive.a[x86_64]70
...
"_crc32", referenced from:
_gzip_filter_read in libarchive.a[x86_64]44
_archive_read_format_7zip_bid in libarchive.a[x86_64]54
_archive_read_format_7zip_read_header in libarchive.a[x86_64]54
_archive_read_format_7zip_read_header in libarchive.a[x86_64]54
_archive_read_format_7zip_read_header in libarchive.a[x86_64]54
_archive_read_format_7zip_read_data in libarchive.a[x86_64]54
_header_bytes in libarchive.a[x86_64]54
...
"_iconv", referenced from:
_iconv_strncat_in_locale in libarchive.a[x86_64]71
"_iconv_close", referenced from:
_free_sconv_object in libarchive.a[x86_64]71
_free_sconv_object in libarchive.a[x86_64]71
"_iconv_open", referenced from:
_get_sconv_object in libarchive.a[x86_64]71
"_inflate", referenced from:
_gzip_filter_read in libarchive.a[x86_64]44
_extract_pack_stream in libarchive.a[x86_64]54
_cab_read_ahead_cfdata in libarchive.a[x86_64]58
_archive_read_format_iso9660_read_data in libarchive.a[x86_64]61
_rd_contents in libarchive.a[x86_64]69
_archive_read_format_zip_seekable_read_header in libarchive.a[x86_64]70
_zip_read_data_deflate in libarchive.a[x86_64]70
...
"_inflateEnd", referenced from:
_gzip_filter_read in libarchive.a[x86_64]44
_gzip_filter_close in libarchive.a[x86_64]44
_archive_read_format_7zip_cleanup in libarchive.a[x86_64]54
_archive_read_format_cab_cleanup in libarchive.a[x86_64]58
_archive_read_format_iso9660_cleanup in libarchive.a[x86_64]61
_xar_cleanup in libarchive.a[x86_64]69
_archive_read_format_zip_cleanup in libarchive.a[x86_64]70
...
"inflateInit2", referenced from:
_gzip_filter_read in libarchive.a[x86_64]44
_init_decompression in libarchive.a[x86_64]54
_cab_read_ahead_cfdata in libarchive.a[x86_64]58
_archive_read_format_zip_seekable_read_header in libarchive.a[x86_64]70
_zip_read_data_deflate in libarchive.a[x86_64]70
"inflateInit", referenced from:
_archive_read_format_iso9660_read_data in libarchive.a[x86_64]61
_xar_read_header in libarchive.a[x86_64]69
_rd_contents_init in libarchive.a[x86_64]69
"_inflateReset", referenced from:
_init_decompression in libarchive.a[x86_64]54
_cab_read_ahead_cfdata in libarchive.a[x86_64]58
_cab_read_ahead_cfdata in libarchive.a[x86_64]58
_archive_read_format_iso9660_read_data in libarchive.a[x86_64]61
_xar_read_header in libarchive.a[x86_64]69
_rd_contents_init in libarchive.a[x86_64]69
_archive_read_format_zip_seekable_read_header in libarchive.a[x86_64]70
...
"_inflateSetDictionary", referenced from:
_cab_read_ahead_cfdata in libarchive.a[x86_64]58
"_xmlCleanupParser", referenced from:
_xml2_read_toc in libarchive.a[x86_64]69
"_xmlFreeTextReader", referenced from:
_xml2_read_toc in libarchive.a[x86_64]69
"_xmlReaderForIO", referenced from:
_xml2_read_toc in libarchive.a[x86_64]69
"_xmlTextReaderConstLocalName", referenced from:
_xml2_read_toc in libarchive.a[x86_64]69
_xml2_read_toc in libarchive.a[x86_64]69
"_xmlTextReaderConstValue", referenced from:
_xml2_read_toc in libarchive.a[x86_64]69
_xml2_read_toc in libarchive.a[x86_64]69
"_xmlTextReaderIsEmptyElement", referenced from:
_xml2_read_toc in libarchive.a[x86_64]69
"_xmlTextReaderMoveToFirstAttribute", referenced from:
_xml2_read_toc in libarchive.a[x86_64]69
"_xmlTextReaderMoveToNextAttribute", referenced from:
_xml2_read_toc in libarchive.a[x86_64]69
"_xmlTextReaderNodeType", referenced from:
_xml2_read_toc in libarchive.a[x86_64]69
"_xmlTextReaderRead", referenced from:
_xml2_read_toc in libarchive.a[x86_64]69
_xml2_read_toc in libarchive.a[x86_64]69
"_xmlTextReaderSetErrorHandler", referenced from:
_xml2_read_toc in libarchive.a[x86_64]69

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

1 participant