tpoechtrager / osxcross

Mac OS X cross toolchain for Linux, FreeBSD, OpenBSD and Android (Termux)
GNU General Public License v2.0
2.91k stars 329 forks source link

MacOSX10.15 build error #202

Closed aspel closed 2 months ago

aspel commented 5 years ago

Hello, Have this error

ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
+ echo ''
+ '[' 0 -eq 1 ']'
+ test_compiler_cxx11 o64-clang++ /osxcross/oclang/test_libcxx.cpp
+ set +e
+ echo -ne 'testing o64-clang++ -stdlib=libc++ -std=c++11 ... '
+ o64-clang++ /osxcross/oclang/test_libcxx.cpp -O2 -stdlib=libc++ -std=c++11 -Wall -o test
testing o64-clang++ -stdlib=libc++ -std=c++11 ... failed (ignored)
+ '[' 1 -eq 0 ']'
+ echo 'failed (ignored)'
+ set -e

+ echo ''
+ '[' 0 -eq 1 ']'
+ test_compiler o64-clang /osxcross/oclang/test.c
testing o64-clang ... + echo -ne 'testing o64-clang ... '
+ o64-clang /osxcross/oclang/test.c -O2 -Wall -o test
osxcross: debug: --> o64-clang /osxcross/oclang/test.c -O2 -Wall -o test
osxcross: debug: <-- /usr/lib/llvm-9/bin/clang (clang) -target x86_64-apple-darwin19 -mlinker-version=409.12 -isystem /usr/lib/llvm-9/bin/../lib/clang/9.0.1/include -isysroot /osxcross/target/bin/../SDK/MacOSX10.15.sdk -cxx-isystem /osxcross/target/bin/../SDK/MacOSX10.15.sdk/usr/include/c++/v1 -mmacosx-version-min=10.9.0 -arch x86_64 -Wno-liblto /osxcross/oclang/test.c -O2 -Wall -o test
osxcross: debug: === time spent in wrapper: 0.171801 ms
+ rm test
works
+ echo works
+ test_compiler o64-clang++ /osxcross/oclang/test.cpp
testing o64-clang++ ... + echo -ne 'testing o64-clang++ ... '
+ o64-clang++ /osxcross/oclang/test.cpp -O2 -Wall -o test
osxcross: debug: --> o64-clang++ /osxcross/oclang/test.cpp -O2 -Wall -o test
osxcross: debug: <-- /usr/lib/llvm-9/bin/clang (clang++) -target x86_64-apple-darwin19 -mlinker-version=409.12 -isystem /usr/lib/llvm-9/bin/../lib/clang/9.0.1/include -isysroot /osxcross/target/bin/../SDK/MacOSX10.15.sdk -stdlib=libc++ -nostdinc++ -Qunused-arguments -cxx-isystem /osxcross/target/bin/../SDK/MacOSX10.15.sdk/usr/include/c++/v1 -mmacosx-version-min=10.9.0 -arch x86_64 -Wno-liblto /osxcross/oclang/test.cpp -O2 -Wall -o test
osxcross: debug: === time spent in wrapper: 0.179951 ms
Undefined symbols for architecture x86_64:
  "std::basic_ios<char, std::char_traits<char> >::widen(char) const", referenced from:
      _main in test-37d8ff.o
  "std::ostream::put(char)", referenced from:
      _main in test-37d8ff.o
  "std::ostream::flush()", referenced from:
      _main in test-37d8ff.o
  "std::ios_base::Init::Init()", referenced from:
      __GLOBAL__sub_I_test.cpp in test-37d8ff.o
  "std::ios_base::Init::~Init()", referenced from:
      __GLOBAL__sub_I_test.cpp in test-37d8ff.o
  "std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, long)", referenced from:
      _main in test-37d8ff.o
  "std::cout", referenced from:
      _main in test-37d8ff.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
+ _exit
+ EC=1
+ '[' 1 -ne 0 ']'
+ test -z build.sh
+ echo ''
+ echo 'exiting with abnormal exit code (1)'
+ test -n 1
+ '[' -n cctools-port ']'
+ rm -f 'build/*_built_successfully'

exiting with abnormal exit code (1)
+ echo ''
+ test build.sh = build.sh
+ check_for_bug_1242300
+ '[' -e /etc/issue ']'

++ grep -i ubuntu.13.10 /etc/issue
+ '[' '' ']'
The command '/bin/sh -c cd /osxcross && OSX_VERSION_MIN=10.9 UNATTENDED=1 OCDEBUG=1 UNATTENDED=1 ./build.sh' returned a non-zero code: 1

Docker file

FROM ubuntu:18.04 as base

RUN apt-get -qq update && apt-get --no-install-recommends -qq -y install curl cmake file git build-essential xz-utils software-properties-common  gpg-agent zlib1g-dev  libz3-dev

RUN curl -sL --retry 10 --retry-delay 60 https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add -
RUN apt-add-repository "deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-9 main"
RUN apt-get -qq update && apt-get --no-install-recommends -qq -y install clang-9 && ln -s /usr/bin/clang-9 /usr/bin/clang && ln -s /usr/bin/clang++-9 /usr/bin/clang++
RUN clang -v
RUN git clone -q --depth 1 https://github.com/tpoechtrager/osxcross.git

