Cross-compilation, CMake and Symlinks

Sysprogs forums Forums VisualGDB Cross-compilation, CMake and Symlinks

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #22349
    fifo_thekid
    Participant

    So I’m using this guide to cross-compile OpenCV for Raspberry Pi:

    https://visualgdb.com/tutorials/raspberry/opencv/build/ I’m doing that mainly because building anything on RPi is much slower than on Windows, and because I need the remote debugging tools of Visual Studio. Everything worked as expected especially with the advanced CMake subsystem of VisualGDB. However, when I reached the deployment step I faced some annoyances.

    First, SmarTTY could not upload to the /usr directory because there is no way to apply the sudo command in the application. I could copy everything to the /home/pi directory and then I copied everything recursively to /usr, which worked like a charm! I got remote debugging working and compiled applications picked up all the required dependencies. I don’t know if there is an alternative to manually copying the files though.

    The second annoyance was when I did used the ldconfig command:

    pi@raspberrypi:~ $ sudo ldconfig

    ldconfig: /usr/lib/libopencv_calib3d.so.4.0 is not a symbolic link

    …..

    pi@raspberrypi:/usr/lib $ ls libopencv_calib3d.* -al

    -rwxr-xr-x 1 root root 9832912 Oct 17 18:16 libopencv_calib3d.so

    -rwxr-xr-x 1 root root 9832912 Oct 17 18:17 libopencv_calib3d.so.4.0

    -rwxr-xr-x 1 root root 9832912 Oct 17 18:16 libopencv_calib3d.so.4.0.0

    As you can see, instead of creating one .so file and several symbolic links, it creates multiple copies of the same file. This is basically because Windows does not support symlinks. Now there are several adhoc solutions, like scripts that convert duplicate files to symlinks but this doesn’t really look like a reliable approach. How do you solve this kind of problem in your day to day cross-compilation tasks?

    #22350
    support
    Keymaster

    Hi,

    We would advise using VisualGDB. It will automatically handle symlinks when synchronizing the sysroot and will also upload the directories correctly when building projects.

    #22388
    fifo_thekid
    Participant

    I’m using VisualGDB! But how am I supposed upload the new contents? in the case of OpenCV, the make install command does not install to the sysroots directory. Please have a look at your tutorial. It suggests using SmarTTY which doesn’t work

    #22404
    support
    Keymaster

    Hi,

    Sorry for the confusion. Indeed several internals of OpenCV have changed since we published the tutorial.

    We have updated the tutorial to reflect the latest OpenCV version, and also added a few usability improvements to VisualGDB (like automatic deployment of the binaries installed by CMake). Please try this build and follow the updated tutorial from the beginning. It should be much easier now.

    #22422
    fifo_thekid
    Participant

    Worked like a charm!

    I still had to replace the dups with symlinks using

    sudo fdupes -n -1 -o ‘name’ /usr/local/lib | while read line; do master=””; for file in ${line[*]}; do if [ “x${master}” == “x” ]; then master=$file; else ln -f “${master}” “${file}”; fi; done; done

    And I wish that you would highlight the parts that were updated, and the publishing date. It was impossible for me to know what did you change exactly.

    #22423
    support
    Keymaster

    Hi,

    Good to know it works. Sorry, our interface for viewing the tutorials doesn’t show the changes, as the old steps won’t be relevant for the users that started with the new version of the tutorial.

    We have modified the publishing date to make it explicit that the tutorial was updated.

    #22427
    fifo_thekid
    Participant

    is it possible to add my script above as a post installation script?

    what about make uninstall?

    how is it implemented?

    oh and one last question: how to I subscribe to threads on this forum?

    #22430
    support
    Keymaster

    Hi,

    You should be able to add it via VisualGDB Project Properties -> Build Customization -> Post-Build Steps (requires the Custom edition).

    Although CMake itself doesn’t support uninstalling targets (and it won’t work for the deployed files), you can add a custom shortcut (will appear under the Project menu when your project is active) via VisualGDB Project Properties that will run arbitrary commands of your choice (e.g. deleting a specific set of directories).

    With the forum subscription, we had issues with it before due to email servers treating the notification emails as spam. We have re-enabled it for now, but we may have to turn it off again if the problem with the mail servers returns.

    #22441
    fifo_thekid
    Participant

    Do Post-Build Steps run on the target machine? I’m currently experimenting with symlinks on Windows to see whether they can solve the problem.

    And that Custom Edition, is it available for preview/trial?

    As for uninstalling, on OpenCV running “make uninstall” would remove the exact files installed by “make install”. I really wish that there is a way to do it with VisualGDB.

    #22443
    support
    Keymaster

    Hi,

    The post-build steps can run on any machine of your choice – they are fully customizable. If you are currently using VisualGDB trial, this feature should be already enabled. If you have already purchased a Linux edition key, please contact our sales to get a trial extension voucher so you could try out the Custom edition features.

    Supporting “make uninstall” out-of-the-box would be tricky. As CMake scripts run on the Windows machine, it would involve running it locally, recording the exact steps it does trying to replay them on a remote machine (or simply removing all files previously installed by VisualGDB). We might be able to eventually support it, but given the complexity and the limited scope of this, it won’t be included in v5.4, sorry.

    That said, we can help you setup the correct custom actions to do the uninstallation as a custom shortcut. Let us know if you run into any difficulties and we will help.

Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.