ライブラリの競合について

2 posts / 0 new
Last post
take
Offline
Last seen: 6 years 1 month ago
Joined: 2018-03-20 17:29
ライブラリの競合について

こんにちは 私は大学でOpenRTMを利用して、開発を行っています。

RTC作成時にライブラリの競合が起こり、困っています。 使用しているライブラリはMobileRobotics社のAriaライブラリ(32bit)を使用しています。 サイトで公開されているRTCで、同じようにAriaライブラリを使用したコンポーネントがあったので、解決方法があるとは思うのですが 自分で見つけることが出来なかったので、助言をいただけるとありがたいです。

以下はヘッダー部分のコピーと開発環境になります。よろしくお願いします。

ヘッダー部分 ...... #include <rtm/DataInPort.h> #include <rtm/DataOutPort.h>

#include "Aria.h" //<-この部分をコメントアウトすると競合が消えます #include <windows.h> #include <stdio.h> #include <vector> #include <string> #include <sstream>

using namespace RTC; ........

開発環境 使用OS Windows10 使用言語 C++ 使用ソフトウェア OpenRTM 1.1.2(32bit) VisualStudio2013 Professional ライブラリ MobileRobotics社 Aria2.9.4(32bit)

Japanese
Miyamoto Nobuhiko
Offline
Last seen: 1 day 6 hours ago
Joined: 2013-12-19 00:41
Re: ライブラリの競合について

エラーの原因ですが、これはAriaのヘッダーファイルでwinsock2.hをインクルードしているため発生しています。 OpenRTM-aistのインクルードファイルでwindows.hをインクルードするようになっており、winsock2.hをwindows.hよりも後にインクルードした場合、エラーになります。

この問題の解決策としては、以下の2つの方法があります。

① Aria.hをOpenRTM-aistのインクルードファイルよりも先にインクルードする

RTC Builderで生成したコードであれば、****Comp.cppのインクルードの順番は以下のようになっています。(****はモジュール名)

 #include <rtm/Manager.h>
 #include <iostream>
 #include <string>
 #include <stdlib.h>
 #include "****.h"

これを以下のように順番を変更してください。

 
 #include "****.h"
 #include <rtm/Manager.h>
 #include <iostream>
 #include <string>
 #include <stdlib.h>

次にヘッダーファイル****.hの先頭でAria.hをインクルードしてください。これでエラーは発生しなくなります。

 #include "Aria.h"
 
 #include <rtm/idl/BasicDataTypeSkel.h>
 #include <rtm/idl/ExtendedDataTypesSkel.h>
 #include <rtm/idl/InterfaceDataTypesSkel.h>

②別ファイルに分離する

他の方法としては、Aria.hをインクルードするファイルを別のcppファイルに分離するということもできます。

Log in or register to post comments

Download

latest Releases : 2.0.0-RELESE

2.0.0-RELESE Download page

Number of Projects

Choreonoid

Motion editor/Dynamics simulator

OpenHRP3

Dynamics simulator

OpenRTP

Integrated Development Platform

AIST RTC collection

RT-Components collection by AIST

TORK

Tokyo Opensource Robotics Association

DAQ-Middleware

Middleware for DAQ (Data Aquisition) by KEK