Home how to link c++ project to an iOS application project?
Reply: 0

how to link c++ project to an iOS application project?

user3388
1#
user3388 Published in August 15, 2018, 11:16 am

I'm trying to link this project to my iOS project since the owner said it can be linked as part of an iOS application but he didn't show how to do that, I added the source code file and opencv2 framework to my project then create the bridging header file to call the c++ function but I don't know this is right or not

my .hpp

#ifndef LaneDetection_hpp
#define LaneDetection_hpp

#include <stdio.h>
#include "opencv2/opencv.hpp"

using namespace cv;
using namespace std;

void mainWindowCallback(int event, int x, int y, int flags, void* userdata);
int main(int argc, char** argv);

#endif /* LaneDetection_hpp */

.h

#ifdef __cplusplus
extern "C" {
#endif

void mainWindowCallback();
int main();

#ifdef __cplusplus
}
#endif

bridging-header.h

#import "LaneDetectionHeader.h"

viewController.swift

let laneDetector = main()

override func viewDidLoad() {
    super.viewDidLoad()
    session?.startRunning()
    // Do any additional setup after loading the view.
    laneDetector
}

I've got these errors

Undefined symbols for architecture arm64: "LaneDetection::Configuration::~Configuration()", referenced from: LaneDetection::Configuration::getInstance() in LaneDetection.o "vtable for LaneDetection::Configuration", referenced from: LaneDetection::Configuration::Configuration() in LaneDetection.o NOTE: a missing vtable usually means the first non-inline virtual member >function has no definition. "LaneDetection::Configuration::setup(int, int, >std::__1::vector, std::__1::allocator > >, std::__1::vector, >std::__1::allocator > >, bool)", referenced from: _main in LaneDetection.o "LaneDetection::Detector::Detector(LaneDetection::EventsDelegate*)", >referenced from: _main in LaneDetection.o "vtable for Console::ScreenEventsDelegate", referenced from: Console::ScreenEventsDelegate::~ScreenEventsDelegate() in LaneDetection.o NOTE: a missing vtable usually means the first non-inline virtual member >function has no definition. "LaneDetection::Detector::processFrame(cv::Mat&, int)", referenced from: _main in LaneDetection.o "Console::ScreenEventsDelegate::ScreenEventsDelegate()", referenced >from: _main in LaneDetection.o "Console::ScreenEventsDelegate::render(cv::Mat&)", referenced from: _main in LaneDetection.o ld: symbol(s) not found for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

Do I need to create camera view on swift first? and make it send the data to c++ function because the main in c++ needed argc, argv which I don't know how to pass these data from Swift or there is another way to make it work.

sorry for my bad English.

edit1: I've tried to link my project to opencv framework and now I've got these errors in the EventsDelegate.cpp file

Image

edit2: now it's said Use of undeclared identifier 'Console' in LaneDetection.cpp Image

I didn't change anything from original, Only created the bridging header files and try to call the main function.

files in my project Image

edit3: now I've got the same errors form the first Image

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.301303 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO