I'm having this problem when I'm trying to start my computer camera.
I'm using this code
#include "opencv2/highgui/highgui.hpp"
#include <iostream>
#include "opencv2/videoio.hpp"
using namespace cv;
using namespace std;
int main(int argc, char* argv[])
{
VideoCapture cap(0); // open the video camera no. 0
}
and it shows this error
enter code here
make all
Building target: video
Invoking: GCC C++ Linker
g++ -L/usr/local/lib -o "video" ./yes.o -lopencv_video
./yes.o: In function `main':
/home/allofthepower/eclipse-workspace/video/Debug/../yes.cpp:10: undefined reference to `cv::VideoCapture::VideoCapture(int)'
makefile:44: recipe for target 'video' failed
/home/allofthepower/eclipse-workspace/video/Debug/../yes.cpp:10: undefined reference to `cv::VideoCapture::~VideoCapture()'
collect2: error: ld returned 1 exit status
make: *** [video] Error 1
I'm new to Ubuntu and OpenCV, please help.
In my case I could fix this by adding -lopencv_videoio to the g++ compiler.
Related
i keep getting this error when i try to run a simple graphics code.
and i dont think the problem is with the code itself.
Desktop\CG> g++ -w bres-circle.cpp -o bres-circle -lgraph
C:/TDM-GCC-64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lgraph
collect2.exe: error: ld returned 1 exit status
Here is the code :
#include <iostream>
#include <graphics.h>
using namespace std;
int main()
{
int gd = DETECT, gm;
initgraph(&gd, &gm,"");
line(100,100,200,200);
closegraph();
}
I want to use pacman to install OpenGL but I get an error compiling.
I want to link with -lglut -lGLU -lGL but what packages are those? Is there a way to find out?
#include <iostream>
using namespace std;
#include <SDL2\SDL.h>
#include <GL\glu.h>
int main(int arc, char *argv[]) {
cout << "Hello world" << endl;
glShadeModel(GL_SMOOTH);
return 0;
}
I run (obviously I get an error saying the lib is not found if using -lGLU)
g++ *.cpp
This is the error
C:\Users\User\AppData\Local\Temp\ccztMdnY.o:main.cpp:(.text+0x39): undefined reference to `__imp_glShadeModel'
F:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.3.0/../../../../x86_64-w64-mingw32/lib/../lib/libmingw32.a(lib64_libmingw32_a-crt0_c.o): In function `main':
C:/repo/mingw-w64-crt-git/src/mingw-w64/mingw-w64-crt/crt/crt0_c.c:18: undefined reference to `WinMain'
collect2.exe: error: ld returned 1 exit status
Why is uuid_generate_random undefined? As far as I know I am including the uuid library when compiling.
Any advice whats going wrong?
me#me-vm:~/Projects/_Tests/test_cba$ make
g++ -o res main.cpp -Luuid -std=c++11
/tmp/ccRubbJa.o: In function `main':
main.cpp:(.text+0x30): undefined reference to 'uuid_generate_random'
collect2: error: ld returned 1 exit status
make: *** [all] Error 1
Simple code:
#include <iostream>
#include <uuid/uuid.h>
int main(int argc, char** argv) {
uuid_t id;
uuid_generate_random(id);
return 0;
}
Using wrong command.Use below
g++ -o res main.cpp -luuid -std=c++11
-L is used to provide location of library
-l is used to provide name library.
I've built Boost 1.59 for MinGW 4.9.2 32bit as follows:
bootstrap.bat mingw
b2 --prefix=%USERPROFILE%\Code\Libraries\boost toolset=gcc install (these are static libraries)
When trying to compile:
#include <iostream>
#include <boost/asio.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
using namespace std;
int main()
{
boost::asio::io_service io;
boost::asio::deadline_timer t(io, boost::posix_time::seconds(5));
t.wait();
cout << "Hello World!" << endl;
return 0;
}
With:
g++ -o test -L %USERPROFILE%\Code\Libraries\boost\lib -l boost_system-mgw49-mt-1_59 -I %USERPROFILE%\Code\Libraries\boost\include\boost-1_59 main.cpp
I get this error:
C:\Users\Brady\AppData\Local\Temp\ccsbGjrk.o:main.cpp:(.text+0x193): undefined reference to `boost::system::generic_category()'
C:\Users\Brady\AppData\Local\Temp\ccsbGjrk.o:main.cpp:(.text+0x19d): undefined reference to `boost::system::generic_category()'
C:\Users\Brady\AppData\Local\Temp\ccsbGjrk.o:main.cpp:(.text+0x1a7): undefined reference to `boost::system::system_category()'
C:/Program Files (x86)/QT/Tools/mingw492_32/bin/../lib/gcc/i686-w64-mingw32/4.9.2/../../../../i686-w64-mingw32/bin/ld.exe: C:\Users\Brady\AppData\Local\Temp\ccsbGjrk.o: bad reloc address 0xe in section `.text$_ZN5boost6system14error_categoryD2Ev[__ZN5boost6system14error_categoryD2Ev]'
collect2.exe: error: ld returned 1 exit status
I'm getting this same error across 2 computers. Any help is appreciated!
It's a linker error. You need to link to the Boost System library.
Do this
g++ -o test -L %USERPROFILE%\Code\Libraries\boost\lib -lboost_system -I %USERPROFILE%\Code\Libraries\boost\include\boost-1_59 main.cpp
I am new at OpenCv. I am using Eclipse C/C++. When i try to run this sample code i faced with these errors. What should i do to solve this problem? Is there any problem at configurating ?
#using namespace std;
#using namespace cv;
int main( int argc, const char** argv )
{
Mat img = imread("MyPic.JPG", CV_LOAD_IMAGE_UNCHANGED);
if (img.empty()) //check whether the image is loaded or not
{
cout << "Error : Image cannot be loaded..!!" << endl;
//system("pause"); //wait for a key press
return -1;
}
namedWindow("MyWindow", CV_WINDOW_AUTOSIZE); //create a window with the name "MyWindow"
imshow("MyWindow", img); /
waitKey(0); //wait infinite time for a keypress
destroyWindow("MyWindow"); //destroy the window with the name, "MyWindow"
return 0;
}
16:11:28 **** Incremental Build of configuration Debug for project OpenCv ****
Info: Internal Builder is used for build
g++ "-IC:\\opencv\\build\\include" -O0 -g3 -Wall -c -fmessage-length=0 -o "src\\OpenCv.o" "..\\src\\OpenCv.cpp"
g++ "-LC:\\opencv\\build\\x86\\vc12\\lib" -o OpenCv.exe "src\\OpenCv.o" -lopencv_calib3d249 -lopencv_contrib249 -lopencv_core249 -lopencv_features2d249 -lopencv_flann249 -lopencv_gpu249 -lopencv_highgui249 -lopencv_imgproc249 -lopencv_legacy249 -lopencv_ml249 -lopencv_nonfree249 -lopencv_objdetect249 -lopencv_ocl249 -lopencv_photo249 -lopencv_stitching249 -lopencv_superres249 -lopencv_ts249 -lopencv_video249 -lopencv_videostab249
src\OpenCv.o: In function `main':
C:\Users\ayberk101\workspace\OpenCv\Debug/../src/OpenCv.cpp:10: undefined reference to `cv::imread(std::string const&, int)'
C:\Users\ayberk101\workspace\OpenCv\Debug/../src/OpenCv.cpp:19: undefined reference to `cv::namedWindow(std::string const&, int)'
C:\Users\ayberk101\workspace\OpenCv\Debug/../src/OpenCv.cpp:20: undefined reference to `cv::_InputArray::_InputArray(cv::Mat const&)'
C:\Users\ayberk101\workspace\OpenCv\Debug/../src/OpenCv.cpp:20: undefined reference to `cv::imshow(std::string const&, cv::_InputArray const&)'
C:\Users\ayberk101\workspace\OpenCv\Debug/../src/OpenCv.cpp:22: undefined reference to `cv::waitKey(int)'
C:\Users\ayberk101\workspace\OpenCv\Debug/../src/OpenCv.cpp:24: undefined reference to `cv::destroyWindow(std::string const&)'
src\OpenCv.o: In function `ZN2cv3MatD1Ev':
C:/opencv/build/include/opencv2/core/mat.hpp:278: undefined reference to `cv::fastFree(void*)'
src\OpenCv.o: In function `ZN2cv3Mat7releaseEv':
C:/opencv/build/include/opencv2/core/mat.hpp:367: undefined reference to `cv::Mat::deallocate()'
collect2.exe: error: ld returned 1 exit status
problem1: you will have to include opencv / c++ header files to make it work:
#include "opencv2/core/core.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/highgui/highgui.hpp"
#using namespace cv;
#include <iostream>
#using namespace std;
int main() {
...
then, problem2: you cannot use the vc12 libs with mingw. (it's a different compiler)
there are no more prebuild mingw libs for opencv, so, before doing anything else, you will have to build the opencv libs locally using cmake.
again, do you really need to use mingw / eclipse ? (vs express is still free)