MacOS: g++ cross-compiler cannot find ld from dmg image

153 views Asked by At

When I compile the sources from just a directory it's OK. But if I do it from dmg image I got this:

$ make
"/Volumes/:Users:me:develop:macos_build_script:myApp:myApp_Release:myApp/myApp.app/Contents/MacOS/devkit-x86/sysroots/i386-pokysdk-darwin/usr/bin/i586-poky-linux/i586-poky-linux-g++" -std=c++11 -Wall -O2 --sysroot="/Volumes/:Users:me:develop:macos_build_script:myApp:myApp_Release:myApp/myApp.app/Contents/MacOS/devkit-x86/sysroots/core2-32-poky-linux" -c -MD main.cpp -I/Volumes/:Users:me:develop:macos_build_script:myApp:myApp_Release:myApp/myApp.app/Contents/MacOS/devkit-x86/sysroots/core2-32-poky-linux/usr/include/c++/4.9.1 -I/Volumes/:Users:me:develop:macos_build_script:myApp:myApp_Release:myApp/myApp.app/Contents/MacOS/devkit-x86/sysroots/core2-32-poky-linux/usr/include/c++/4.9.1/i586-poky-linux -o main.o
"/Volumes/:Users:me:develop:macos_build_script:myApp:myApp_Release:myApp/myApp.app/Contents/MacOS/devkit-x86/sysroots/i386-pokysdk-darwin/usr/bin/i586-poky-linux/i586-poky-linux-g++" -std=c++11 -Wall -O2 --sysroot="/Volumes/:Users:me:develop:macos_build_script:myApp:myApp_Release:myApp/myApp.app/Contents/MacOS/devkit-x86/sysroots/core2-32-poky-linux" main.o -I/Volumes/:Users:me:develop:macos_build_script:myApp:myApp_Release:myApp/myApp.app/Contents/MacOS/devkit-x86/sysroots/core2-32-poky-linux/usr/include/c++/4.9.1 -I/Volumes/:Users:me:develop:macos_build_script:myApp:myApp_Release:myApp/myApp.app/Contents/MacOS/devkit-x86/sysroots/core2-32-poky-linux/usr/include/c++/4.9.1/i586-poky-linux -lopencv_core -lopencv_highgui -lopencv_imgproc -lzmq -o aaa.bin
collect2: fatal error: cannot find 'ld'
compilation terminated.
make: *** [aaa] Error 1

After this error I unpack contents from *.dmg then run it and compilation completes successful.

Why and what I need to do to make it work from dmg?

My *.dmg contains an application and a cross-compiler. Source files for compilation are outside and created by this application. It is simple IDE.

1

There are 1 answers

0
Kroll On BEST ANSWER

Finaly I find out the cause of this problem. It is two bug-or-features one in macdeployqt and one in g++.

When I wrote my building script I thought it will be good to get dmg image in same directory from which I run my script. And I added a command with absolute path:

macdeployqt /Users/me/develop/macos_build_script/myApp/myApp_Release/myApp/myApp.app -dmg

The image was built and my app ran well. But. Silently macdeployqt made a name for dmg mount point from absolute path. The absolute path became a single directory name with colons instead slashes: :Users:me:develop:macos_build_script:myApp:myApp_Release:myApp. The root of dmg did not contain this directory, it only appears when dmg image is mounted.

Then this directory with colons will be part of variables of makefile.

Cross-compilator i586-poky-linux-g++ builds an object files when paths with colons present. And I thought it's all ok with g++ if it using this coloned paths for object files. I thought the cause somwhere in other place. But I was wrong.

Backslashing of colons din't help.

In some moment I builded the dmg image by hands from a directory in which myApp.app bundle subdirectory placed with this short command:

macdeployqt myApp.app -dmg

And the problem is gone. The mount point of dmg image now is just /Volumes/myApp. I do nothing except jump to dir where myApp.app is and making the relative path.