How to correctly compile a C# package?
Hello!
I have trouble building a C# package due to the error:
/home/berln/projects/ros/roscsharp/hello_world/src/hello.cs(3,7): error CS0246: The type or namespace name `RosCS' could not be found. Are you missing a using directive or an assembly reference?
I created a simple C# package by
berln@berln-Signor:~/projects/ros/roscsharp$ roscreate-pkg hello_world
Then I edited manifest.xml and added this line.
<depend package="roscs"/>
And the last thing I changed is CMakeLists.txt, and I added these three lines:
rosbuild_include(roscs cncs)
CSHARP_ADD_TARGET_DEPENDENCY(hello Mono.C5)
CSHARP_ADD_EXE(hello src/hello.cs)
Here's the src/hello.cs:
using System;
using System.Threading;
using RosCS;
public class RosCsHello
{
Node node;
public RosCsHello()
{
this.node = Node.MainNode;
}
public void Run()
{
while(RosSharp.Ok())
{
Console.WriteLine("Hello");
}
}
static public void Main ()
{
RosSharp.Init("ROSCS_hello",args);
RosCsHello hello = new RosCsHello();
hello.Run();
}
}
But when I compile, the compiler would complain that it cannot find RosCS, I don't know why this happens?
EDIT:
I followed what Alireza suggested, I first modify my CMakeLists.txt, and then remove Makefile autogenerated by roscreate-pkg.After that, I cmake CMakeLists.txt, then make.
But I got this error message:
[ 14%] Creating Csharp Wrapper Code
Querying Ros for messages...
Message: Name: Logger NameSpace: roscpp/
Start generating...
Path for generating files : /home/rosfuerte/project/ros/my_package/roscs_try/msg_cs_gen!
Total msges: 1
Cleaning before...
Template: /home/rosfuerte/project/ros/important_packages/cn-roscs-ros-pkg/roscs/templates/messages/Message.cs
Template: /home/rosfuerte/project/ros/important_packages/cn-roscs-ros-pkg/roscs/templates/messages/Node.cs
Template: /home/rosfuerte/project/ros/important_packages/cn-roscs-ros-pkg/roscs/templates/messages/Publisher.cs
Template: /home/rosfuerte/project/ros/important_packages/cn-roscs-ros-pkg/roscs/templates/messages/RosSharp.cs
Template: /home/rosfuerte/project/ros/important_packages/cn-roscs-ros-pkg/roscs/templates/messages/Timer.cs
Template: /home/rosfuerte/project/ros/important_packages/cn-roscs-ros-pkg/roscs/templates/messages/roscs.cpp
Template: /home/rosfuerte/project/ros/important_packages/cn-roscs-ros-pkg/roscs/templates/messages/Subscriber.cs.pm
make[2]: *** No rule to make target `lib/std_msgs.Messages.dll', needed by `lib/roscs_try.Communication.dll'. Stop.
make[1]: *** [CMakeFiles/CSharp_myExe_exe.dir/all] Error 2
make: *** [all] Error 2
This is my CMakeLists.txt
cmake_minimum_required(VERSION 2.4.6)
include($ENV{ROS_ROOT}/core/rosbuild/rosbuild.cmake)
rosbuild_init()
rosbuild_include(roscs cncs)
rosbuild_gen_cs_msg()
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)
CSHARP_ADD_TARGET_DEPENDENCY(myExe Mono.C5)
CSHARP_ADD_EXE(myExe src/tmp.cs)
Does anyone have ideas about how this problem can be solved? Any thought or advice would be appreciated!