Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build error on UWP #63

Open
quattrinili opened this issue May 17, 2020 · 10 comments
Open

Build error on UWP #63

quattrinili opened this issue May 17, 2020 · 10 comments
Assignees

Comments

@quattrinili
Copy link

quattrinili commented May 17, 2020

There is an issue for the UWP build of ros2_dotnet. In particular, the error is on fastrtps and the problem seems to be related to perhaps some differences in libraries and non-compatibility with UWP as it gives some syntax errors:

e.g., error C2332: 'struct': missing tag name (compiling source file ros2-uwp\src\eProsima\Fast-RTPS\src\cpp\transport\TCPAcceptorSecure.cpp)

Some context for the compilation:

  • this is the command I am running colcon build --merge-install --packages-ignore rmw_fastrtps_dynamic_cpp rcl_logging_log4cxx rcl_logging_spdlog ros2trace tracetools_launch tracetools_read tracetools_test tracetools_trace --cmake-args -A x64 -DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_SYSTEM_VERSION=10.0.17134 -DTHIRDPARTY=ON -DINSTALL_EXAMPLES=OFF -DBUILD_TESTING=OFF -DRCL_LOGGING_IMPLEMENTATION=rcl_logging_noop --event-handlers console_cohesion+
  • I am running this with the repos file for UWP: https://github.com/ros2-dotnet/ros2_dotnet/blob/master/ros2_dotnet_uwp.repos thus I am using the Fast-RTPS fork (https://github.com/ros2-dotnet/Fast-RTPS)
  • I am compiling on Windows 10 with Visual Studio 2017.

Note that the Desktop ros2_dotnet compiles fine. My sense is that the problem might be on the ASIO library, and I tried to get the uwp version with vcpkg .12.2-2, but still without success.

(Split from comments on issue #55)

@mcevoyandy
Copy link

@quattrinili were you able to resolve this issue? I've got the same problem.

@theseankelly
Copy link
Member

theseankelly commented May 20, 2020

Hey @quattrinili and @mcevoyandy

Quick thought from my side -- have you used ROS2 on Windows before (and thus, have you installed all the nuget package dependencies necessary for the Desktop install?). I've noticed that if cmake can find them on the system, then the FastRTPS cmake script will not clone its own copies, and you'll end up pulling in the non-UWP libraries to the build which can cause build and/or runtime errors.

Uninstall all ROS2 third party dependencies that the ROS2 installation instructions had to install (libasio, tinyxml, log4cxx, etc). The repos files (for UWP) are completely standalone, and the -DTHIRDPARTY=ON flag is specifically for FastRTPS - it checks out and builds its own copy of all dependent libraries. Doing it this way ensures the dependencies are also UWP ready.

@theseankelly
Copy link
Member

Oh and uninstall OpenSSL as well -- my memory is foggy but I believe if OpenSSL is not present, FastRTPS will not build with security enabled (and your build error is in something called "TCPAcceptorSecure")

@esteve
Copy link
Member

esteve commented May 20, 2020

@quattrinili @mcevoyandy yes, @theseankelly is right, uninstall OpenSSL for now. The reason for this failing is that TCPAcceptorSecure uses interface as a variable name, but that is defined in windows.h as a typedef for something else. However, because we don't install OpenSSL in CI, we didn't see this issue.

I'm updating our fork of Fast-RTPS to not build the security stuff if targeting UWP.

@esteve
Copy link
Member

esteve commented May 20, 2020

I've disabled support for the security extensions in FastRTPS if building for UWP in ros2-dotnet/Fast-RTPS@40072bb

@quattrinili @mcevoyandy could you try again with an updated copy of our fork of FastRTPS?

Thanks!

@esteve esteve self-assigned this May 20, 2020
@mcevoyandy
Copy link

mcevoyandy commented May 20, 2020

Thanks for the fast response! This enabled fastrtps to build properly :)

Here's the steps I followed:

  1. Windows > Add or Remove Programs > OpenSSL > uninstall
  2. Remove PATH variable set for OpenSSL
  3. in cmd: > choco uninstall asio
  4. Remove build, install, log folders from previous build attempts
  5. Repeated install instructions

@quattrinili
Copy link
Author

I forgot that I had OpenSSL and I uninstalled it. The error related to it disappeared. However, unfortunately, I am still having problems, this time with linking with a link with foonathan_memory. I am digging into it.

foonathan_memory-0.6.2.lib(virtual_memory.obj) : error LNK2019: unresolved external symbol __imp_VirtualAlloc referenced in function "void * __cdecl foonathan::memory::traits_detail::allocate_node<class foonathan::memory::virtual_memory_allocator>(struct foonathan::memory::traits_detail::full_concept,class foonathan::memory::virtual_memory_allocator &,unsigned __int64,unsigned __int64)" (??$allocate_node@Vvirtual_memory_allocator@memory@foonathan@@@traits_detail@memory@foonathan@@YAPEAXUfull_concept@012@AEAVvirtual_memory_allocator@12@_K2@Z)

@quattrinili
Copy link
Author

Ok, found the problem: it is in the foonathan/memory, which uses VirtualAlloc, however UWP does not support it. Instead, VirtualAllocFromApp should be used, and that works also for Windows Desktop app (see https://docs.microsoft.com/en-us/windows/win32/api/memoryapi/nf-memoryapi-virtualallocfromapp). I modified it in my fork https://github.com/quattrinili/memory -- I plan to submit a pull request for foonathan/memory, but you are welcome to use it if you would like in the meanwhile.

This allowed me to fully compile ros2_dotnet for UWP. I tried with a talker and a listener in a simple UWP app, and at least right now it is not crashing; though for some reasons, they are not able to communicate. I still get some DLLNotFoundException on rcl_dotnet_common. I will check a couple of other things.

@esteve
Copy link
Member

esteve commented May 25, 2020

@quattrinili

This allowed me to fully compile ros2_dotnet for UWP

That's great! Fast-RTPS introduced foonathan_memory as a dependency, but it's weird that our CI hasn't caught that. In any case. thanks! :-)

@quattrinili
Copy link
Author

Maybe it was working with a previous version of MSVC? I submitted the pull request upstream for foonathan memory, but I see that it fails with MSVC 14 (should be Visual Studio 2015). On my system, both VS 2017 and 2019 work. All these versions make it hard to ensure things work properly... :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants