I wish to use Fade2D library in my C++Builder projects.
Libraries are in MS Visual Studio's and using them raised an exception:
[ilink32 Error] Error contains invalid OMF record, type 0x21 (possibly COFF)
I tried the two tools from Embarcadero to build the .lib file for C++ Builder:
COFF2OMF to convert the .lib from VS format and
IMPLIB to produces the .lib file starting form DLL
In both cases I have the error:
[ilink32 Error] Error: Unresolved external 'GEOM_FADE2D::setLic(const char *, const char *, const char *, const char *, const char *)' referenced from MAIN.OBJ
Any suggestions? Thanks in advance.
Related
This question already has answers here:
cannot convert 'const char*' to 'LPCWSTR {aka const wchar_t*}'
(4 answers)
Cannot convert const char[16] to LPCWSTR [closed]
(1 answer)
cannot convert parameter 1 from 'const char *' to 'LPCWSTR'
(6 answers)
Closed 3 months ago.
I'm trying to import an XE5 project over to C++Builder 10.2. I used the first example in the XE5 project and it ran fine. I've built this project from scratch starting with New VCL Project, then just added all my cpp files and forms to the project and am now trying to compile it.
The original code is this:
extern "C++" __declspec(dllimport) HID_SMBUS_STATUS HidSmbus_GetNumDevices();
//load the library dynamically
HINSTANCE load = LoadLibrary("SLABHIDDevice.dll");
I get a compile error that says:
libloaderapi.h(648): candidate function not viable: no known conversion from 'const char [18]' to 'LPCWSTR' (aka 'const wchar_t *') for 1st argument
That worked in XE5 on the same computer so I don't understand why I'm getting that error in 10.2.
I then tried this to comply with the error:
extern "C++" __declspec(dllimport) HID_SMBUS_STATUS HidSmbus_GetNumDevices();
LPCWSTR a;
*a = "SLABHIDDevice.dll";
HINSTANCE load = LoadLibrary(a);
But there is something wrong with my syntax that I don't understand as I get this error now:
[bcc32c Error] worksurface.cpp(73): C++ requires a type specifier for all declarations
I thought I had declared 'a' in the line above it, so I don't understand that. In any case, I then tried to load the library statically instead of dynamically by doing this instead:
#pragma comment(lib, "SLABHIDDevice.dll")
extern "C++" __declspec(dllimport) HID_SMBUS_STATUS HidSmbus_GetNumDevices();
But then I get the following error:
[ilink32 Error] Error: Error processing module (path)\SLABHIDDEVICE.DLL
In all cases, SLABDIDDEVICE.DLL is in the project directory.
I am learning open CV and for the same i was trying few programs.
I am referring to this link.
http://docs.opencv.org/modules/contrib/doc/facerec/tutorial/facerec_gender_classification.html
I am using visual studio 10 to run the same, and i think somewhere i have messed up with some configuration.
I am facing the same problem in couple of more programs (picked from same source) ,
The error which i get is as follows:-
1>main.obj : error LNK2019: unresolved external symbol "int __cdecl cv::waitKey(int)" (?waitKey#cv##YAHH#Z) referenced in function __catch$_main$0
1>main.obj : error LNK2019: unresolved external symbol "class cv::Mat __cdecl cv::subspaceReconstruct(class cv::_InputArray const &,class cv::_InputArray const &,class cv::_InputArray const &)" (?subspaceReconstruct#cv##YA?AVMat#1#ABV_InputArray#1#00#Z) referenced in function __catch$_main$0
..... (more such unresolved external symbol error)
1>main.obj : error LNK2001: unresolved external symbol "public: virtual bool __thiscall cv::_InputArray::empty(void)const " (?empty#_InputArray#cv##UBE_NXZ)
1>c:\users\isenses\documents\visual studio 2010\Projects\gender_classification\Debug\gender_classification.exe : fatal error LNK1120: 37 unresolved externals
1>
1>Build FAILED.
1>Time Elapsed 00:00:00.36
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
My Project Properties are as follows:-
Properties->Configuration Properties ->Debugging->command arguments->C:\Users\isenses\Documents\Visual Studio 2010\Projects\gender_classification\csv.txt
Properties->Configuration Properties ->VC++ directories->Include directories->(added C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\lib
&
C:\openCV_2.4\opencv\build\x86\vc10\lib)
C/C++->general->additional include directories (added include path of openCV ie:-
C:\openCV_2.4\opencv\build
Linker->General---
Enable incremental linking=no
Additional Library directories=C:\Program Files %28x86%29\Microsoft Visual Studio 10.0\VC\lib
C:\openCV_2.4\opencv\build\x86\vc10
linker->System---SubSystem= /SUBSYSTEM:CONSOLE
Linker->Input---
additional dependencies=
wsock32.lib
opencv_contrib2411d.lib
opencv_calib3d2411d.lib
opencv_ml2411d.lib
opencv_objdetect2411d.lib
Thank you.
Thanks to #miki i was able to build the file successfully.
The solution to my problem was:-
adding proper additional Dependencies in properties->linker->input.
Adding libraries path in windows environment variables.
I had not used proper additional dependencies as pointed by #miki and as quoted by him "well you also have to link opencv_coreXXX,opencv_highguiXXX, opencv_imgprocXXX etc... (with trailing "d" if in debug) in your Linker->Input--- additional dependencies"
Thanks again
I want to add an answer to this because I feel the documentation on the opencv site needs to be updated. I followed the tutorial and could not get the library to link. After many permutations I decided to look at the .lib files. My problem was quite simple. The lib files in the opencv tutorial are not complete. Specifically my lib directory includes three more lib files. I added three extra lib files to visual studio linker and the external symbol problem was solved.
I am unsure why this is the case because I was only trying to use functions contained within the core module. Anyway, hopefully this will help someone.
I am using opencv 3 and visual studio 2017.
I am trying to compile a program, I am trying to track an object using openCV.
Now whenever i compile the code i get the following error.
disguise_gui_1306.cpp:101:5: error: ‘FaceRecognizer’ was not declared in this scope
Ptr model, mouthModel;
^
disguise_gui_1306.cpp:101:19: error: template argument 1 is invalid
Ptr model, mouthModel;
^
disguise_gui_1306.cpp:101:26: error: invalid type in declaration before ‘,’ token
Ptr model, mouthModel;
^
disguise_gui_1306.cpp: In function ‘void snapshotCB(Fl_Widget*, void*)’:
disguise_gui_1306.cpp:232:40: error: base operand of ‘->’ is not a pointer
int predictedMouthLabel = mouthModel->predict(testSample);
^
disguise_gui_1306.cpp:242:31: error: base operand of ‘->’ is not a pointer
int predictedLabel = model->predict(testSample);
^
disguise_gui_1306.cpp:260:29: error: base operand of ‘->’ is not a pointer
int predictedLabel = model->predict(testSample);
^
disguise_gui_1306.cpp: In function ‘void
trainFaceRecogniserModel(std::vector, std::vector)’:
disguise_gui_1306.cpp:394:39: error: ‘createEigenFaceRecognizer’ was not declared in this scope
model = createEigenFaceRecognizer();
^
disguise_gui_1306.cpp:395:10: error: base operand of ‘->’ is not a pointer
model->train(img, lab);
^
disguise_gui_1306.cpp: In function ‘int main(int, char**)’:
disguise_gui_1306.cpp:416:39: error: ‘createEigenFaceRecognizer’ was not
declared in this scope
model = createEigenFaceRecognizer();
^
disguise_gui_1306.cpp:417:10: error: base operand of ‘->’ is not a pointer
model->train(images, labels);
^
disguise_gui_1306.cpp:432:15: error: base operand of ‘->’ is not a pointer
mouthModel->train(mouthimages, mouthlabels);
While when the run the same on my friends laptop it compiles smoothly.
We are same OS(debian),OpenCV 3.0.0-rc1.
As per my research this problem should only arise if m using older version of openCV2.3.
I have been trying various solutions like adding contrib.hpp and all.
But nothing seems to help.
Kindly help.
Was your opencv3 built with OPENCV_EXTRA_MODULES_PATH option in make?
-D OPENCV_EXTRA_MODULES_PATH=</path/to/opencv_contrib>/modules
As mentioned above, first check if OpenCV was compiled with contrib modules as described in https://docs.opencv.org/4.x/d7/d9f/tutorial_linux_install.html
then:
Add the inlude directories in your cmake CMakeLists.txt as described in
https://docs.opencv.org/4.x/db/df5/tutorial_linux_gcc_cmake.html ; an example:
cmake_minimum_required(VERSION 2.8)
project( DisplayImage )
find_package( OpenCV REQUIRED )
include_directories( "/home/user/opencv-4.x","/home/user/opencv_contrib-4.x" )
add_executable( DisplayImage DisplayImage.cpp )
target_link_libraries( DisplayImage ${OpenCV_LIBS} )
In your program.cpp file include the libraries
#include <opencv2/opencv.hpp>
#include <opencv2/face.hpp>
#include <opencv2/highgui.hpp>
Follow the correct name spaces described per version of OpneCV in https://docs.opencv.org/4.5.5/dd/d7c/classcv_1_1face_1_1EigenFaceRecognizer.html or de FaceRecognizer you use; for example
Ptr<cv::face::FaceRecognizer> model = cv::face::EigenFaceRecognizer::create();
Two IDL files, testbase.idl
module Test{
enum JobType{
TYPE1,
TYPE2,
TYPE3
};
struct UserContext{
string name;
string ssoToken;
};
};
testhello.idl:
#include "testbase.idl"
module Test
{
interface Hello
{
void createJob(in UserContext type);
};
};
and Hello.mpc content is:
project(testbaseIDL): taoidldefaults, anytypecode {
idlflags += -Wb,stub_export_macro=TEST_BASE_STUB_Export -Wb,stub_export_include=test_base_stub_export.h -Wb,skel_export_macro=TEST_BASE_SKEL_Export -Wb,skel_export_include=test_base_skel_export.h
IDL_Files {
testhello.idl
}
custom_only = 1
}
project(testhelloIDL): taoidldefaults, anytypecode {
idlflags += -Wb,stub_export_macro=TEST_HELLO_STUB_Export -Wb,stub_export_include=test_hello_stub_export.h -Wb,skel_export_macro=TEST_HELLO_SKEL_Export -Wb,skel_export_include=test_hello_skel_export.h
IDL_Files {
testhello.idl
}
custom_only = 1
}
project(test_base_server): naming, iortable, utils, avoids_corba_e_micro, anytypecode {
sharedname = test_base_server
after += *IDL
Source_Files {
testbaseS.cpp
}
Header_Files{
testbaseS.h
testbaseC.h
test_base_skel_export.h
}
dynamicflags += TEST_BASE_SKEL_BUILD_DLL TEST_BASE_STUB_BUILD_DLL
}
project(test_base_client): naming, iortable, utils,anytypecode {
sharedname = test_base_client
dynamicflags += TEST_BASE_STUB_BUILD_DLL
Source_Files {
testbaseC.cpp
}
Header_Files{
test_base_stub_export.h
testbaseC.h
}
}
project(testhelloserver): naming, iortable, utils, avoids_corba_e_micro,anytypecode {
sharedname = test_hello_server
dynamicflags += TEST_HELLO_SKEL_BUILD_DLL
libs += test_base_server test_hello_client test_base_client
Source_Files {
testhelloS.cpp
}
Header_Files{
testhelloS.h
testbaseS.h
test_hello_skel_export.h
}
}
project(testhelloclient): naming, iortable, utils,anytypecode {
sharedname = test_hello_client
dynamicflags += TEST_HELLO_STUB_BUILD_DLL
libs += test_base_client
Source_Files {
testhelloC.cpp
}
Header_Files{
testhelloC.h
testbaseC.h
test_hello_stub_export.h
}
}
I want to do some demo. The mpc would generate 4 main projects(testbaseClient, testbaseserver, testhelloServer and testhelloClient) and each projects would generate one dll and library and all of them are used as skeleton and stub for each IDL.
In VS2008, after building testUDL, testbaseclient, testbaseServer, the links for both testbaseserver and testbaseclient fail because link can not find some symbols. The error messages are:
1>testhelloC.obj : error LNK2019: unresolved external symbol "bool __cdecl operator::marshal(class TAO_OutputCDR &)" (?marshal#?$In_Var_Size_Argument_T#UUserContext#Test##VAny_Insert_Policy_Stream#TAO###TAO##UAE_NAAVTAO_OutputCDR###Z)
1>testhelloC.obj : error LNK2019: unresolved external symbol "void __cdecl operator::any_insert(class CORBA::Any *,struct Test::UserContext const &)" (?any_insert#?$Any_Insert_Policy_Stream#UUserContext#Test###TAO##SAXPAVAny#CORBA##ABUUserContext#Test###Z)
1>testhelloS.obj : error LNK2001: unresolved external symbol "void __cdecl operatortesthelloS.obj : error LNK2019: unresolved external symbol "bool __cdecl operator>>(class TAO_InputCDR &,struct Test::UserContext &)" (??5#YA_NAAVTAO_InputCDR##AAUUserContext#Test###Z) referenced in function "public: virtual bool __thiscall TAO::In_Var_Size_SArgument_T::demarshal(class TAO_InputCDR &)" (?demarshal#?$In_Var_Size_SArgument_T#UUserContext#Test##VAny_Insert_Policy_Stream#TAO###TAO##UAE_NAAVTAO_InputCDR###Z)
1>.\test_hello_serverd.dll : fatal error LNK1120: 3 unresolved externals
I understand the error: unresolved external symbol happens only if link could not find those symbol from itself or dependent libraries. Therefore, I added
libs += test_base_server test_base_client
for both testhelloclient and testhelloserver. After regenerating all project, the result is the same. The "unresolved external symbol" still there.
I suspect the two generated base library are wrong and I use command:
dumpbin /EXPORTS
to export all symbol and none reported unresolved external symbol are there.
Microsoft (R) COFF/PE Dumper Version 9.00.30729.01
Copyright (C) Microsoft Corporation. All rights reserved.
Dump of file test_base_clientd.dll
File Type: DLL
Section contains the following exports for test_base_clientd.dll
00000000 characteristics
526C30F9 time date stamp Sat Oct 26 18:15:37 2013
0.00 version
1 ordinal base
1 number of functions
1 number of names
ordinal hint RVA name
1 0 00003130 ??4_Init_locks#std##QAEAAV01#ABV01##Z = ??4_Init_locks#std##QAEAAV01#ABV01##Z (public: class std::_Init_locks & __thiscall std::_Init_locks::operator=(class std::_Init_locks const &))
Summary
1000 .data
2000 .idata
3000 .rdata
1000 .reloc
1000 .rsrc
9000 .text
Microsoft (R) COFF/PE Dumper Version 9.00.30729.01
Copyright (C) Microsoft Corporation. All rights reserved.
Dump of file test_base_serverd.dll
File Type: DLL
Section contains the following exports for test_base_serverd.dll
00000000 characteristics
526C2AEE time date stamp Sat Oct 26 17:49:50 2013
0.00 version
1 ordinal base
1 number of functions
1 number of names
ordinal hint RVA name
1 0 00003130 ??4_Init_locks#std##QAEAAV01#ABV01##Z = ??4_Init_locks#std##QAEAAV01#ABV01##Z (public: class std::_Init_locks & __thiscall std::_Init_locks::operator=(class std::_Init_locks const &))
Summary
1000 .data
2000 .idata
3000 .rdata
1000 .reloc
1000 .rsrc
9000 .text
Microsoft (R) COFF/PE Dumper Version 9.00.30729.01
Copyright (C) Microsoft Corporation. All rights reserved.
Dump of file test_base_serverd.lib
File Type: LIBRARY
Exports
ordinal name
??4_Init_locks#std##QAEAAV01#ABV01##Z (public: class std::_Init_locks & __thiscall std::_Init_locks::operator=(class std::_Init_locks const &))
Summary
E1 .debug$S
14 .idata$2
14 .idata$3
4 .idata$4
4 .idata$5
16 .idata$6
Microsoft (R) COFF/PE Dumper Version 9.00.30729.01
Copyright (C) Microsoft Corporation. All rights reserved.
Dump of file test_base_clientd.lib
File Type: LIBRARY
Exports
ordinal name
??4_Init_locks#std##QAEAAV01#ABV01##Z (public: class std::_Init_locks & __thiscall std::_Init_locks::operator=(class std::_Init_locks const &))
Summary
E1 .debug$S
14 .idata$2
14 .idata$3
4 .idata$4
4 .idata$5
16 .idata$6
Then what I am confused is that:
1) Would link requires all symbol available during making library project. What my past experience in unix is that all symbol is required only if it is on making executable file.
2) How to resolve this issue here? Should I add some arguments for testIDL projects?
[UPdate]:
Added all *C.cpp for testhelloclient and all *C.cpp and *S.cpp would make compilation work.
However, this is not as I expected. I want to compile each IDL into two libraries: one is for stub and another is for skeleton. Then in the future, I only need to deliver stub/skeleton with corresponding header files for other projects. It is unnecessary for skeleton/sub application to compile any of cpp files generated by IDL when .lib/.dll and header file is available.
Currently, none of *.lib files generated above contain symbol from *C.cpp or *S.cpp(the dumpbin result is similar as post previous, only 1 function). And other application would still report unresolve symbols because .lib does not contain any export symbols.
I read MSDN: http://msdn.microsoft.com/en-us/library/ms235636%28v=vs.90%29.aspx this afternoon. For export symbol of dll, the function is declared as:
static __declspec(dllexport) double Add(double a, double b);
but idl generated c header files seems not follow this way..
VC seems much different with GCC in Linux. Is there some solution?It is impossible for I to add _declsepc for each functions in IDL generated header files? The issue is simplified as: none of symbols is export in library generated from IDL in VC(I renamed title for more clarification)
[More update]
I go back to the tao_idl command, it seems it is caused by options like: -Wb,skeleton_export_include="headerfile.h" export_macro..
It seems all these files and macros are generated....Is there any better to gernated .mpc file and are these headerfile.h and macros?
[UPDATE]
It now works with updated mpc file(see above). The export files are generated by generate_export_file.pl which is in $ACE_ROOT/bin directory. The command is like:
generate_export_file.pl TEST_HELLO_STUB > test_hello_stub_export.h
Thanks all.
You have to add anytypecode also as base project in the other projects in the IDL file, not only with the IDL file itself. Also just use naming instead of namingexe, you only need to use the naming service stubs, not the full service implementation
I am new in OpenCV and have some problems when using videoInput.lib,please help me.I am using winXP SP3+Cmake2.8.2+OpenCV 2.1+Visual Studio 2008.I have made every configuration and now OpenCv can be used when I am coding.I heard videoInput.lib has been included since OpenCV2.0 and I want to use it,so I tried codes below to quick test.
// Test2.cpp : Defines the entry point for the console application.
//
#include "videoInput.h"
#include "stdafx.h"
#include "cv.h"
#include "highgui.h"
#include "cxcore.h"
int main(int ,char * *)
{
int width=320;
int height=240;
IplImage *pRgb=cvCreateImage(cvSize(width,height), IPL_DEPTH_8U, 3);
videoInput video;
video.setupDevice(0, width, height);
video.showSettingsWindow(0);
while(1)
{
if(video.isFrameNew(0))
{
video.getPixels(0, (unsigned char *)pRgb->imageData, false, true);
//cvFlip(pRgb,NULL,1);
char c=cvWaitKey(1);
if(c==27) break;
cvShowImage("Video", pRgb);
}
}
}
However when I build the codes,I got following error
1>------ Build started: Project: Test2, Configuration: Debug Win32 ------
1>Compiling...
1>Test2.cpp
1>c:\opencv2.1\vc2008\include\opencv\cvcompat.h(803) : warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss
1>Linking...
1>Test2.obj : error LNK2019: unresolved external symbol "public: __thiscall videoInput::~videoInput(void)" (??1videoInput##QAE#XZ) referenced in function _main
1>Test2.obj : error LNK2019: unresolved external symbol "public: bool __thiscall videoInput::getPixels(int,unsigned char *,bool,bool)" (?getPixels#videoInput##QAE_NHPAE_N1#Z) referenced in function _main
1>Test2.obj : error LNK2019: unresolved external symbol "public: bool __thiscall videoInput::isFrameNew(int)" (?isFrameNew#videoInput##QAE_NH#Z) referenced in function _main
1>Test2.obj : error LNK2019: unresolved external symbol "public: void __thiscall videoInput::showSettingsWindow(int)" (?showSettingsWindow#videoInput##QAEXH#Z) referenced in function _main
1>Test2.obj : error LNK2019: unresolved external symbol "public: bool __thiscall videoInput::setupDevice(int,int,int)" (?setupDevice#videoInput##QAE_NHHH#Z) referenced in function _main
1>Test2.obj : error LNK2019: unresolved external symbol "public: __thiscall videoInput::videoInput(void)" (??0videoInput##QAE#XZ) referenced in function _main
1>C:\Documents and Settings\SKSC\My Documents\Visual Studio 2008\Projects\Test2\Debug\Test2.exe : fatal error LNK1120: 6 unresolved externals
1>Build log was saved at "file://c:\Documents and Settings\SKSC\My Documents\Visual Studio 2008\Projects\Test2\Test2\Debug\BuildLog.htm"
1>Test2 - 7 error(s), 1 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
I have been googling for a long time but still can not find the solution,I am gonna mad.Does anyone know how to fix these problems?
Thanks in advance.
I think you still need to link with videoInput.lib, OpenCV uses videoInput.lib but it doesn't mean you can use all functions of videoInput.lib from OpenCV
Yes, you have to explicitly link to videoInput.lib from the Linker.
Here you will find what you need.
Here is how you can solve it:
"Go to Project Properties -> Confuguration Properties -> Linker -> Input and add videoinput.lib along with the usual OpenCV library files." This is the solution from the site mentioned above. I tried it and it works.