otool -L filename/path not working - ios

I'm running through some various programming/debugging tutorials and uses the "otool" command in terminal. An example is to check for shared libraries. The error is always one of two. I'm running it from the directory the file is located. Typing in just otool give the list of otool "-x" switches. I've gone down the list of switches on multiple files and directories and get the same errors.
What am I missing?
$ otool -L DemoApp
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/otool: can't open file: DemoApp (No such file or directory)
or
$ otool -L DemoApp.app
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/otool: can't map file: DemoApp.app (Invalid argument)

you need to point to a final executable file. DemoApp.app is just a directory. Try otool -L ~/Applications/DemoApp.app/Contents/MacOS/DemoApp

Related

Qt-creator examples fail to build for iphonesimulator

I've successfully installed Qt 5.7.0 and Qt-creator 4.1.0 on El Capitan with Xcode 8.
I fixed the xcode sdk-version errors from qt, and now I'm trying to build one of the examples for iphonesimulator. None of them work. All of them fail with error message of type:
The following build commands failed:
CopyPNGFile Debug-iphonesimulator/2dpainting.app/Default-568h#2x.png 2dpainting.xcodeproj/Default-568h#2x.png
I can confirm that directory Debug-iphonesimulator/2dpainting.app does not have the png-file, it's actually located somewhere within the qt installation directories. Copying the png to the source folder does not help as the folder gets overwritten upon running 'make'.
Any advice would be appreciated.
Edit:
The build kit warns about the following issue:
"Device type is not supported by the Qt version". Device type is 'iOS simulator'.
I had the same problem after I had updated my Xcode to version 8.0.
My first error was "Project ERROR: Xcode not set up properly. You may need to confirm the license agreement by running /usr/bin/xcodebuild."
To solve this problem, I created a symbolic link:
cd /Applications/Xcode.app/Contents/Developer/usr/bin/
sudo ln -s xcodebuild xcrun
Then I got error "Project ERROR: Current iphonesimulator SDK version (10.0) is too old. Please upgrade Xcode."
I commented two strings out in file QT_DIR/5.7/ios/mkspecs/macx-ios-clang/features/sdk.prf
lessThan(QMAKE_MAC_SDK_VERSION, "8.0"): \
error("Current $$QMAKE_MAC_SDK SDK version ($$QMAKE_MAC_SDK_VERSION) is too old. Please upgrade Xcode.")
Then I got error about emulator. Qt could not find it. I replaced line of code in file QT_DIR/5.7/ios/mkspecs/macx-ios-clang/xcodebuild.mk from:
IPHONESIMULATOR_GENERIC_DESTINATION := "id=$(shell xcrun simctl list devices | grep -E 'iPhone|iPad' | grep -v unavailable | perl -lne 'print $$1 if /((.*?))/' | tail -n 1)"
to:
IPHONESIMULATOR_GENERIC_DESTINATION := "id=$(shell xcrun simctl list devices | grep -E 'iPhone|iPad' | grep -v unavailable | awk 'match ($$0, /\(([A-F0-9\-]*\))/ ) { print substr ($$0, RSTART+1, RLENGTH-2) }' | tail -n 1)"
And finally afer all of it I got error "The following build commands failed:
CopyPNGFile Debug-iphonesimulator/Test01.app/Default-568h#2x.png Test01.xcodeproj/Default-568h#2x.png"
This error occurred due to the fact that the system has two file xcrun. And script /Applications/Xcode.app/Contents/Developer/usr/bin/copypng starts one, which is a symbolic link. Then I changed path in this script
from:
my $PNGCRUSH = `xcrun -f pngcrush`;
to:
my $PNGCRUSH = `/usr/bin/xcrun -f pngcrush`;
And then I finally had built the project without errors and opened it in Xcode.
I had this stupid error and spent two days to nail down. I was about to downgrade Xcode and thought lets try one more time. Finally nailed down.
Symptom:
The simplest project wont build from Qt Creator. The error I would get: CopyPNG failed or something along the line and a hint '-f' unknown parameter.
Reason: xcrun takes both -f and -find from the terminal I can see, but it does not like -f from the script copypng. (copypng is a perl script by the way.)
The solution: Open the file /Applications/Xcode.app/Contents/Developer/usr/bin/copypng and find
my $PNGCRUSH = `xcrun -f pngcrush`;
changed to
my $PNGCRUSH = `xcrun -find pngcrush`;
PS: I dint have path problem with xcrun, if you have it'd be good to put the whole path as advised above.

