如何在C ++项目中包含OpenCV源代码以使其可移植?

时间:2016-02-29 23:03:23

标签: c++ opencv cmake

在我的C ++项目中,我使用(3.1)OpenCV Mat(仅)存储和操作矩阵(因此只使用核心模块)。

现在我想使代码可移植:如果用户(运行Linux或Windows或OS X)接受我的代码,那么他可以编译并运行它,而无需安装整个OpenCV包。

此外,我希望用户运行最快版本的代码(即在发布模式,优化等中编译......)。

请你建议一种方法吗?

我将源代码从modules / cores复制到项目目录,但不知道如何继续。

提前感谢您的任何建议!

1 个答案:

答案 0 :(得分:0)

您可以通过将静态库({ "name": "analytics-ui", "version": "0.0.1", "description": "The Analytics UI Application.", "author": "david.kerman@thomsonreuters.com", "devDependencies": { "beepbeep": "^1.2.0", "browser-sync": "^2.10.0", "del": "^2.1.0", "gulp": "^3.9.0", "gulp-inline-ng2-template": "0.0.10", "gulp-prompt": "^0.1.2", "gulp-sass": "^2.1.1", "gulp-sourcemaps": "^1.6.0", "gulp-tslint": "^3.6.0", "gulp-typedoc": "^1.2.1", "gulp-typescript": "^2.8.0", "jasmine-core": "^2.4.1", "jspm": "^0.16.25", "jspm-bower-endpoint": "^0.3.2", "jspm-git": "^0.4.2", "karma": "^0.13.21", "karma-chrome-launcher": "^0.2.2", "karma-firefox-launcher": "^0.1.7", "karma-jasmine": "^0.3.6", "karma-jspm": "^2.0.2", "karma-phantomjs-launcher": "^1.0.0", "lodash": "^4.2.1", "phantomjs-prebuilt": "^2.1.4", "typings": "^0.6.8" }, "jspm": { "configFile": "jspm-config.js", "dependencies": { "angular2": "npm:angular2@^2.0.0-beta.7", "d3": "npm:d3@^3.5.16", "es6-promise": "npm:es6-promise@^3.1.2", "es6-shim": "github:es-shims/es6-shim@^0.34.4", "lodash": "npm:lodash@^4.5.0", "reflect-metadata": "npm:reflect-metadata@^0.1.3", "rxjs": "npm:rxjs@^5.0.0-beta.2", "zone.js": "npm:zone.js@^0.5.14" }, "devDependencies": {} }, "scripts": { "jspm": "jspm", "gulp": "gulp", "typings": "typings" } } 文件)与您的包一起包含并在编译期间链接到它来实现。使用.a作为-D BUILD_SHARED_LIBS=OFF的参数构建OpenCV应该创建静态文件。