Why is CoCreateInstanceFromApp missing from an ARM build over an x64 build? - c++

This question does not already have an answer
I know what an unresolved external symbol means - I'm asking specifically why when building as ARM the DirectX functions are missing for my project. When I build my DirectX project for Raspberry Pi I get the below link errors. Why is CoCreateInstFromApp missing only for the ARM build?
The Microsoft documentation on CoCreateInstanceFromApp implies it should simply be present in any Windows executable - this is in fact what I see when building x86 or x64 versions of the same project. It ought to be present, since DirectX does support ARM architecture - or have I missed something?
The project is including d3d11.lib & dxgi.lib, which I presumed it would pick up from the right directory - but get no specific errors about those libraries. The project is C++ in Visual Studio 2017 Pro v15.8.7.
Redacted link error:
DirectXTK_ARM.lib : error LNK2019: unresolved
external symbol __imp_CoCreateInstanceFromApp referenced in function
"long __cdecl CoCreateInstance ...
DirectXTK_ARM.lib : error LNK2019: unresolved
external symbol __imp_PropVariantClear ....
More info, if required:
I have altered this Desktop Duplication sample from Microsoft to do a screen-shot instead of duplication, and thus removed the window code and used DirectXTK for saving the file. This works great on my desktop and on a Minnowboard (x64 Win10 IoT). But if I try and compile for Raspberry PI (ARM) it fails with the link error:
DirectXTK_ARM.lib(WICTextureLoader.obj) : error LNK2019: unresolved
external symbol __imp_CoCreateInstanceFromApp referenced in function
"long __cdecl CoCreateInstance(struct _GUID const &,struct IUnknown
*,unsigned long,struct _GUID const &,void * *)" (?CoCreateInstance##YAJABU_GUID##PAUIUnknown##K0PAPAX#Z)
DirectXTK_ARM.lib(WICTextureLoader.obj) : error LNK2019: unresolved
external symbol __imp_PropVariantClear referenced in function "long
__cdecl `anonymous namespace'::CreateTextureFromWIC(struct ID3D11Device *,struct ID3D11DeviceContext *,struct
IWICBitmapFrameDecode *,unsigned int,enum D3D11_USAGE,unsigned
int,unsigned int,unsigned int,unsigned int,struct ID3D11Resource *
*,struct ID3D11ShaderResourceView * *)" (?CreateTextureFromWIC#?A0x2b71c33d##YAJPAUID3D11Device##PAUID3D11DeviceContext##PAUIWICBitmapFrameDecode##IW4D3D11_USAGE##IIIIPAPAUID3D11Resource##PAPAUID3D11ShaderResourceView###Z)
1

CoCreateInstance and PropVariantClear are part of ole32.lib.
UWP apps should link with the umbrella WindowsApp.lib, but you can also link to umbrella mincore.lib for IoT apps.

Related

Convert VS 32 bit project to 64

There is an abandoned project, that builds correctly in 32bit version, but I need 64bit version of it. I tried to change project setting to x64 in visual studio, but when I click build I get lots of errors. Here are the visual studio files. And here is more info about the project. I have no experience with VS and c++.
This is a DLL, that makes connection between MT5 platform and MySQL, using libmysql.dll. I would like to read and write data to/from MySQL using MT5.
I would appreciate if you could help me to convert this to 64 bits, the 32 bit version can not be loaded to MT5.
Here are the first 5 error:
1>MQLMySQL.obj : error LNK2019: unresolved external symbol mysql_num_rows referenced in function "int __cdecl cMySqlCursorRows(int)" (?cMySqlCursorRows##YAHH#Z)
1>MQLMySQL.obj : error LNK2019: unresolved external symbol mysql_num_fields referenced in function "wchar_t * __cdecl cMySqlGetRowField(int,unsigned int)" (?cMySqlGetRowField##YAPEA_WHI#Z)
1>MQLMySQL.obj : error LNK2019: unresolved external symbol mysql_errno referenced in function "bool __cdecl MySqlExecute(int,wchar_t *)" (?MySqlExecute##YA_NHPEA_W#Z)
1>MQLMySQL.obj : error LNK2019: unresolved external symbol mysql_error referenced in function "bool __cdecl MySqlExecute(int,wchar_t *)" (?MySqlExecute##YA_NHPEA_W#Z)
1>MQLMySQL.obj : error LNK2019: unresolved external symbol mysql_init referenced in function "int __cdecl cMySqlConnect(wchar_t *,wchar_t *,wchar_t *,wchar_t *,int,wchar_t *,int)" (?cMySqlConnect##YAHPEA_W000H0H#Z)
1>MQLMySQL.obj : error LNK2019: unresolved external symbol mysql_real_connect referenced in function "int __cdecl cMySqlConnect(wchar_t *,wchar_t *,wchar_t *,wchar_t *,int,wchar_t *,int)" (?cMySqlConnect##YAHPEA_W000H0H#Z)
From the first 5 errors you've had, it looks like a linker issue. Most compiled languages compile the source (c++) code into object files and then link them with existing libraries. If the source compiles, but you can't link to the external libraries (for example they aren't installed) then you'll get errors like you've described.
Is there an external library that you need to reference, or are all of your source files organized in such a way that they can reference each other?

OpenCV via NuGet packages with Visual Studio 2015, how to configure?

I'm trying to use OpenCV via NuGet packages with Visual Studio 2015 and I can't seem to get everything configured. I'm not sure if I'm making a mistake somewhere or what I'm trying is not supported.
A little background, I made this tutorial a while back:
https://www.youtube.com/watch?v=7SM5OD2pZKY
https://github.com/MicrocontrollersAndMore/OpenCV_3_Windows_10_Installation_Tutorial
And I'd like to update this to use NuGets if possible. I use NuGets on the job every day so I'm familiar with the concept, but I've only previously used NuGets with .Net (Visual Basic or C#) applications.
I'm trying to make this work with plane jane C++ OpenCV, not within a .NET or UWP app.
For the record, in a separate .Net test project, I tried the EmguCV NuGet package:
With Visual Studio 2015 and everything worked as expected (for those not familiar, Emgu CV is probably the oldest/best known/most stable .Net wrapper for OpenCV)
Here are the steps I tried to get regular C++ OpenCV to work within Visual Studio 2015 using NuGets:
Start Visual Studio 2015, make an Empty Project:
Bring up the NuGet package manager:
I choose OpenCV.Win.ImgProc as that seemed to be the only OpenCV 3.x NuGet available, this also auto imported Core as expected:
Then I added a .cpp file and copied/pasted in known-good OpenCV code, the OpenCV libraries are not recognized:
I tried Build -> Clean, Build -> Build, same concern. I also tried "Solution Configurations" and "Solution Platforms" set to Debug / Release / x86 / x64, same concern.
Am I missing a step here? Do NuGets only work within a managed environment such as .Net or UWP, or can they work with regular C++ as well? I did notice the mention in the Description about UWP:
But I'm not using VideoIO, so I'm not sure that should matter.
Has anybody had any success with this? I can always go back to the "old school" way of directly referencing libraries in Project -> (project name) Properties as shown in my tutorial linked to above, but I'd like to use NuGets if possible.
----------- Edit ---------------
I had to place my response to Leo-MSFT here to allow for enough characters and screenshots. Thanks for the suggestion Leo-MSFT, but two problems with that. For one, that package is OpenCV 2.4.10, very outdated by now:
2nd, if I use that package the red underlines are gone, but I get the following linker errors when I try to build and run:
1>------ Build started: Project: Test2, Configuration: Debug x64 ------
1> test.cpp
1>test.obj : error LNK2019: unresolved external symbol "void __cdecl cv::fastFree(void *)" (?fastFree#cv##YAXPEAX#Z) referenced in function "public: __cdecl cv::Mat::~Mat(void)" (??1Mat#cv##QEAA#XZ)
1>test.obj : error LNK2019: unresolved external symbol "public: __cdecl cv::_InputArray::_InputArray(class cv::Mat const &)" (??0_InputArray#cv##QEAA#AEBVMat#1##Z) referenced in function main
1>test.obj : error LNK2019: unresolved external symbol "public: __cdecl cv::_OutputArray::_OutputArray(class cv::Mat &)" (??0_OutputArray#cv##QEAA#AEAVMat#1##Z) referenced in function main
1>test.obj : error LNK2019: unresolved external symbol "public: void __cdecl cv::Mat::deallocate(void)" (?deallocate#Mat#cv##QEAAXXZ) referenced in function "public: void __cdecl cv::Mat::release(void)" (?release#Mat#cv##QEAAXXZ)
1>test.obj : error LNK2019: unresolved external symbol "public: void __cdecl cv::Mat::copySize(class cv::Mat const &)" (?copySize#Mat#cv##QEAAXAEBV12##Z) referenced in function "public: class cv::Mat & __cdecl cv::Mat::operator=(class cv::Mat const &)" (??4Mat#cv##QEAAAEAV01#AEBV01##Z)
1>test.obj : error LNK2019: unresolved external symbol "int __cdecl cv::_interlockedExchangeAdd(int *,int)" (?_interlockedExchangeAdd#cv##YAHPEAHH#Z) referenced in function "public: class cv::Mat & __cdecl cv::Mat::operator=(class cv::Mat const &)" (??4Mat#cv##QEAAAEAV01#AEBV01##Z)
1>test.obj : error LNK2019: unresolved external symbol "void __cdecl cv::namedWindow(class std::basic_string,class std::allocator > const &,int)" (?namedWindow#cv##YAXAEBV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##H#Z) referenced in function main
1>test.obj : error LNK2019: unresolved external symbol "int __cdecl cv::waitKey(int)" (?waitKey#cv##YAHH#Z) referenced in function main
1>test.obj : error LNK2019: unresolved external symbol "void __cdecl cv::imshow(class std::basic_string,class std::allocator > const &,class cv::_InputArray const &)" (?imshow#cv##YAXAEBV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##AEBV_InputArray#1##Z) referenced in function main
1>test.obj : error LNK2019: unresolved external symbol "class cv::Mat __cdecl cv::imread(class std::basic_string,class std::allocator > const &,int)" (?imread#cv##YA?AVMat#1#AEBV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##H#Z) referenced in function main
1>test.obj : error LNK2019: unresolved external symbol "void __cdecl cv::GaussianBlur(class cv::_InputArray const &,class cv::OutputArray const &,class cv::Size,double,double,int)" (?GaussianBlur#cv##YAXAEBV_InputArray#1#AEBV_OutputArray#1#V?$Size_#H#1#NNH#Z) referenced in function main
1>test.obj : error LNK2019: unresolved external symbol "void __cdecl cv::Canny(class cv::_InputArray const &,class cv::_OutputArray const &,double,double,int,bool)" (?Canny#cv##YAXAEBV_InputArray#1#AEBV_OutputArray#1#NNH_N#Z) referenced in function main
1>test.obj : error LNK2019: unresolved external symbol "void __cdecl cv::cvtColor(class cv::_InputArray const &,class cv::_OutputArray const &,int,int)" (?cvtColor#cv##YAXAEBV_InputArray#1#AEBV_OutputArray#1#HH#Z) referenced in function main
1>C:\Users\cdahms\Documents\Test2\x64\Debug\Test2.exe : fatal error LNK1120: 13 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
After trying various options, I've settled on this package:
Which seems to work, although it's not very confidence inspiring that it is clearly labeled "not an official package" and also that it's slightly out of date (not many changes from OpenCV 3.1.0 to 3.2.0 however). I suppose I'll use this until a proper updated package is released.
The OpenCV libraries package is OpenCV3.1 rather than OpenCV.Win.ImgProc for your test OpenCV code.
Below is my test result, so you just need to install the OpenCV3.1 NuGet package instead of OpenCV.Win.ImgProc for that OpenCV code.
Note that: OpenCV3.1 is not an official package.

regex build error on win7 64bit

I got this two build error on VS2008 and Windows 7 64bit:
error LNK2019: unresolved external symbol "__declspec(dllimport) void __cdecl std::tr1::_Xbad(enum std::tr1::regex_constants::error_type)" (__imp_?_Xbad#tr1#std##YAXW4error_type#regex_constants#12##Z) referenced in function "public: static unsigned __int64 __cdecl std::tr1::_Regex_traits<char>::length(char const *)" (?length#?$_Regex_traits#D#tr1#std##SA_KPEBD#Z)
error LNK2019: unresolved external symbol "__declspec(dllimport) void __cdecl std::tr1::_Xmem(void)" (__imp_?_Xmem#tr1#std##YAXXZ) referenced in function "private: void __cdecl std::tr1::_Buf<char>::_Expand(int)" (?_Expand#?$_Buf#D#tr1#std##AEAAXH#Z)
Does that ring any bell? The code was fine on VS2008 and Windows 7 32 bit, but did not build on a 64 bit machine. Any suggestion is appreciated. Thanks.
I downloaded VC feature 2008, and the problem is gone after installation. I did this because I saw another poster said so somewhere online.
Here it is:
http://www.microsoft.com/en-us/download/details.aspx?id=6922

OpenCV - SURF functionality issue

I am trying to build an OpenCV program which uses SURF matching algorithm, the code is in the following link :
http://feelmare.blogspot.ro/2011/10/sift-matching-c-source-code-using.html
However, I am obtaining 2 errors regarding some external symbols : _cvExtractSurf and _cvSURFParams.
error LNK2019: unresolved external symbol _cvExtractSURF referenced in function "public: bool __thiscall CMareMatchingClass::ExtractBGsurf(struct _IplImage *)" (?ExtractBGsurf#CMareMatchingClass##QAE_NPAU_IplImage###Z)
error LNK2019: unresolved external symbol _cvSURFParams referenced in function "public: __thiscall CMareMatchingClass::CMareMatchingClass(void)" (??0CMareMatchingClass##QAE#XZ)
Do you know how can I solve this errors? I am running the code by using opencv 2.3.0 in visual studio 2010 in Windows 7 - 64 bit.
You didn't link a needed library - try to link all OpenCV libraries in project settings. See documentation.

Linking error VC++

I download Neoncube downloader and tried to compile. After I resolved some linking issues, there's still three that I can't solve.
1>main.obj : error LNK2019: unresolved
external symbol _UnEmbedBrowserObject
referenced in function "long stdcall
NoticeWindowProcedure(struct HWND
*,unsigned int,unsigned int,long)" (?NoticeWindowProcedure##YGJPAUHWND__##IIJ#Z)
1>main.obj : error LNK2019: unresolved
external symbol _EmbedBrowserObject
referenced in function "long stdcall
NoticeWindowProcedure(struct HWND
*,unsigned int,unsigned int,long)" (?NoticeWindowProcedure##YGJPAUHWND__##IIJ#Z)
1>main.obj : error LNK2019: unresolved
external symbol _DisplayHTMLPage
referenced in function "void cdecl
drawNotice(struct HWND *,int)"
(?drawNotice##YAXPAUHWND__##H#Z)
These functions appear to be from some obscure COM object from Microsoft. Yet I can't found any documentation on it. (UnEmbedBrowserObject, EmbedBrowserObject, DisplayHTMLPage)
Can someone help me?
Thanks
These are not names in any of the Microsoft SDK libraries. The appear to come from this code project. It could also be this one. You'll have to build it to create the DLL and add the .lib it produces to your project's linker input.