Reputation: 117
I'm trying to build drake with Gurobi and am getting several issues. I should note that I am treating drake as a package in my ROS workspace, and that has been working well so far.
--config=gurobi
, and running a test file, I get the error:/home/user/test_ws/devel/lib/simple_test/simple_test: error while loading shared libraries: libdrake_lcm.so: cannot open shared object file: No such file or directory
This doesn't happen when I omit --config=gurobi
.
Traceback (most recent call last):
File "/home/user/test_ws/build/drake/_bazel_user/c0701f1e1e0381b11260fb3e4da5ea58/execroot/drake/bazel-out/k8-opt/bin/install.runfiles/drake/tools/install/installer.py", line 485, in <module>
main(sys.argv[1:])
File "/home/user/test_ws/build/drake/_bazel_user/c0701f1e1e0381b11260fb3e4da5ea58/execroot/drake/bazel-out/k8-opt/bin/install.runfiles/drake/tools/install/installer.py", line 478, in main
exec(f'installer.{action}')
File "<string>", line 1, in <module>
File "/home/user/test_ws/build/drake/_bazel_user/c0701f1e1e0381b11260fb3e4da5ea58/execroot/drake/bazel-out/k8-opt/bin/install.runfiles/drake/tools/install/installer.py", line 169, in install
self.copy_or_link(src, dst_full)
File "/home/user/test_ws/build/drake/_bazel_user/c0701f1e1e0381b11260fb3e4da5ea58/execroot/drake/bazel-out/k8-opt/bin/install.runfiles/drake/tools/install/installer.py", line 145, in copy_or_link
os.symlink(relative_link, dst)
FileExistsError: [Errno 17] File exists: './libgurobi.so.9.5.2' -> '/home/user/test_ws/install/lib/libgurobi95.so'
Manually deleting that existing file solved the issue, but having to constantly remove this file is problematic.
[UPDATE]
I'm now explaining my current build setup. I have a ros workspace organized as
test_ws/
build/
devel/
...
src/
drake/
simple_test/
CMakeLists.txt
package.xml
test.cpp
My CMakeLists.txt
contains the following:
cmake_minimum_required(VERSION 3.0.2)
project(simple_test)
execute_process(COMMAND ${CMAKE_C_COMPILER} -fuse-ld=gold -Wl,--version ERROR_QUIET OUTPUT_VARIABLE ld_version)
if ("${ld_version}" MATCHES "GNU gold")
message("USING GOLD LINKER!")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=gold -Wl,--disable-new-dtags")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fuse-ld=gold -Wl,--disable-new-dtags")
endif()
add_compile_options(-std=c++14 -g -DEIGEN_NO_DEBUG -Werror=return-type) #with debugging symbols
find_package(drake REQUIRED PATHS /home/user/test_ws/src/drake/build/install)
find_package(catkin)
catkin_package()
add_executable(simple_test test.cpp)
target_link_libraries(simple_test drake::drake)
Upvotes: 0
Views: 122
Reputation: 2449
For (1), I cannot repro.
First, I installed Drake latest master via this:
env GUROBI_HOME=/home/jwnimmer/Downloads/gurobi951/linux64 \
bazel run //:install --config=gurobi -- /home/jwnimmer/tmp/wakka
This should be identical to running cmake && make install
to that folder.
Then, I build and link a sample program:
jwnimmer@call-cps:~/tmp/wakka$ cat main.cc
#include "drake/common/find_resource.h"
int main() {
drake::FindResourceOrThrow(
"drake/manipulation/models/iiwa_description/urdf/"
"iiwa14_primitive_collision.urdf");
return 0;
}
jwnimmer@call-cps:~/tmp/wakka$ g++ --std=c++17 main.cc -Iinclude -Llib -Wl,-rpath -Wl,$(pwd)/lib -ldrake -omain
jwnimmer@call-cps:~/tmp/wakka$ ./main; echo $?
0
The linking seems fine:
jwnimmer@call-cps:~/tmp/wakka$ readelf -d main
Dynamic section at offset 0x3cf0 contains 31 entries:
Tag Type Name/Value
0x0000000000000001 (NEEDED) Shared library: [libdrake.so]
0x0000000000000001 (NEEDED) Shared library: [libstdc++.so.6]
0x0000000000000001 (NEEDED) Shared library: [libgcc_s.so.1]
0x0000000000000001 (NEEDED) Shared library: [libc.so.6]
0x000000000000001d (RUNPATH) Library runpath: [/home/jwnimmer/tmp/wakka/lib]
...
jwnimmer@call-cps:~/tmp/wakka$ ldd main
linux-vdso.so.1 (0x00007ffe2c491000)
.... nothing is shown as 'missing' ...
To help, you'll probably need to share a reproducible sample of how you're building.
Upvotes: 0
Reputation: 2449
I haven't looked into the first problem yet.
For the second problem, I think is a bug in Drake's install program (see https://github.com/RobotLocomotion/drake/issues/18007). But in any case, never try to install Drake twice in a row, it is unsound. You should always rm
the old install before trying a new one.
Upvotes: 0