Asked — Edited
Resolved Resolved by ptp!

Ez_B Namespace In New C++ Project

I am having some trouble getting visual studio (vs2013) to recognize the EZ_B namespace in a new c++ project. It works fine in the Example Project from the SDK though. However, because of other components (specifcally YARP) I need to compile using CMake. My CMakeLists.txt looks like this:



add_executable(ez ez.cpp)
target_link_libraries(ez ${YARP_LIBRARIES})

So, can I include the EZ_B.dll already in cmake, and if not how can I add it to the solution that cmake generates?


Upgrade to ARC Pro

Stay on the cutting edge of robotics with ARC Pro, guaranteeing that your robot is always ahead of the game.



In c++ world: To allow an executable to load/execute a DLL you need implicit (or explicit) link, for that you need to obtain a header file .h which contains the classes/declarations and you need a .LIB file which is used by the linker to create the call references between your code and the external lib.

there are cmake commands to specify the header and library location(s)

BUT you are not in c++ world, EZ_B is not a regular c++ library is a .NET managed library and can't be used as a regular library linked to plain c++ code.

what you have in ez.cpp is a c++/CLI extensions, which only visual studio can understand and compile, also you need to pass compiler directives to the visual studio.

In your cmake i don't see specific commands for the visual studio.

some examples:

clr compilation and exception management:

set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "/clr /EHa") 

to include .net references:

set_target_properties(${PROJECT_NAME} PROPERTIES VS_DOTNET_REFERENCES "System;System.Core;WindowsBase;${CMAKE_CURRENT_SOURCE_DIR}/../3rdParty/EZ_B.dll;")

probably you will need more commands, but at least those two are missing.


Hi ptp,

Yes I know it's a pain, but there's no way around c++ at the time.

However, your feedback did the trick. Thanks a lot. Just made my life a bit easier:)

Best regards, Lars