3

I am a bit lost with this linking error, I assume the problem lies on my side rather than in the lib itself but I don't know how to solve this.

I am trying to link to boost::process 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
pho
  • 317
  • 1
  • 10
  • 1
    Most likely you defined something in a header file, instead of just declaring it. Without seeing any code (preferably a [Minimal, Complete, and Verifiable Example](http://stackoverflow.com/help/mcve)) it's really impossible to say anything more. – Some programmer dude Sep 14 '16 at 11:33
  • I agree, I will try to boil it down to something I can post. – pho Sep 14 '16 at 11:38
  • 1
    FYI, the error is "multiple definition." The message "first defined here" is just the compiler being nice and telling you where the other definition is. – Angew is no longer proud of SO Sep 14 '16 at 11:42
  • Are you including a `cpp` file anywhere? – NathanOliver Sep 14 '16 at 11:44
  • No Nathan but I am pretty sure it is some trivial include mix-up. It's been sometime since I've written cpp. – pho Sep 14 '16 at 11:49
  • 1
    @pho `boost-process` is **NOT** a part of `boost` yet. According to the reference you gave: "This library requires boost 1.62. Since this is not released yet you can clone the `winapi` module from here to get it to work. You will need to overwrite the current code in `boost/libs/winapi`". Have you followed these instructions? – kenba Sep 14 '16 at 11:55
  • Yes kenba I've copied it to my boost include. – pho Sep 14 '16 at 12:03
  • 1
    @kenba It's currently under review (v0.6). Formal review window somewhere begin October IIRC. Yes - it has been pending/abandoned for a long time before – sehe Sep 14 '16 at 12:09

1 Answers1

2

This is a library bug, the functions in question are missing inline. I'll fix that today, so you'll be able to use it tomorrow. There's nothing wrong with your code:

But thank you very much for giving the beta a try. The review is in the end of october, I'd be very happy if you participate there.

  • 1
    Thanks! Of course I can do that. I am porting this project from the old version by Vidal and it will be tested on Windows and Linux. I'll let you know if I run into problems! – pho Sep 14 '16 at 13:19