Ask Your Question

Revision history [back]

code contans printf("\n") does not linking with openCV

this works fine:

#include <stdio.h>
int main()
{
  printf("hello");
  return 0;
}

but when I try do this,

#include <stdio.h>
int main()
{
  printf("\n");
  return 0;
}

I have linking error:

C:\opencv\build_dlls_2\install\x86\mingw\lib\libopencv_ts2413.a(ts_perf.cpp.obj):ts_perf.cpp:(.text$_ZN12_GLOBAL__N_115PerfEnvironment8TearDownEv+0xb): undefined reference to 'cv::setNumThreads(int)'
C:\opencv\build_dlls_2\install\x86\mingw\lib\libopencv_ts2413.a(ts_perf.cpp.obj):ts_perf.cpp:(.text$_ZN4perf8TestBase5SetUpEv+0x7): undefined reference to `cv::theRNG()'

I compile main.cpp in this way:

mingw32-g++.exe -Wall -fexceptions -g -IC:\opencv\build\include -IC:\opencv\dep\eigen-eigen-26667be4f70b -c "E:\08projects\C Projects\codeblocks_tests\test5\main.cpp" -o obj\Debug\main.o

And linking by this way:

mingw32-g++.exe  -o bin\Debug\test5.exe obj\Debug\main.o   C:\opencv\build_dlls_2\install\x86\mingw\lib\libopencv_calib3d2413.dll.a C:\opencv\build_dlls_2\install\x86\mingw\lib\libopencv_contrib2413.dll.a C:\opencv\build_dlls_2\install\x86\mingw\lib\libopencv_core2413.dll.a C:\opencv\build_dlls_2\install\x86\mingw\lib\libopencv_features2d2413.dll.a C:\opencv\build_dlls_2\install\x86\mingw\lib\libopencv_flann2413.dll.a C:\opencv\build_dlls_2\install\x86\mingw\lib\libopencv_gpu2413.dll.a C:\opencv\build_dlls_2\install\x86\mingw\lib\libopencv_highgui2413.dll.a C:\opencv\build_dlls_2\install\x86\mingw\lib\libopencv_imgproc2413.dll.a C:\opencv\build_dlls_2\install\x86\mingw\lib\libopencv_legacy2413.dll.a C:\opencv\build_dlls_2\install\x86\mingw\lib\libopencv_ml2413.dll.a C:\opencv\build_dlls_2\install\x86\mingw\lib\libopencv_nonfree2413.dll.a C:\opencv\build_dlls_2\install\x86\mingw\lib\libopencv_objdetect2413.dll.a C:\opencv\build_dlls_2\install\x86\mingw\lib\libopencv_ocl2413.dll.a C:\opencv\build_dlls_2\install\x86\mingw\lib\libopencv_photo2413.dll.a C:\opencv\build_dlls_2\install\x86\mingw\lib\libopencv_stitching2413.dll.a C:\opencv\build_dlls_2\install\x86\mingw\lib\libopencv_superres2413.dll.a C:\opencv\build_dlls_2\install\x86\mingw\lib\libopencv_ts2413.a C:\opencv\build_dlls_2\install\x86\mingw\lib\libopencv_video2413.dll.a C:\opencv\build_dlls_2\install\x86\mingw\lib\libopencv_videostab2413.dll.a

What the matter?

printf("\n") statement in client code contans printf("\n") does not cause linking with openCVerror

this works fine:

#include <stdio.h>
int main()
{
  printf("hello");
  return 0;
}

but when I try do this,

#include <stdio.h>
int main()
{
  printf("\n");
  return 0;
}

I have linking error:

C:\opencv\build_dlls_2\install\x86\mingw\lib\libopencv_ts2413.a(ts_perf.cpp.obj):ts_perf.cpp:(.text$_ZN12_GLOBAL__N_115PerfEnvironment8TearDownEv+0xb): undefined reference to 'cv::setNumThreads(int)'
C:\opencv\build_dlls_2\install\x86\mingw\lib\libopencv_ts2413.a(ts_perf.cpp.obj):ts_perf.cpp:(.text$_ZN4perf8TestBase5SetUpEv+0x7): undefined reference to `cv::theRNG()'

I compile main.cpp in this way:

mingw32-g++.exe -Wall -fexceptions -g -IC:\opencv\build\include -IC:\opencv\dep\eigen-eigen-26667be4f70b -c "E:\08projects\C Projects\codeblocks_tests\test5\main.cpp" -o obj\Debug\main.o

And linking by this way:

mingw32-g++.exe  -o bin\Debug\test5.exe obj\Debug\main.o   C:\opencv\build_dlls_2\install\x86\mingw\lib\libopencv_calib3d2413.dll.a C:\opencv\build_dlls_2\install\x86\mingw\lib\libopencv_contrib2413.dll.a C:\opencv\build_dlls_2\install\x86\mingw\lib\libopencv_core2413.dll.a C:\opencv\build_dlls_2\install\x86\mingw\lib\libopencv_features2d2413.dll.a C:\opencv\build_dlls_2\install\x86\mingw\lib\libopencv_flann2413.dll.a C:\opencv\build_dlls_2\install\x86\mingw\lib\libopencv_gpu2413.dll.a C:\opencv\build_dlls_2\install\x86\mingw\lib\libopencv_highgui2413.dll.a C:\opencv\build_dlls_2\install\x86\mingw\lib\libopencv_imgproc2413.dll.a C:\opencv\build_dlls_2\install\x86\mingw\lib\libopencv_legacy2413.dll.a C:\opencv\build_dlls_2\install\x86\mingw\lib\libopencv_ml2413.dll.a C:\opencv\build_dlls_2\install\x86\mingw\lib\libopencv_nonfree2413.dll.a C:\opencv\build_dlls_2\install\x86\mingw\lib\libopencv_objdetect2413.dll.a C:\opencv\build_dlls_2\install\x86\mingw\lib\libopencv_ocl2413.dll.a C:\opencv\build_dlls_2\install\x86\mingw\lib\libopencv_photo2413.dll.a C:\opencv\build_dlls_2\install\x86\mingw\lib\libopencv_stitching2413.dll.a C:\opencv\build_dlls_2\install\x86\mingw\lib\libopencv_superres2413.dll.a C:\opencv\build_dlls_2\install\x86\mingw\lib\libopencv_ts2413.a C:\opencv\build_dlls_2\install\x86\mingw\lib\libopencv_video2413.dll.a C:\opencv\build_dlls_2\install\x86\mingw\lib\libopencv_videostab2413.dll.a

What the matter?matter? My config is Windows 7 x64, openCV 2.4.13, TDM-GCC x32, dll I built by myself.