2016-09-14 17 views
3

このリンクエラーで少し失われていますが、問題はlib自体ではなく私の側にあると思いますが、これを解決する方法はわかりません。boost :: processにリンクするときに "multiple definition"エラーが発生する0.6

私が後押しするリンクしようとしています::プロセス0.6 https://github.com/klemens-morgenstern/boost-process/

main.cppに

#include <boost/log/trivial.hpp> 
#include <boost/log/common.hpp> 
#include <boost/log/sinks.hpp> 
#include <boost/log/sources/logger.hpp> 
#include <boost/shared_ptr.hpp> 

#include <iostream> 
#include <thread> 

#include "ui.h" 
#include "queue.h" 
#include "image_processor.h" 
#include "recorder.h" 

using namespace boost::log; 

int main(int argc, char **argv) { 

    atomic_bool stop_execution{false}; 
    shared_ptr<image_queue_blocking> recording_queue = make_shared<image_queue_blocking>(10); 

    /**/ 
    boost::filesystem::path ffmpeg_path = "/usr/bin/ffmpeg"; 

    recorder video_recorder; 
    bool ret = video_recorder.setup(recording_queue, ffmpeg_path); 
    if (ret == false) { 
     cout << "main::recorder setup failed" << std::endl; 
     return 1; 
    } 

    /**/ 
    thread recording_thread = thread(&recorder::start, video_recorder, ref(stop_execution)); 

    /**/ 
    recording_thread.join(); 

    return 0; 
} 

recorder.cpp

#include "recorder.h" 

recorder::recorder() { 
    io_service = std::make_shared<boost::asio::io_service>(); 
    stdin_pipe = std::make_shared<boost::process::async_pipe>(*io_service); 
} 

recorder::~recorder() {} 

bool recorder::start_process() { 
    /* 
    */ 
} 

bool recorder::setup(shared_ptr<image_queue_blocking> recording_queue, boost::filesystem::path & ffmpeg_path) { 
    /* 
    */ 
    return true; 
} 

bool recorder::start(atomic_bool & stop_execution) { 
    /* 
    */ 
} 

recorder.h

#ifndef THREEBEE_RECORDER_H 
#define THREEBEE_RECORDER_H 

#ifndef RECORDER_H 
#define RECORDER_H 

#include <thread> 
#include <exception> 
#include <memory> 
#include <vector> 
#include <string> 
#include <iostream> 
#include <boost/assign.hpp> 
#include <boost/filesystem.hpp> 
#include <boost/iostreams/stream.hpp> 

#include <boost/process.hpp> 
#include "queue.h" 


class recorder { 
public: 
    recorder(); 
    ~recorder(); 
    bool setup(shared_ptr<image_queue_blocking> recording_queue, boost::filesystem::path & ffmpeg_path); 
    bool start(atomic_bool & stop_execution); 
    bool start_process(); 

private: 
    std::shared_ptr<boost::asio::io_service> io_service; 
    std::shared_ptr<boost::process::async_pipe> stdin_pipe; 
    boost::filesystem::path ffmpeg_path_; 
    shared_ptr<Mat> image; 
    shared_ptr<image_queue_blocking> recording_queue_; 
}; 


#endif //THREEBEE_RECORDER_H 
#endif //RECORDER_H 
CMakeFiles/main.dir/recorder.cpp.o: In function `boost::process::detail::posix::cmd_setter_::make_cmd(std::vector<std::string, std::allocator<std::string> >&)': 

recorder.cpp:(.text+0x11c): multiple definition of `boost::process::detail::posix::cmd_setter_::make_cmd(std::vector<std::string, std::allocator<std::string> >&)' 

CMakeFiles/main.dir/main.cpp.o:main.cpp:(.text+0x142): first defined here 

CMakeFiles/main.dir/recorder.cpp.o: In function `boost::process::detail::posix::exe_cmd_init::make_cmd()': 

recorder.cpp:(.text+0x1fc): multiple definition of `boost::process::detail::posix::exe_cmd_init::make_cmd()' 

CMakeFiles/main.dir/main.cpp.o:main.cpp:(.text+0x222): first defined here 

CMakeFiles/main.dir/recorder.cpp.o: In function `boost::process::detail::posix::async_pipe::operator=(boost::process::detail::posix::async_pipe&&)': 

recorder.cpp:(.text+0x316): multiple definition of `boost::process::detail::posix::async_pipe::operator=(boost::process::detail::posix::async_pipe&&)' 

CMakeFiles/main.dir/main.cpp.o:main.cpp:(.text+0x33c): first defined here 
+1

ほとんどの場合、ヘッダーファイルで宣言するのではなく、何かを定義した可能性があります。任意のコード(できれば[最小、完全、および検証可能な例](http://stackoverflow.com/help/mcve))を見ることなく、何も言わないことは本当に不可能です。 –

+0

私は同意する、私は私が投稿できるものにそれを沸騰しようとします。 – pho

+1

参考:エラーは「複数定義」です。 「ここで最初に定義された」というメッセージは、コンパイラがうまくいて、他の定義がどこにあるかを伝えることだけです。 – Angew

答えて

2

これは、ライブラリのバグで、問題の機能がinlineが欠落しています。私は今日それを修正するので、あなたは明日それを使うことができるでしょう。コードに何も問題はありません。

ベータ版をお試しいただきありがとうございます。このレビューは10月の終わりにあります。もしあなたがそこに参加するなら、とても嬉しいです。

+1

ありがとう!もちろん私はそれを行うことができます。私はこのプロジェクトをVidalによって古いバージョンから移植しており、WindowsとLinuxでテストされます。私が問題にぶつかったら教えてあげるよ! – pho

関連する問題