I am new to learning openCV and was trying to reproduce an online example "face recognition" program here: http://www.cognotics.com/opencv/servo_2007_series/part_5/index.html.
I am however getting an "unresolved external symbol" error for few functions:
cvEigenDecomposite
cvCalcEigenObjects
indNearestNeighbor(float *) // functions defined locally by the user
loadTrainingData(struct CvMat *) // functions defined locally by the user
The "unresolved external symbol" would show up when I mess up the linker. The weird thing, it worked just fine for other examples I have done so far on other websites. My reasoning is that the first two functions cvEigenDecomposite and cvCalcEigenObjects require extra .lib object that I haven't linked to and the other two functions depend on the first two. So my question is whether those functions require extra .lib objects to be linked to?
here is the list of the .lib objects I currently link to:
opencv_core231d.lib
opencv_highgui231d.lib
opencv_imgproc231d.lib
opencv_features2d231d.lib
opencv_calib3d231d.lib
Thanks!
EDIT:
ERRORS:
1>main.obj : error LNK2019: unresolved external symbol _cvEigenDecomposite referenced in function "void __cdecl learn(void)" (?learn##YAXXZ)
1>main.obj : error LNK2019: unresolved external symbol _cvCalcEigenObjects referenced in function "void __cdecl doPCA(void)" (?doPCA##YAXXZ)
1>main.obj : error LNK2019: unresolved external symbol "int __cdecl findNearestNeighbor(float *)" (?findNearestNeighbor##YAHPAM#Z) referenced in function "void __cdecl recognize(void)" (?recognize##YAXXZ)
1>main.obj : error LNK2019: unresolved external symbol "int __cdecl loadTrainingData(struct CvMat * *)" (?loadTrainingData##YAHPAPAUCvMat###Z) referenced in function "void __cdecl recognize(void)" (?recognize##YAXXZ)
1>C:\Users\Lyukshins\Dropbox\Programming\OpenCV2\Face Recognition\Debug\Face Recognition.exe : fatal error LNK1120: 4 unresolved externals
DEPENDENCIES:
C:\opencv\build\include
C:\opencv\build\include\opencv2
C:\opencv\build\include\opencv
INCLUDED DIRECTORIES:
C:\opencv\build\x86\vc10\lib
C:\opencv\build\include
cvEigenDecomposite and cvCalcEigenObjects are located in opencv_legacy231d.lib
The other 2 functions, as you said, are local functions. So they must be declared in the code before the functions that call them.
Related
Curiously, the last time I worked with this project in 2018, everything was fine. I have no idea what changed. My project is a DLL written in C++. Today when I built it I got messages:
uafxcw.lib(dllmodul.obj) : error LNK2005: _DllMain#12 already defined in LIBCMT.lib(dllmain.obj)
uafxcw.lib(afxmem.obj) : error LNK2005: "void * __cdecl operator new(unsigned int)" (??2#YAPAXI#Z) already defined in LIBCMT.lib(new.obj)
uafxcw.lib(afxmem.obj) : error LNK2005: "void __cdecl operator delete(void *)" (??3#YAXPAX#Z) already defined in LIBCMT.lib(delete.obj)
uafxcw.lib(afxmem.obj) : error LNK2005: "void * __cdecl operator new[](unsigned int)" (??_U#YAPAXI#Z) already defined in LIBCMT.lib(new2.obj)
I tried setting /NODEFAULTLIB:LIBCMT.lib and then I got a huge number of unresolved references. So I put LIBCMT.lib back in and used /NODEFAULTLIB:uafxcw.lib, and to the surprise of nobody, got a huge number of unresolved references.None of the conflicts are symbols I've defined myself; they are all library entries. Is there a standard way to resolve these conflicts?Edit 1: Since originally posting, I have also tried adding the linker option /FORCE:MULTIPLE. This seems to work but feels uncomfortable because I don't know if the various definitions lead to the same code and anyway this situation is kind of ugly; I feel that there has to be a better way.
I have a C project in Visual Studio 2019 and I would like to use certain functions written in Go within it.
I have a test file called ctest.go which has the following contents:
package main
import (
"C"
"fmt"
)
//export printInt
func printInt(x int) {
fmt.Printf("Hello from go: %d", x)
}
func main() {}
I'm generating a static library with this command:
go build -buildmode=c-archive ctest.go
I end up with two files, ctest.a and ctest.h which I include in my VS project. I include ctest.h in my code and immediately get these errors:
identifier "__SIZE_TYPE__" is undefined
expected a ';'
expected a ';'
The generated header file contains the following lines which caused it:
typedef __SIZE_TYPE__ GoUintptr;
typedef float _Complex GoComplex64;
typedef double _Complex GoComplex128;
I replaced __SIZE_TYPE__ by size_t and just commented out the _Complex lines to stop the errors.
Now my VS project compiles while including the header file. But as soon as I try to use my go function like this:
printInt(5);
I get 2 warnings followed by 6 errors:
Warning LNK4078 multiple '.text' sections found with different attributes (60600060) AWO F:\AWO\AWO\ctest.a(go.o)
Warning LNK4078 multiple '.text' sections found with different attributes (60600060) AWO F:\AWO\AWO\ctest.a(go.o)
Error LNK2019 unresolved external symbol __imp___iob referenced in function __cgo_preinit_init AWO F:\AWO\AWO\ctest.a(000005.o)
Error LNK2001 unresolved external symbol __imp___iob AWO F:\AWO\AWO\ctest.a(000006.o)
Error LNK2001 unresolved external symbol __imp___iob AWO F:\AWO\AWO\ctest.a(000007.o)
Error LNK2019 unresolved external symbol _fprintf referenced in function _x_cgo_sys_thread_create AWO F:\AWO\AWO\ctest.a(000005.o)
Error LNK2001 unresolved external symbol _fprintf AWO F:\AWO\AWO\ctest.a(000007.o)
Error LNK1120 2 unresolved externals AWO F:\AWO\Debug\AWO.exe 1
This is where I'm stuck. I'm not sure what I'm doing wrong or should be doing differently to properly use the library generated with go.
project properties -> linker -> input -> additional dependencies
legacy_stdio_definitions.lib;%(AdditionalDependencies)
add source code
C
FILE* __cdecl __iob_func(void)
{
FILE _iob[] = { *stdin, *stdout, *stderr };
return _iob;
}
C++
extern "C" { FILE __iob_func[3] = { *stdin,*stdout,*stderr }; }
I'm trying to create an object of IVpnManagementAgent but I can't seem to find where the IID (IID___x_ABI_CWindows_CNetworking_CVpn_CIVpnManagementAgent) of it is defined so I can instance RoGetActivationFactory as it seems it requires me a second parameter of REFIID.
Also I saw this example but as I'm using C - I can't use __uuidof.
Weirdly enough the msdn sample seems to omit this parameter.
The problem is if I compile this code:
#include <roapi.h>
#define COBJMACROS
#include <windows.networking.vpn.h>
(main)()
{__x_ABI_CWindows_CNetworking_CVpn_CIVpnManagementAgent *pVpnMan;
IClassFactory *pCF; RoInitialize(RO_INIT_MULTITHREADED),
RoGetActivationFactory(0,
&IID___x_ABI_CWindows_CNetworking_CVpn_CIVpnManagementAgent,
&pVpnMan);}
Like this: cl rmousevpn.c /link RuntimeObject.lib windows.networking.lib
It gives me unresolved:
rmousevpn.obj : error LNK2019: unresolved external symbol IID___x_ABI_CWindows_CNetworking_CVpn_CIVpnManagementAgent referenced in function main
rmousevpn.exe : fatal error LNK1120: 1 unresolved externals
I am sure this has come up time and time again. I get the following error:
1>precision.obj : error LNK2001: unresolved external symbol "int nprecision"
in my program precision.cxx I have a #include to u.hxx which has the following declaration:
extern int nprecision
Surely this now reads the variable nprecision as an external variable and should all be fine. I am unsure of what is going on.
Any suggestions would be appreciated. I've done everything I can think of.
Regards
Mat
What library should be included to use TransparentBlt?
This is VC98 (Visual Studio 6) linking to the Gdi32.lib. (Other GDI functions such as BitBlt link as expected), and the compilers compiles with out error or warning.
Even though the Gdi32.lib is included, yet the linker returns this error:
mtcombo.obj : error LNK2001: unresolved external symbol __imp__TransparentBlt#44
C:\Work\Montel\Targ2_12\guitest.exe : fatal error LNK1120: 1 unresolved externals
What am I missing?
AFAIK, you will need the Msimg32.lib
http://msdn.microsoft.com/en-us/library/ms532303(VS.85).aspx
Msimg32.lib
FYI you can search the functions on http://msdn.microsoft.com/library and at the bottom it will tell you what library you need.