Why can't ld called from MSYS find (existing static) library when arguments are read from a response #file containing backslashes?

This is basically the same issue as in mingw ld cannot find some library which is exist in the search path, MinGW linker can't find MPICH2 libraries - and I'm aware that there are heaps of posts on StackOverflow regarding the issue of static and dynamic linking with MinGW - but I couldn't find anything that explains how I can troubleshoot.
I am building a project with a huge linker command like (via g++) on MinGW, in a MSYS2 shell (git-bash.exe). The process fails with, among others:
/z/path/to/../../../../i686-w64-mingw32/bin/ld.exe: cannot find -lssl
I add -Wl,--verbose to the g++ linker call (to be passed to ld), and I can see for the -L/z/path/to/libs/openssl/lib/mingw -lssl:
...
attempt to open /z/path/to/libs/openssl/lib/mingw/libssl.a failed
...
/z/path/to/libs/openssl/lib/mingw/ssl.dll failed
attempt to open /z/path/to/libs/openssl/lib/mingw\libssl.a failed
...
But this is weird, because the file exists?
$ file /z/path/to/libs/openssl/lib/mingw/libssl.a
/z/path/to/libs/openssl/lib/mingw/libssl.a: current ar archive
(... and it was built with the same compiler on the same machine)?
Weirdly, once it attempts to open with forward slash .../libssl.a, once with backslash ...\libssl.a - but at least the first path checks out in a bash shell, as shown above?
It gets even worse if I try to specify -l:libssl.a -- or if I specify -L/z/path/to/libs/openssl/lib/mingw -Wl,-Bstatic -lssl -- instead; then all attempts to open are with a backslash:
...
attempt to open /z/path/to/scripts/other/build/openssl/build/mingw/lib\libssl.a failed
attempt to open /z/path/to/libs/openssl/lib/mingw\libssl.a failed
...
To top it all off, if I look it up manually through the command line using ld, it is found ?!:
$ ld -L/z/path/to/libs/openssl/lib/mingw -lssl --verbose
attempt to open Z:/path/to/libs/openssl/lib/mingw/libssl.dll.a failed
attempt to open Z:/path/to/libs/openssl/lib/mingw/ssl.dll.a failed
attempt to open Z:/path/to/libs/openssl/lib/mingw/libssl.a succeeded
Does anyone have an idea why this happens, and how can I get ld to finally find these libraries? Or rather - how can I troubleshoot, and understand why these libraries are not found, when they exist at the paths where ld tries to open them?
OK, found something more - not sure if this is a bug; but my problem is that I'm actually reading arguments from a file (otherwise I get g++: Argument list too long). So, to simulate that:
$ echo " -Wl,--verbose -L/z/path/to/libs/openssl/lib/mingw -lssl -lcrypto " > tmcd3
$ g++ #tcmd3 2>&1 | grep succeeded | grep ssl
# nothing
$ g++ `cat tcmd3` 2>&1 | grep succeeded | grep ssl
attempt to open Z:/path/to/libs/openssl/lib/mingw/libssl.a succeeded
attempt to open Z:/path/to/libs/openssl/lib/mingw/libcrypto.a succeeded
... it turns out, if the very same arguments are fed on the command line, then static library lookup succeeds - but if the arguments are read from file through the # at-sign, then static library lookup fails?! Unfortunately, I cannot use on my actual project, since even with cat, I'd still get g++: Argument list too long ... So how can I fix this?
MSYS has special handling of directories as arguments when they are used in the shell. This translates e.g. /<drive_letter>/blabla to the proper Windows style paths. This is to accomodate Unix programs that don't handle Z: style directory root.
What you see here is that MSYS isn't performing this interpretation for string read from a file. When you think about it, it's very logical, but as you have experienced first-hand, also sometimes annoying.
Long story short: don't put Unix style paths in files with command arguments. Instead, pass them through e.g. cygpath -w, which works in MSYS2 (which should be the MSYS that Git for Windows 2+ comes with).
Ok, with some more experiments, I noticed that:
-L/z/path/to/libs/openssl/lib/mingw, the Unix path specification, tends to fail - while if we specify the same, except starting with a Windows drive letter, that is:
-LZ:/path/to/libs/openssl/lib/mingw, then things work - also from an arguments file with # at-sign:
$ echo " -Wl,--verbose -LZ:/path/to/libs/openssl/lib/mingw -lssl -lcrypto " > tmcd3
$ g++ #tcmd3 2>&1 | grep succeeded | grep ssl
attempt to open Z:/path/to/libs/openssl/lib/mingw/libssl.a succeeded
attempt to open Z:/path/to/libs/openssl/lib/mingw/libcrypto.a succeeded
I guess, since the shell is MSYS2/git-bash.exe, entering full POSIX paths on the shell with /z/... is not a problem, because the shell will convert them - but in a file, there is nothing to convert them, so we must use Windows/MingW convention to specify them...

