Award
Congratulations ptp, for answering the question and has received an EZ-Credit award! Share what you have learned and create a tutorial to help others by clicking here.

Ez_b Namespace In New C++ Project

Assistance Requested

Help larschrjensen with their question and receive $10 of EZ-Credit to get more robots and parts from our store. The following information was provided about their previous efforts searching tutorials for a resolution.

larschrjensen claims to have checked these sources:
 
#1

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:

Code:


CMAKE_MINIMUM_REQUIRED(VERSION 2.8.9)
SET(PROJECTNAME ez)
PROJECT(${PROJECTNAME})

find_package(YARP)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${YARP_MODULE_PATH})

include_directories(${YARP_INCLUDE_DIRS})
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?

I have found a few conversations, tutorials and activities that may help with your question. Take a look at these links. I've sorted them by what I believe to be most relevant but that is not always the case as I'm still learning.


Also, consider reviewing the Learn section for informative lessons and activities. Check it out!


#2

Lars,

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:

Code:


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



to include .net references:

Code:


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.

#3

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 Smile

Best regards,
Lars

#4

@larschrjensen

Can you drop me an email, i would like to exchange some ideas how to integrate with the yarp framework.

my email (is in my profile):

https://www.ez-robot.com/User/ptp/Profile/

Thanks

#5

@ptp

I've sent you an email!