Closed adamk33n3r closed 10 years ago
Stripping the binary should not break the building process. Could you post the error output and which compiler/linker and Qt libraries you are using?
I'm using qt version 4.8.6 installed through homebrew. It is using clang 5.1.0.
This is the error I get when the -s
is present.
[ 97%] Building CXX object oracle/CMakeFiles/oracle.dir/src/main.cpp.o
clang: warning: argument unused during compilation: '-s'
[ 97%] Building CXX object oracle/CMakeFiles/oracle.dir/src/oracleimporter.cpp.o
clang: warning: argument unused during compilation: '-s'
[ 97%] Building CXX object oracle/CMakeFiles/oracle.dir/src/window_main.cpp.o
clang: warning: argument unused during compilation: '-s'
[ 98%] Building CXX object oracle/CMakeFiles/oracle.dir/__/cockatrice/src/carddatabase.cpp.o
clang: warning: argument unused during compilation: '-s'
[ 98%] Building CXX object oracle/CMakeFiles/oracle.dir/__/cockatrice/src/settingscache.cpp.o
clang: warning: argument unused during compilation: '-s'
[ 98%] Building CXX object oracle/CMakeFiles/oracle.dir/src/moc_oracleimporter.cxx.o
clang: warning: argument unused during compilation: '-s'
[ 98%] Building CXX object oracle/CMakeFiles/oracle.dir/src/moc_window_main.cxx.o
clang: warning: argument unused during compilation: '-s'
[ 98%] Building CXX object oracle/CMakeFiles/oracle.dir/__/cockatrice/src/moc_carddatabase.cxx.o
clang: warning: argument unused during compilation: '-s'
[ 99%] Building CXX object oracle/CMakeFiles/oracle.dir/__/cockatrice/src/moc_settingscache.cxx.o
clang: warning: argument unused during compilation: '-s'
Linking CXX executable oracle.app/Contents/MacOS/oracle
ld: warning: option -s is obsolete and being ignored
ld: internal error: atom not found in symbolIndex(__ZN10QTextCodec12codecForNameEPKc) for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [oracle/oracle.app/Contents/MacOS/oracle] Error 1
make[1]: *** [oracle/CMakeFiles/oracle.dir/all] Error 2
make: *** [all] Error 2
Hm, something seems not right. I created a fresh build directory for the current git master and used cmake-gui (2.8.12.2) to check all default options and configure the build. There is no -s option by default and the release target uses -O3. I set the c++ compiler to clang++ because otherwise it would be g++ on my Linux system and set the cxxflags to "-s -O2" to reproduce this error but the source compiled, at least with clang 3.3 (there is no clang 5.x btw, the current version is 3.4.1; or does Apple use other versions of clang? This would suck.). What puzzles me in any case is: clang ignores -s for compiling (which is ok because you can strip only after linking) and ld writes that it ignores -s too, so it should not matter if -s is present or not - but obviously it does matter somehow (which sounds rather like a bug in the linker).
Do you also use the current git master? Did you create a new build directory and how did you use/invoke cmake? Did you customize something for cmake? What does ld --version, cmake --version and clang++ --version say?
The flag gets defined in oracle/CMakeList.txt:
set(CMAKE_CXX_FLAGS_RELEASE "-s -O2")
My clang version is:
Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
So i assume 3.4 is the base version Apple used for its "5.1" version.
Verbose output of the linking error:
Linking CXX executable oracle.app/Contents/MacOS/oracle
cd /Users/fab/prj/Cockatrice/build/oracle && /usr/local/Cellar/cmake/2.8.12.2/bin/cmake -E cmake_link_script CMakeFiles/oracle.dir/link.txt --verbose=1
/usr/bin/c++ -s -O2 -Wl,-search_paths_first -Wl,-headerpad_max_install_names CMakeFiles/oracle.dir/src/main.cpp.o CMakeFiles/oracle.dir/src/oracleimporter.cpp.o CMakeFiles/oracle.dir/src/window_main.cpp.o CMakeFiles/oracle.dir/__/cockatrice/src/carddatabase.cpp.o CMakeFiles/oracle.dir/__/cockatrice/src/settingscache.cpp.o CMakeFiles/oracle.dir/src/moc_oracleimporter.cxx.o CMakeFiles/oracle.dir/src/moc_window_main.cxx.o CMakeFiles/oracle.dir/__/cockatrice/src/moc_carddatabase.cxx.o CMakeFiles/oracle.dir/__/cockatrice/src/moc_settingscache.cxx.o -o oracle.app/Contents/MacOS/oracle -F/usr/local/Cellar/qt/4.8.5/lib -framework QtSvg -framework QtGui -framework QtXml -framework QtNetwork -framework QtCore
ld: warning: option -s is obsolete and being ignored
ld: internal error: atom not found in symbolIndex(__ZN10QTextCodec12codecForNameEPKc) for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [oracle/oracle.app/Contents/MacOS/oracle] Error 1
make[1]: *** [oracle/CMakeFiles/oracle.dir/all] Error 2
make: *** [all] Error 2
Manually calling the commandline with "-v" as suggested produces the following output:
Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
Target: x86_64-apple-darwin13.2.0
Thread model: posix
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld" -demangle -dynamic -arch x86_64 -macosx_version_min 10.9.0 -s -o oracle.app/Contents/MacOS/oracle -search_paths_first -headerpad_max_install_names CMakeFiles/oracle.dir/src/main.cpp.o CMakeFiles/oracle.dir/src/oracleimporter.cpp.o CMakeFiles/oracle.dir/src/window_main.cpp.o CMakeFiles/oracle.dir/__/cockatrice/src/carddatabase.cpp.o CMakeFiles/oracle.dir/__/cockatrice/src/settingscache.cpp.o CMakeFiles/oracle.dir/src/moc_oracleimporter.cxx.o CMakeFiles/oracle.dir/src/moc_window_main.cxx.o CMakeFiles/oracle.dir/__/cockatrice/src/moc_carddatabase.cxx.o CMakeFiles/oracle.dir/__/cockatrice/src/moc_settingscache.cxx.o -framework QtSvg -framework QtGui -framework QtXml -framework QtNetwork -framework QtCore -lc++ -lSystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/5.1/lib/darwin/libclang_rt.osx.a -F/usr/local/Cellar/qt/4.8.5/lib
ld: warning: option -s is obsolete and being ignored
ld: internal error: atom not found in symbolIndex(__ZN10QTextCodec12codecForNameEPKc) for architecture x86_64
Cockatrice also uses -s -O2 in CMakeList.txt so it is strange that only the oracle is failing to build. I don't know what causes the error but I think that the presets in the CMake files are too GNU oriented anyway: -s only works well with gcc and -ggdb optimizes for gdb. That is not quite BSD/Mac/Win32 friendly. I'd say that the compiler settings should be removed from the all subfolder CMakeLists.txt and rewritten in the main CMakeLists.txt in a platform/toolchain specific way, e.g. with the variables listed here: http://www.cmake.org/Wiki/CMake_Useful_Variables#System_.26_Compiler_Information We could check for GNUCXX, Clang and MSVC this way and set proper flags.
So, i've created a pull request #82 that fixes this issue. A CMakeList.txt rehaul is a good idea anyway, i see a few points that could be improved:
My versions are:
ld -v:
@(#)PROGRAM:ld PROJECT:ld64-236.4
configured to support archs: armv6 armv7 armv7s arm64 i386 x86_64 armv6m armv7m armv7em
cmake --version:
cmake version 2.8.12.2
clang++ --version:
Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
Target: x86_64-apple-darwin13.1.0
Thread model: posix
So basically same as @ctrlaltca
Fixed - #82
I tried building the app and it fail when linking Oracle. It is fixed by removing the
-s
fromset(CMAKE_CXX_FLAGS_RELEASE "-s -O2")
. I don't know if this is only a thing with Mavericks or if it's an OS X thing but removing this-s
lets it finish with a working product.