How to make gcov to read abc.pic.gcda and abc.pic.gcno files

Hi I am using gcov (GCC) 4.1.2 20080704 (Red Hat 4.1.2-51)
When I run gcov I am getting errors like "cannot open graph file". (My gcno and gcda file are created with name as abc.pic.gcda and abc.pic.gcno). But when I rename these files by removing "pic" (abc.gcda and abc.gcno) gcov is working fine. My question is: how to make gcov to read the files which are named like abc.pic.gcda and abc.pic.gcno?
Looks like you have file like abc.pic.cpp
and when you compile it
$ g++ --coverage abc.pic.cpp
$ ls
abc.pic.cpp abc.pic.gcno a.out
File abc.pic.gcno is created as you see. Next run binary
$ ./a.out
$ ls
abc.pic.cpp abc.pic.gcda abc.pic.gcno a.out
And run gcov:
$ gcov abc.pic
abc.gcno:cannot open graph file
$ gcov abc
abc.gcno:cannot open graph file
As you can see there is an error. To make it working you should provide full filename like
$ gcov abc.pic.cpp
File 'abc.pic.cpp'
Lines executed:100.00% of 6
abc.pic.cpp:creating 'abc.pic.cpp.gcov'

Which dart2js command is launched by DartEditor?

After reading article found at https://www.dartlang.org/articles/web-ui/tools.html, I tried to compile my application by following it.
My application stored in web/app.html can be successfully compiled to Javascript under DartEditor by using "Run as Javascript" command.
When I try to use following command lines to perform a compilation for deploying in production, I encounter an issue on uncopied package part file.
$ dart --package-root=packages/ packages/web_ui/dwc.dart --out /tmp/dart/ --no-rewrite-urls web/app.html
$ ls lib/app/
model_browser.dart model_server.dart
$ ls lib/app/src/model/
model_browser.dart model_server.dart model_shared.dart
$ cd /tmp/dart
$ dart2js -v app.html_bootstrap.dart --package-root=packages/ -oapp.html_bootstrap.dart.js
...
info: scanning library file:///private/tmp/dart/_from_packages/bm/model_browser.dart
_from_packages/app/model_browser.dart:12:1: Error: Cannot read "_from_packages/app/src/model/model_shared.dart" (OS Error: No such file or directory, errno = 2).
part 'src/model/model_shared.dart';
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
info: Error: compiler cancelled: Error: Cannot read "_from_packages/app/src/model/model_shared.dart" (OS Error: No such file or directory, errno = 2).
...
$ ls _from_packages/app/
model_browser.dart model_browser.dart.map
$ ls _from_packages/app/src/model/
model_browser.dart model_browser.dart.map
In fact, "model_shared.dart" file isn't copied into /tmp/dart/_from_packages/app/src/model/model_shared.dart.
The content of model_browser.dart is following
library model;
import 'dart:json' as json;
import 'package:bm/i18n.dart' as i18n;
import 'package:logging/logging.dart';
import 'package:web_ui/web_ui.dart';
part 'src/model/model_shared.dart';
part 'src/model/model_browser.dart';
DartEditor can launch my application as Javascript. What is the right command line for launching dart2js in order to take into account the "part" statements of my "model" library ?
The issue is linked to "--no-rewrite-urls" option and the absolute path in --out option.
If I remove the "--no-rewrite-urls" option and put a relative path in --out option, the dart2js compilation is successfully done.

Xcode Build error, arm-apple-darwin11-gcc-4.2.1 execvp: No such file or directory

After upgrading to Xcode 4.3.2. I'm getting a metric ton of build errors.
A whole line of them are error code 255
gcc-4.2: error trying to exec '/usr/bin/arm-apple-darwin11-gcc-4.2.1': execvp: No such file or directory
Command /usr/bin/gcc-4.2 failed with exit code 255
I noticed that there is no /usr/bin/arm-apple-darwin11-gcc-4.2.1 file on my machine. Could this be the source of the problem?
What's the output of this command?
$ printenv | grep "CC="
It might be honoring your C Compiler (CC) selection. I was getting similar errors (through cocoapods) and doing an
$ export CC=
fixed it for me.

Resources