Micro-XRCE-DDS-Agent icon indicating copy to clipboard operation
Micro-XRCE-DDS-Agent copied to clipboard

Cannot use cmake to install in local prefix

Open Ryanf55 opened this issue 2 years ago • 6 comments

Issue template

  • Hardware description: N/A
  • OS: Ubuntu 22.04
  • Installation type: local prefix install
  • Version or commit hash: v2.3.0

Steps to reproduce the issue

After cloning

git clone <repo>
cd Micro-XRCE-DDS-Agent
cmake -S . -B build 
cmake --build build
cmake --install build --prefix install

Expected behavior

Everything gets installed in the local directly install rather than globally in my system. I would like to set my own install prefix using standard CMake options.

Actual behavior

It tries to write to a system directory and fails.

-- Up-to-date: /home/ryan/Documents/Micro-XRCE-DDS-Agent/install/share/microxrcedds_agent/cmake/microxrcedds_agentConfig.cmake
-- Up-to-date: /home/ryan/Documents/Micro-XRCE-DDS-Agent/install/share/microxrcedds_agent/cmake/microxrcedds_agentConfigVersion.cmake
-- Up-to-date: /usr/local
CMake Error at build/cmake_install.cmake:165 (file):
  file INSTALL cannot set permissions on "/usr/local": Operation not
  permitted.

And, on that line in build/cmake_install.cmake: file(INSTALL DESTINATION "/usr/local" TYPE DIRECTORY FILES "/home/ryan/Documents/Micro-XRCE-DDS-Agent/build/temp_install/fastcdr-1.0.26/" USE_SOURCE_PERMISSIONS)

Additional information

Why is this desired? Well, I want to install the agent on my computer, but not write to my system headers. I like to reserve writing to root access files with package managers like debian only. Why don't I use debian? Well, I want to contribute here, so I need to compile and run locally :)

Ryanf55 avatar Feb 20 '23 04:02 Ryanf55

This is not desired. If you have a patch please feel free to contribute.

In the meanwhile I have found no problem with:

mkdir build
cd build
cmake .. -DCMAKE_INSTALL_PREFIX=../install
make
make install

pablogs9 avatar Feb 20 '23 06:02 pablogs9

Thanks for that workaround, it worked!

I did try debugging, and also turned on -v flag for install, but there was no extra information. I am not sure how I can help any further; at least the team knows about the issue.

Once I installed according to your instructions, the microcrcedds_agent object file cannot be found.

cd ../install/bin
 ./MicroXRCEAgent udp4 --help
./MicroXRCEAgent: error while loading shared libraries: libmicroxrcedds_agent.so.2.3: cannot open shared object file: No such file or directory

Ryanf55 avatar Feb 20 '23 13:02 Ryanf55

AFAIK you need to add this folder to LD_LIBRARY_PATH

pablogs9 avatar Feb 20 '23 13:02 pablogs9

Ah, like so.

cd Micro-XRCE-DDS-Agent/install$ LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PWD/lib/ ./bin/MicroXRCEAgent udp4
Warning: '--port <value>' is required
Usage: 'MicroXRCEAgent <udp4|udp6|tcp4|tpc6|canfd|serial|multiserial|pseudoterminal> <<args>>'
For a more detailed description about all the available arguments, please execute the agent with '-h/--help' option.

Ryanf55 avatar Feb 20 '23 13:02 Ryanf55

that's now it is working

pablogs9 avatar Feb 20 '23 13:02 pablogs9

Thanks, I'll run with this. Do you mind leaving the issue open since the workflow I posted should theoretically be the same result as calling make directly?

Ryanf55 avatar Feb 20 '23 13:02 Ryanf55