g++ app with openCV in static

asked 2017-09-22 11:36:55 -0500

carton99 gravatar image

updated 2017-09-26 05:09:33 -0500


I use openCV without extra modules in shared mode install, it's easy to compile my application:

g++ -std=c++11 -stdlib=libc++ Main.cpp   -o app `pkg-config --cflags --libs /Users/xxx/Applications/opencv-3.2.0/opencv/build/unix-install/opencv.pc`  -I/System/Library/Frameworks/JavaVM.framework/Headers

But when I compile openCv with -DBUILD_SHARED_LIBS=OFF option my command doesn't work !

I tested to make my app with cmake it's work, but I realy need to compile with g++ command.

Thx cc

[edit] Ok second round:

here my Main.cpp and my command to compile:

#include <opencv2/core/core.hpp>
#include <iostream>
int main(int argc, char **argv){
    std::cout << "hello" << std::endl;
    cv::Mat img;
    return 0;

g++ -std=c++0x Main.cpp -I /xxx/opencv/build/include -L /xxx/opencv/build/lib -lopencv_core -o Main

Command don't work and I had a very tall error:

  Undefined symbols for architecture x86_64:
      "_cblas_cgemm", referenced from:
          lapack_gemm32fc(float const*, u ...
(many ... ...)

symbol(s) not found for architecture x86_64
    clang: error: linker command failed with exit code 1 (use -v to see invocation)

I dont' see one solution.

Obviously with cmake it's working, but here I need g++

edit retag flag offensive close merge delete


berak gravatar imageberak ( 2017-09-22 22:35:44 -0500 )edit

you can try to disable lapack : cmake -DWITH_LAPACK=OFF (when building the opencv libs)

(hope, you do not mind my edit, but it would look "answered" else)

berak gravatar imageberak ( 2017-09-26 04:54:47 -0500 )edit

Thk, I try to reinstal openCV with :cmake -DWITH_LAPACK=OFF

Here my new error message when I compile my own program:

Undefined symbols for architecture x86_64: "_clBuildProgram", referenced from: cv::ocl::Program::Impl::Impl(cv:

Here my cmake to compile my own program (it's important to say that with cmake it's work perfectly), I think g++ command is bad

cmake_minimum_required(VERSION 2.8)
project( cv )
find_package( OpenCV REQUIRED )


target_link_libraries( cv ${OpenCV_LIBS} )

EDIT: I move all my process with cmake

carton99 gravatar imagecarton99 ( 2017-09-26 05:16:38 -0500 )edit

so, is it solved now ?

(and, if so, should i move your last comment to an answer ?)

berak gravatar imageberak ( 2017-09-26 08:48:21 -0500 )edit

Problem it solved for me because I move to cmake but I don't find solution to do a compilation with g++

carton99 gravatar imagecarton99 ( 2017-09-26 08:51:51 -0500 )edit