Ask Your Question
0

ROS2 Windows can't add dependency, fatal error LNK1107: invalid or corrupt file

asked 2020-10-12 19:55:36 -0500

JoelB gravatar image

I am trying to use the ctre phoenix c++ library. This worked fine when using catkin in Ubuntu, but I recently made the switch to ROS2 and am developing in windows, and now I get this error:

      hello.cpp
    hello.obj : error LNK2019: unresolved external symbol "int __cdecl ctre::phoenix::platform::can::SetCANInterface(char const *)" (?SetCANInterface@can@platform@phoenix@ctre@@YAHPEBD@Z) referenced in function main [F:\dev\colcon_ws\build\lunabotics2021\hello.vcxproj]
    F:\dev\colcon_ws\src\lunabotics2021\lib\x86-64\libCTRE_Phoenix.a : fatal error LNK1107: invalid or corrupt file: cannot read at 0x56FF0 [F:\dev\colcon_ws\build\lunabotics2021\hello.vcxproj]
    listen.cpp
    listen.vcxproj -> F:\dev\colcon_ws\build\lunabotics2021\Release\listen.exe


Failed   <<< lunabotics2021 [21.2s, exited with code 1]
---

Here is my CMakeLists.txt:

cmake_minimum_required(VERSION 3.5)
project(lunabotics2021)

# Default to C99
if(NOT CMAKE_C_STANDARD)
  set(CMAKE_C_STANDARD 99)
endif()

# Default to C++14
if(NOT CMAKE_CXX_STANDARD)
  set(CMAKE_CXX_STANDARD 14)
endif()

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  add_compile_options(-Wall -Wextra -Wpedantic)
endif()

#set(phoenix_DIR "F:/dev/colcon_ws/src/lunabotics2021/include/ctre")

#////////////////////////////////////////////////////////////////
# STEP 1: ADD DEPENDENCIES///////////////////////////////////////
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(std_msgs REQUIRED)
#find_package(phoenix REQUIRED)

# STEP 2: ADD EXECUTABLE AND AMENT DEPENDENCIES/////////////////

add_executable(hello src/hello.cpp)
ament_target_dependencies(hello rclcpp std_msgs)

add_executable(listen src/listen.cpp)
ament_target_dependencies(listen rclcpp std_msgs)

target_include_directories(hello PUBLIC
    $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
  $<INSTALL_INTERFACE::include>)

target_include_directories(listen PUBLIC
    $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
    $<INSTALL_INTERFACE::include>)

# STEP 3: ADD INSTALL///////////////////////////////////////////

install(TARGETS hello DESTINATION lib/${PROJECT_NAME})
install(TARGETS listen DESTINATION lib/${PROJECT_NAME})

#////////////////////////////////////////////////////////////////



if(BUILD_TESTING)
  find_package(ament_lint_auto REQUIRED)
  # the following line skips the linter which checks for copyrights
  # uncomment the line when a copyright and license is not present in all source files
  #set(ament_cmake_copyright_FOUND TRUE)
  # the following line skips cpplint (only works in a git repo)
  # uncomment the line when this package is not in a git repo
  #set(ament_cmake_cpplint_FOUND TRUE)
  ament_lint_auto_find_test_dependencies()
endif()

target_link_libraries(hello F:/dev/colcon_ws/src/lunabotics2021/lib/x86-64/libCTRE_Phoenix.a)
target_link_libraries(hello F:/dev/colcon_ws/src/lunabotics2021/lib/x86-64/libCTRE_PhoenixCanutils.a)
target_link_libraries(hello F:/dev/colcon_ws/src/lunabotics2021/lib/x86-64/libCTRE_PhoenixCCI.a)
target_link_libraries(hello F:/dev/colcon_ws/src/lunabotics2021/lib/x86-64/libCTRE_PhoenixPlatformLinuxSocketCan.a)

ament_package()

Any ideas what is wrong, or is there a better way to be doing this?

edit retag flag offensive close merge delete

Comments

1

@JoelB, it looks like you acquired the libraries from this repository. Those are Linux specific libraries and not binary compatible with Windows system. I'd recommend to contact the repository owner on GitHub and see if they have the Windows equivalent ones for your development.

Sean Yen gravatar image Sean Yen  ( 2020-10-13 22:49:03 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2020-10-17 15:35:45 -0500

JoelB gravatar image

updated 2020-10-18 13:21:12 -0500

Yep, totally had the wrong library. Got the windows version and it worked great. Thanks a lot!

I got the correct library by using the phoenix framework installer found here: http://www.ctr-electronics.com/contro...

edit flag offensive delete link more

Comments

It would be good to mention where you downloaded the Windows version from.

gvdhoorn gravatar image gvdhoorn  ( 2020-10-18 02:28:36 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2020-10-12 19:55:36 -0500

Seen: 29 times

Last updated: Oct 18