Im getting this error:
D:\Users\JF150696\AppData\Local\Temp\ccrDYwyp.o Source2.cpp:(.text+0xdf): undefined reference to `cv::imread(std::string const&, int)'
D:\Users\JF150696\AppData\Local\Temp\ccrDYwyp.o Source2.cpp:(.text+0xdec): undefined reference to `cv::_InputArray::_InputArray(cv::Mat const&)'
D:\Users\JF150696\AppData\Local\Temp\ccrDYwyp.o Source2.cpp:(.text+0xe41): undefined reference to `cv::imwrite(std::string const&, cv::_InputArray const&, std::vector<int, std::allocator<int> > const&)'
d:\devc\dev-cpp\mingw64\x86_64-w64-mingw32\bin\ld.exe D:\Users\JF150696\AppData\Local\Temp\ccrDYwyp.o: bad reloc address 0x20 in section `.text$_ZSt4sqrtf[__ZSt4sqrtf]'
D:\devc\opencv\projekty\test 3 opencv\test 3 opencv\collect2.exe [Error] ld returned 1 exit status
What i did in Dev Options:
I have added this command line to compiler:
-L"C:\opencv\build\x86\vc11\lib" -lopencv_highgui248 -lopencv_core248 -lopencv_imgproc248 -lopencv_calib3d248 -lopencv_video248 -lopencv_features2d248 -lopencv_ml248 -lopencv_highgui248 -lopencv_objdetect248 -lopencv_contrib248 -lopencv_legacy248 -lopencv_flann248
This lane to linker options:
-static-libgcc -lopencv_highgui248 -lopencv_core248 -lopencv_imgproc248 -lopencv_calib3d248 -lopencv_video248 -lopencv_features2d248 -lopencv_ml248 -lopencv_highgui248 -lopencv_objdetect248 -lopencv_contrib248 -lopencv_legacy248 -lopencv_flann248
In directiories i have added:
binaries: D:\devc\opencv\build\x86\vc11\bin
libs: D:\devc\opencv\build\x86\vc11\lib
headers C: D:\devc\opencv\build\include\opencv2 D:\devc\opencv\build\include\opencv D:\devc\opencv\build\include
headers C++: same as above
I have added opencv path D:\devc\opencv to PATH variable
My dev C++ version is: 5.7.0, OpenCV: 2.4.8
Anyone know how to fix that?
EDIT
Same problem using CodeBlock
Did you link Source2 to collect2 properly? Source2.cpp should be compiled into an object file before linking with your main program.
If I am not mistaken, the problems are not related to linking libraries it is because imread and imwrite shouldnt be like you called
imread(string, mat)
But you called
imread(string, int)
So it gives error. Same with other lines.
Build the libraries using CMake and CodeBlocks as given in here till step 3 of codeblock settings.
Then include the following as given in the blog to Devc++ C and C++ Includes tab
C:\OpenCV\my_build\install\include
C:\OpenCV\my_build\install\include\opencv
C:\OpenCV\my_build\install\include\opencv2
since you have included opencv and opencv2, remove /opencv2/..and /opencv ..in the header files.
and add the below line to libraries in Devc++
C:\OpenCV\my_build\install\x64\mingw\lib
also add all the .dll.a files in C:\OpenCV\my_build\install\x64\mingw\lib to Project Options.
Copy all the dll files from opencv\my_build\install\x64\mingw\bin and paste to folder where EXE of your program would be built.
Related
I'm trying to use PortAudio for audio recording through a microphone. But I get a bunch of errors -
Compiling single file...
--------
- Filename: C:\Users\Gumm\Downloads\pa_stable_v190600_20161030\portaudio\examples\paex_record.c
- Compiler Name: TDM-GCC 4.9.2 64-bit Debug
Processing C source file...
--------
- C Compiler: C:\Program Files (x86)\Dev-Cpp\MinGW64\bin\gcc.exe
- Command: gcc.exe "C:\Users\Gumm\Downloads\pa_stable_v190600_20161030\portaudio\examples\paex_record.c" -o "C:\Users\Gumm\Downloads\pa_stable_v190600_20161030\portaudio\examples\paex_record.exe" -g3 -I"C:\Program Files (x86)\Dev-Cpp\MinGW64\include" -I"C:\Program Files (x86)\Dev-Cpp\MinGW64\x86_64-w64-mingw32\include" -I"C:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include" -L"C:\Program Files (x86)\Dev-Cpp\MinGW64\lib" -L"C:\Program Files (x86)\Dev-Cpp\MinGW64\x86_64-w64-mingw32\lib" -L"C:\Users\Gumm\Downloads\pa_stable_v190600_20161030\portaudio\examples" -g3
C:\Users\Gumm\AppData\Local\Temp\ccih6neG.o: In function `main':
C:/Users/Gumm/Downloads/pa_stable_v190600_20161030/portaudio/examples/paex_record.c:224: undefined reference to `Pa_Initialize'
C:/Users/Gumm/Downloads/pa_stable_v190600_20161030/portaudio/examples/paex_record.c:227: undefined reference to `Pa_GetDefaultInputDevice'
C:/Users/Gumm/Downloads/pa_stable_v190600_20161030/portaudio/examples/paex_record.c:234: undefined reference to `Pa_GetDeviceInfo'
C:/Users/Gumm/Downloads/pa_stable_v190600_20161030/portaudio/examples/paex_record.c:238: undefined reference to `Pa_OpenStream'
C:/Users/Gumm/Downloads/pa_stable_v190600_20161030/portaudio/examples/paex_record.c:249: undefined reference to `Pa_StartStream'
C:/Users/Gumm/Downloads/pa_stable_v190600_20161030/portaudio/examples/paex_record.c:255: undefined reference to `Pa_Sleep'
C:/Users/Gumm/Downloads/pa_stable_v190600_20161030/portaudio/examples/paex_record.c:253: undefined reference to `Pa_IsStreamActive'
C:/Users/Gumm/Downloads/pa_stable_v190600_20161030/portaudio/examples/paex_record.c:260: undefined reference to `Pa_CloseStream'
C:/Users/Gumm/Downloads/pa_stable_v190600_20161030/portaudio/examples/paex_record.c:303: undefined reference to `Pa_GetDefaultOutputDevice'
C:/Users/Gumm/Downloads/pa_stable_v190600_20161030/portaudio/examples/paex_record.c:310: undefined reference to `Pa_GetDeviceInfo'
C:/Users/Gumm/Downloads/pa_stable_v190600_20161030/portaudio/examples/paex_record.c:314: undefined reference to `Pa_OpenStream'
C:/Users/Gumm/Downloads/pa_stable_v190600_20161030/portaudio/examples/paex_record.c:327: undefined reference to `Pa_StartStream'
C:/Users/Gumm/Downloads/pa_stable_v190600_20161030/portaudio/examples/paex_record.c:332: undefined reference to `Pa_Sleep'
C:/Users/Gumm/Downloads/pa_stable_v190600_20161030/portaudio/examples/paex_record.c:332: undefined reference to `Pa_IsStreamActive'
C:/Users/Gumm/Downloads/pa_stable_v190600_20161030/portaudio/examples/paex_record.c:335: undefined reference to `Pa_CloseStream'
C:/Users/Gumm/Downloads/pa_stable_v190600_20161030/portaudio/examples/paex_record.c:342: undefined reference to `Pa_Terminate'
C:/Users/Gumm/Downloads/pa_stable_v190600_20161030/portaudio/examples/paex_record.c:349: undefined reference to `Pa_GetErrorText'
collect2.exe: error: ld returned 1 exit status
Compilation results...
--------
- Errors: 1
- Warnings: 0
- Compilation Time: 0.53s
I know this is a linker error but I am unable to find any .lib file from my download of portaudio. How do I resolve this issue?
< /Hey >
It looks like you are trying to build one of the port audio examples, without first building and/or linking the portaudio library!
Building portaudio for windows
Since your on Windows, there's two main ways to build portaudio (official docs reference):
With Visual Studio (VS) : The portaudio download provides a VS project that you have to change a few minor things before it should (hopefully) compile.
With MinGW : A command line version of building portaudio on windows. You will need to install MinGW if you haven't already, but I think this method is much easier than my attempts with Visual Studio in the past.
Either technique you use will generate a static .lib file, which you can then be used to link to your project (i.e. the source file you are trying to compile).
Linking portaudio
Visual Studio
So since your on Windows, I would recommend doing this in Visual Studio (create a empty c++ command line program, and add the paex_record.c file ) if you want to have a setup project ready to go. Below is a quick way to setup a static lib in VS.
Reference the library header (portaudio.h) in Project
Properties->C/C++->General->Additional Include Directories
Reference the .lib (portaudio.lib) in Project Properties->Linker->Input
More info on creating and using static libs.
MinGW
It's actually much simpler with MinGW in my opinion but if you aren't used to working in the command line you might not prefer it.
Assuming you have your project directory with three files (for simplicity):
Project Folder
|paex_record.c
|portaudio.lib
|portaudio.h
Then the compile command (source) is:
cd /Project/Directory
gcc paex_record.c -lportaudio
I've built googletest using make under linux, the resulting files are libgtest.a libgtest_main.a.
I referenced the include files from my application and added the following lib dependencies (in the given order):
-lgtest
-lpthread
However I get the following two linker errors when I try to compile:
more undefined references to `testing::internal::EqFailure(char const*, char const*, testing::internal::String const&, testing::internal::String const&, bool)
undefined reference to `testing::internal::String::ShowCStringQuoted(char const*)
From what I've seen within the googletest source, the EqFailure function is directly implemented within gtest.cc. I don't understand why I should get a linker error here, the other definitions from googletest could obviously also be found (if I remove -lgtest, I get alot of more linker errors).
What am I missing? Thank you in advance.
Make sure you do not accidentally mix your own gtest and the one shipped with ubuntu.
I use cmake to build and got the same errors due to cmake opting for /usr/include over my own custom built version (which is what I linked with).
i download qt and eclipse with c++ cdt , i see that qt come with qt ide (qt creator) , to develop qt appliation and that fine , but i want to do this wit eclipse , i mean use c++ code with qt inside eclipse . is there any ? because i am trying to use qt to design my user interface only and using other code from other libraries to do other things .
i try to include header files (usr/include/qt4) , but i still have a problem when i compile the program such us ( can't find qgui.h ) any help the integrate qt with eclipse like netbeans .
edit :
here is my output
13:48:48 **** Incremental Build of configuration Debug for project test ****
Info: Internal Builder is used for build
g++ -o test src/test.o -lQtCore
src/test.o: In function `main':
/media/sda2/workspaceeclipse/test/Debug/../src/test.cpp:6: undefined reference to `QApplication::QApplication(int&, char**, int)'
/media/sda2/workspaceeclipse/test/Debug/../src/test.cpp:8: undefined reference to `QPushButton::QPushButton(QString const&, QWidget*)'
/media/sda2/workspaceeclipse/test/Debug/../src/test.cpp:12: undefined reference to `QApplication::exec()'
/media/sda2/workspaceeclipse/test/Debug/../src/test.cpp:12: undefined reference to `QPushButton::~QPushButton()'
/media/sda2/workspaceeclipse/test/Debug/../src/test.cpp:12: undefined reference to `QApplication::~QApplication()'
/media/sda2/workspaceeclipse/test/Debug/../src/test.cpp:8: undefined reference to `QPushButton::~QPushButton()'
/media/sda2/workspaceeclipse/test/Debug/../src/test.cpp:12: undefined reference to `QPushButton::~QPushButton()'
/media/sda2/workspaceeclipse/test/Debug/../src/test.cpp:12: undefined reference to `QApplication::~QApplication()'
src/test.o: In function `QWidget::resize(int, int)':
/usr/include/qt4/QtGui/qwidget.h:996: undefined reference to `QWidget::resize(QSize const&)'
collect2: error: ld returned 1 exit status
13:48:49 Build Finished (took 1s.609ms)
I had to adjust the following settings in "Project Properties => C/C++ General => Paths and Symbols":
On the "Includes" tab, for the GNU C++ language, add the following include paths:
/usr/include/qt4
/usr/include/qt4/QtCore
/usr/include/qt4/QtGui
On the "Symbols" tab, for the GNU C++ language, define the following symbols with a value of "1" (might be different for you, but at least the QT_CC_GNU, QT_CORE_LIB and QT_GUI_LIB are necessary):
QT_CC_GNU
QT_CORE_LIB
QT_GUI_LIB
QT_NO_DEBUG
QT_SHARED
QT_TESTLIB_LIB
QT_WEBKIT
With these settings, the source indexer works well. Other than that, Eclipse is simply calling "make" for the build.
everyone
Recently, I'm working on stereo vision. And I download the StereoMatch code from middlebury website: http://vision.middlebury.edu/stereo/code/
I used Ubuntu 11.10 to run this code. After I run this code, I got the following error. There are 3 'undefined reference to ' error. But the code has already included the header file 'MinFilter.h'. And I get confused. Could someone help me? I would appreciate it.
errors:
StcAggregate.o: In function CStereoMatcher::AggrMin()':
StcAggregate.cpp:(.text+0x20f): undefined reference tovoid MinFilter(CImageOf&, CImageOf&, int, int)'
StcEvaluate.o: In function _ZL14PartialShuffle8CImageOfIhERS0_S1_f.constprop.2':
StcEvaluate.cpp:(.text+0x37): undefined reference tovoid MinFilter(CImageOf&, CImageOf&, int, int)'
StcEvaluate.cpp:(.text+0x5b): undefined reference to `void MaxFilter(CImageOf&, CImageOf&, int, int)'
collect2: ld returned 1 exit status
make: * [StereoMatch] Error 1
This is an error from the linker (and/or runtime environment) which cannot find some symbols (i.e. code) which the header files you've included promised to exist. In order for these symbols to be found, you must tell the linker to link against the library (or object file) containing them. This library may have come with the code pre-compiled or may have been made during installation. Have you not got a README file where it is explained how to use (i.e. link and run) the code?
I met exactly the same problem and solved it like this:
Open the Makefile and change the first line from
CPPFLAGS = -O2 -Wall
to
CPPFLAGS = -O -Wall
Then "make clean" and "make", it works for me. So I guess it is because param
"-O2" does more optimization than expected.
i builded my boost library with bjam, and then moved all the .a files into c:\Server\libs\boost_1_46_0\lib
if i want to compile my program there is some error:
the compile command
g++ -Ic:\Server\libs\boost_1_46_0\ -Lc:\Server\libs\boost_1_46_0\lib\ -lboost_thread-mgw45-mt-1_46 -o try1 try1.cpp
the errors
C:\Users\FEHERG~1\AppData\Local\Temp\ccB46To7.o:try1.cpp:(.text+0xe9): undefined
reference to `_imp___ZN5boost6thread4joinEv'
C:\Users\FEHERG~1\AppData\Local\Temp\ccB46To7.o:try1.cpp:(.text+0x120): undefine
d reference to `_imp___ZN5boost6threadD1Ev'
C:\Users\FEHERG~1\AppData\Local\Temp\ccB46To7.o:try1.cpp:(.text+0x138): undefine
d reference to `_imp___ZN5boost6threadD1Ev'
C:\Users\FEHERG~1\AppData\Local\Temp\ccB46To7.o:try1.cpp:(.text$_ZN5boost11this_
thread18interruptible_waitEm[boost::this_thread::interruptible_wait(unsigned lon
g)]+0x40): undefined reference to `_imp___ZN5boost11this_thread18interruptible_w
aitEPvNS_6detail7timeoutE'
C:\Users\FEHERG~1\AppData\Local\Temp\ccB46To7.o:try1.cpp:(.text$_ZN5boost6thread
C1IPFvvEEET_NS_10disable_ifINS_14is_convertibleIRS4_NS_6detail13thread_move_tIS4
_EEEEPNS0_5dummyEE4typeE[boost::thread::thread<void (*)()>(void (*)(), boost::di
sable_if<boost::is_convertible<void (*&)(), boost::detail::thread_move_t<void (*
)()> >, boost::thread::dummy*>::type)]+0x23): undefined reference to `_imp___ZN5
boost6thread12start_threadEv'
collect2: ld returned 1 exit status
can anybody help me what is the problem in this problem?
i followed this tutorial: http://antonym.org/2009/05/threading-with-boost---part-i-creating-threads.html
so this is the source: http://pastebin.com/YqCPLNwU
UPDATE:
i think the error is not lining the library, the error is in the library.
i built it with bjam with toolchain=gcc multithread options.
UPDATE
here is the objdump http://pastebin.com/4fpqYb7d
UPDATE
i found that the problem is that the linker wants to link with dynamic linking or something like this.
Code Blocks, MinGW, Boost, and static linking issues
there "Jack Kelly" says that i need to add #define BOOST_THREAD_USE_LIB at the beginning of my source file. but this not helps to me. how can i link a library statically? (the -static not helped as well)
adding #define BOOST_THREAD_USE_LIB at the beginning works.
Remember to link also boost libs listed in the errors (boost system in my case).
Move the -lboost_thread-mgw45-mt-1_46 option to the end of the command line (after try1.cpp). (From chat.)
This might be relevant https://svn.boost.org/trac/boost/ticket/4614