printf("\n") statement in client code cause linking error [closed]

asked 2016-11-27 13:35:01 -0500

conductor gravatar image

updated 2016-11-28 03:31:09 -0500

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? My config is Windows 7 x64, openCV 2.4.13, TDM-GCC x32, dll I built by myself.

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by berak
close date 2016-11-29 01:02:18.744638

Comments

1

opencv_ts is only for the unit tests, you do not need to link it with a "normal" program (also, that seems to be a static lib, so linking order matters.

forget the printf thing, you simply changed your project in some way. (the code does not mattter)

berak gravatar imageberak ( 2016-11-28 04:06:23 -0500 )edit

so mote it be :)

with not linking "libopencv_ts2413.a" it works properly.

conductor gravatar imageconductor ( 2016-11-28 21:29:29 -0500 )edit