RUN apt-get -qq update && apt-get --no-install-recommends -qq -y install automake libxml2-dev libssl-dev

COPY MacOSX10.15.sdk.tar.xz /osxcross/tarballs/MacOSX10.15.sdk.tar.xz

RUN cd /osxcross && OSX_VERSION_MIN=10.9 OCDEBUG=1 UNATTENDED=1 ./build.sh
RUN cd /osxcross && ./target/bin/o64-clang++-libc++ -o osxcross ./oclang/test_libcxx.cpp
aspel commented 5 years ago

Additional info

Step 13/50 : RUN cd /osxcross && ./target/bin/o64-clang++ -v -o test ./oclang/test.cpp
 ---> Running in bf547e56328c
clang version 9.0.1-svn374861-1~exp1~20191015075537.63 (branches/release_90)
Target: x86_64-apple-darwin19
Thread model: posix
InstalledDir: /usr/bin
 "/usr/lib/llvm-9/bin/clang" -cc1 -triple x86_64-apple-macosx10.9.0 -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main-file-name test.cpp -mrelocation-model pic -pic-level 2 -mthread-model posix -mdisable-fp-elim -masm-verbose -munwind-tables -faligned-alloc-unavailable -target-sdk-version=10.15 -target-cpu core2 -dwarf-column-info -debugger-tuning=lldb -ggnu-pubnames -target-linker-version 409.12 -v -nostdinc++ -resource-dir /usr/lib/llvm-9/lib/clang/9.0.1 -isystem /usr/lib/llvm-9/bin/../lib/clang/9.0.1/include -isysroot /osxcross/target/bin/../SDK/MacOSX10.15.sdk -cxx-isystem /osxcross/target/bin/../SDK/MacOSX10.15.sdk/usr/include/c++/v1 -stdlib=libc++ -internal-isystem /osxcross/target/bin/../SDK/MacOSX10.15.sdk/usr/local/include -internal-isystem /usr/lib/llvm-9/lib/clang/9.0.1/include -internal-externc-isystem /osxcross/target/bin/../SDK/MacOSX10.15.sdk/usr/include -Wno-liblto -fdeprecated-macro -fdebug-compilation-dir /osxcross -ferror-limit 19 -fmessage-length 0 -stack-protector 1 -fblocks -fencode-extended-block-signature -fregister-global-dtors-with-atexit -fobjc-runtime=macosx-10.9.0 -fcxx-exceptions -fexceptions -fmax-type-align=16 -fdiagnostics-show-option -o /tmp/test-8fbf72.o -x c++ ./oclang/test.cpp
clang -cc1 version 9.0.1 based upon LLVM 9.0.1 default target x86_64-pc-linux-gnu
ignoring nonexistent directory "/osxcross/target/bin/../SDK/MacOSX10.15.sdk/usr/local/include"
ignoring nonexistent directory "/osxcross/target/bin/../SDK/MacOSX10.15.sdk/Library/Frameworks"
ignoring duplicate directory "/usr/lib/llvm-9/bin/../lib/clang/9.0.1/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/lib/llvm-9/bin/../lib/clang/9.0.1/include
 /osxcross/target/bin/../SDK/MacOSX10.15.sdk/usr/include/c++/v1
 /osxcross/target/bin/../SDK/MacOSX10.15.sdk/usr/include
 /osxcross/target/bin/../SDK/MacOSX10.15.sdk/System/Library/Frameworks (framework directory)
End of search list.
 "/osxcross/target/bin/x86_64-apple-darwin19-ld" -demangle -lto_library /usr/lib/llvm-9/lib/libLTO.dylib -no_deduplicate -dynamic -arch x86_64 -macosx_version_min 10.9.0 -syslibroot /osxcross/target/bin/../SDK/MacOSX10.15.sdk -o test /tmp/test-8fbf72.o -lc++ -lSystem
Undefined symbols for architecture x86_64:
  "std::ostream::operator<<(std::ostream& (*)(std::ostream&))", referenced from:
      _main in test-8fbf72.o
  "std::ios_base::Init::Init()", referenced from:
      ___cxx_global_var_init in test-8fbf72.o
  "std::ios_base::Init::~Init()", referenced from:
      ___cxx_global_var_init in test-8fbf72.o
  "std::cout", referenced from:
      _main in test-8fbf72.o
  "std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)", referenced from:
      _main in test-8fbf72.o
  "std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)", referenced from:
      _main in test-8fbf72.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
The command '/bin/sh -c cd /osxcross && ./target/bin/o64-clang++ -v -o test ./oclang/test.cpp' returned a non-zero code: 1
tpoechtrager commented 5 years ago

Looks like a broken SDK to me. Did you follow the README to package the SDK? https://github.com/tpoechtrager/osxcross#packaging-the-sdk

aspel commented 5 years ago

Yes, I used gen_sdk_package.sh to create MacOSX10.15.sdk.tar.xz I will try recreate SDK file directly from Xcode