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

When I cross compile cgo to macos, undefined reference to symbols inside frameworks #10660

Closed
akkuman opened this issue Jan 21, 2022 · 4 comments
Labels
os-macos question zig cc Zig as a drop-in C compiler feature

Comments

@akkuman
Copy link

akkuman commented Jan 21, 2022

Zig Version

0.9.0

Steps to Reproduce

When I cross compile cgo from linux to macos, compile error

cat $HOME/.bin/zcc
#!/bin/sh
ZIG_LOCAL_CACHE_DIR="$HOME/tmp" zig cc -target x86_64-macos-gnu

cat $HOME/.bin/zxx
#!/bin/sh
ZIG_LOCAL_CACHE_DIR="$HOME/tmp" zig c++ -target x86_64-macos-gnu

error

# github.com/akkuman/rotateproxy/cmd/rotateproxy
/opt/hostedtoolcache/go/1.17.6/x64/pkg/tool/linux_amd64/link: running zcc failed: exit status 1
warning: unsupported linker arg: -S
warning: unsupported linker arg: -no_pie
warning: unsupported linker arg: -pagezero_size
warning: unsupported linker arg: 4000000
warning: unsupported linker arg: --compress-debug-sections
warning: unsupported linker arg: zlib-gnu
warning(link): framework not found for '-framework CoreFoundation'
warning(link): framework not found for '-framework Security'
warning(link): Framework search paths:
error(link): undefined reference to symbol '_SecTrustSettingsCopyTrustSettings'
error(link):   first referenced in '/tmp/go-link-800811870/go.o'
error(link): undefined reference to symbol '_SecTrustSettingsCopyCertificates'
error(link):   first referenced in '/tmp/go-link-800811870/go.o'
error(link): undefined reference to symbol '_SecPolicyCopyProperties'
error(link):   first referenced in '/tmp/go-link-800811870/go.o'
error(link): undefined reference to symbol '_SecItemExport'
error(link):   first referenced in '/tmp/go-link-800811870/go.o'
error(link): undefined reference to symbol '_CFStringCreateWithBytes'
error(link):   first referenced in '/tmp/go-link-800811870/go.o'
error(link): undefined reference to symbol '_CFRelease'
error(link):   first referenced in '/tmp/go-link-800811870/go.o'
error(link): undefined reference to symbol '_CFNumberGetValue'
error(link):   first referenced in '/tmp/go-link-800811870/go.o'
error(link): undefined reference to symbol '_CFEqual'
error(link):   first referenced in '/tmp/go-link-800811870/go.o'
error(link): undefined reference to symbol '_CFDictionaryGetValueIfPresent'
error(link):   first referenced in '/tmp/go-link-800811870/go.o'
error(link): undefined reference to symbol '_CFDataGetLength'
error(link):   first referenced in '/tmp/go-link-800811870/go.o'
error(link): undefined reference to symbol '_CFDataGetBytePtr'
error(link):   first referenced in '/tmp/go-link-800811870/go.o'
error(link): undefined reference to symbol '_CFArrayGetValueAtIndex'
error(link):   first referenced in '/tmp/go-link-800811870/go.o'
error(link): undefined reference to symbol '_CFArrayGetCount'
error(link):   first referenced in '/tmp/go-link-800811870/go.o'
error: UndefinedSymbolReference

see https://github.com/akkuman/rotateproxy/runs/4863624753?check_suite_focus=true

Expected Behavior

compile successfully

Actual Behavior

error

@akkuman akkuman added the bug Observed behavior contradicts documented or intended behavior label Jan 21, 2022
@nektro
Copy link
Contributor

nektro commented Jan 30, 2022

    echo 'ZIG_LOCAL_CACHE_DIR="$HOME/tmp" zig cc -target '${libc}' $@' >> "$HOME/.bin/zcc"
    echo 'ZIG_LOCAL_CACHE_DIR="$HOME/tmp" zig c++ '${libc}' $@' >> "$HOME/.bin/zxx"

the single quotes are likely destroying the variable text replacement

@andrewrk andrewrk added os-macos zig cc Zig as a drop-in C compiler feature labels Feb 2, 2022
@andrewrk
Copy link
Member

andrewrk commented Feb 2, 2022

These should be hard errors instead of warnings:

warning(link): framework not found for '-framework CoreFoundation'
warning(link): framework not found for '-framework Security'

In master branch, they are.

Looks like a duplicate of #1349.

@kubkon do we have a FAQ link or documentation page to link people to when they run into this particular issue?

@andrewrk andrewrk closed this as completed Feb 2, 2022
@andrewrk andrewrk added question and removed bug Observed behavior contradicts documented or intended behavior labels Feb 2, 2022
@kubkon
Copy link
Member

kubkon commented Feb 2, 2022

These should be hard errors instead of warnings:

warning(link): framework not found for '-framework CoreFoundation'
warning(link): framework not found for '-framework Security'

In master branch, they are.

Correct, I've fixed it for the next release from warnings into hard errors, but you know this already.

Looks like a duplicate of #1349.

@kubkon do we have a FAQ link or documentation page to link people to when they run into this particular issue?

Excellent question, and I don't think we have, no. Where would you think we should add info like this? Main docs? Or perhaps we should have a separate page for the toolchain (compiler+linker)?

@andrewrk
Copy link
Member

andrewrk commented Feb 2, 2022

I'd start with making sure #1349 has up-to-date info. Maybe an entry in https://github.com/ziglang/zig/wiki/FAQ that we can link to. And that's enough for now.

@andrewrk andrewrk changed the title When I cross compile cgo from linux to macos, compile error When I cross compile cgo to macos, undefined reference to symbols inside frameworks Feb 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
os-macos question zig cc Zig as a drop-in C compiler feature
Projects
None yet
Development

No branches or pull requests

4 participants