Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undefined references after building on Ubuntu #6076

Closed
gbear605 opened this issue Feb 6, 2016 · 4 comments
Closed

Undefined references after building on Ubuntu #6076

gbear605 opened this issue Feb 6, 2016 · 4 comments
Labels
category: build/install question (invalid tracker) ask questions and other "no action" items here: https://forum.opencv.org

Comments

@gbear605
Copy link

gbear605 commented Feb 6, 2016

I had OpenCV version 2.4.12 running fine on my computer. I then built and installed version 3.1.0. Now when I compile, I get

/tmp/ccjxY4XG.o: In function `cvPointFrom32f':
/usr/local/include/opencv2/core/types_c.h:929: undefined reference to `cvRound'
/usr/local/include/opencv2/core/types_c.h:930: undefined reference to `cvRound'
/tmp/ccjxY4XG.o: In function `cvReadInt':
/usr/local/include/opencv2/core/core_c.h:2318: undefined reference to `cvRound'
/tmp/ccjxY4XG.o: In function `cvEllipseBox':
/usr/local/include/opencv2/imgproc/imgproc_c.h:1041: undefined reference to `cvRound'
/usr/local/include/opencv2/imgproc/imgproc_c.h:1042: undefined reference to `cvRound'
collect2: error: ld returned 1 exit status

I am compiling the following code.c file:

#include "opencv2/highgui/highgui_c.h"
#include <stdio.h>
int main(int argc, char* argv[])
{
      return 0;
}

I am compiling it using

gcc -ggdb `pkg-config opencv --cflags --libs` camera.c -o camera `pkg-config --libs opencv`

I am on a Jetson TK1, which has an ARM cpu. It is running Ubuntu 14.04.

I installed 3.1.0 by

wget https://github.com/Itseez/opencv/archive/3.1.0.zip
unzip 3.1.0.zip
cd opencv-3.1.0
mkdir build
cd build
cmake -DWITH_CUDA=ON -DCUDA_ARCH_BIN="3.2" -DCUDA_ARCH_PTX="" -DBUILD_TESTS=OFF -DBUILD_PERF_TESTS=OFF ..
sudo make -j4 install
echo "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib/" >> ~/.bashrc
source ~/.bashrc
@alalek
Copy link
Member

alalek commented Feb 7, 2016

  1. Try to add #include <opencv2/highgui.hpp> before "c" header

  2. Add output: pkg-config opencv --cflags --libs
    You may try to specify PKG_CONFIG_PATH environment variable to point into /usr/local/... path for OpenCV 3.1

  3. You can also debug included headers and check that there is no mix of 2.4/3.1 headers:

gcc++ -E -x c++ - -v `pkg-config opencv --cflags --libs` \
    <<< '#include "opencv2/opencv.hpp"' | grep  "# 1 .*opencv2.*1"

@gbear605
Copy link
Author

gbear605 commented Feb 7, 2016

Adding #include <opencv2/highgui.hpp> fixed my problem.

@gbear605 gbear605 closed this as completed Feb 7, 2016
@charlie5
Copy link

charlie5 commented Oct 30, 2016

 #include <opencv2/core/fast_math.hpp>      

... works for me on archlinux.

@suryafyi
Copy link

How do I add #include <opencv2/highgui.hpp> when I am using OpenCV C bindings? Will there not be a language clash?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: build/install question (invalid tracker) ask questions and other "no action" items here: https://forum.opencv.org
Projects
None yet
Development

No branches or pull requests

4 participants