|
The workarounds say you can target an earlier version and it helps. Makes sense since the problem is with too many cross dependencies in MFC.
|
|
|
|
|
How to link statically to OpenCV?
For dynamically linking to MFC, do i select, "Use of MFC = Use MFC in a Shared DLL"?
Right now for statically linking OpenCV i got,
Linker --> General --> Additional Library Directories = C:\opencv\install\x64\vc11\staticlib
Linker --> Input --> Additional Dependencies = "List all Lib's"
Am i missing something here?
|
|
|
|
|
That is exactly how you do it. By listing the OpenCV lib files under Linker|General|Additional Dependencies, they get linked in statically and you don't need to ship the application with the DLLs.
Yes, setting "Use MFC in a Shared DLL" gives you the dynamic linking to MFC I suggest, but the MFC DLLs have to be on your client's machine - there is a very good chance they already are.
This gives you that nice 100 KB exe you got here[^]. The fact that you did not mention any linker errors is a very good sign.
Soren Madsen
"When you don't know what you're doing it's best to do it quickly" - Jase #DuckDynasty
|
|
|
|
|
Well, am getting linker errors now, that too plenty of them.
error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease'
The OpenCV library am trying to link is build as Static Release, but the MFC is now Dynamic.
Any ideas?
|
|
|
|
|
The /MD /MT options are used for specifying how the Runtime Libraries[^] are linked. Note that this is not the MFC stuff.
You should be able to rebuild the OpenCV libraries with the /MD switch instead of /MT. I think that will cause you the least trouble going forward.
Soren Madsen
"When you don't know what you're doing it's best to do it quickly" - Jase #DuckDynasty
|
|
|
|
|
If i am right, /MD = Dynamic and /MT = Static.
If i build OpenCV as /MD and then link to the MFC app, during run time it will ask for OpenCV dll's.
|
|
|
|
|
I don't know the details of building the OpenCV libraries. I know there is a BUILD_SHARED_LIBS flag, but I don't know if you can set that to OFF (like you have done) and somewhere else specify the /MD switch and have it correctly build all the lib files without a dependency on the DLLs.
Soren Madsen
"When you don't know what you're doing it's best to do it quickly" - Jase #DuckDynasty
|
|
|
|
|
I created a WIN32 console application and statically linked the OpenCV. The final exe is little less than 4 MB.
This kinda proves that there's a overhead when using MFC with statically linked lib's.
For my purpose this works fine, as the OpenCV will ultimately be running in a WIN32 DLL.
Thanks SoMad for your suggestions!
Now the next part am working on is adding an XML file to the project and compiling it into the project.
|
|
|
|
|
It sounds like you are making progress.
There is another approach to this and that is how I often deal with these kind of scenarios where I need to include 3rd party libraries (like Live555 and FFmpeg), but I want to reduce the number of distributable files and the interdependency of those files. Since you just mentioned the WIN32 DLL, this might also be what you are planning on doing in the end.
Instead of just building the EXE and distributing that, I build the EXE and a DLL for interfacing to the 3rd party library. That way I can tailor the DLL to work with the 3rd party library according to my needs, while compiling the library according to its needs.
You should be able to build your DLL with the /MT setting and build your EXE with the /MD and Shared MFC DLL setting then dynamically load the DLL.
Soren Madsen
"When you don't know what you're doing it's best to do it quickly" - Jase #DuckDynasty
|
|
|
|
|
Don Guy wrote: Now the next part am working on is adding an XML file to the project and compiling it into the project. I assume you are putting it in the resource.
XResFile - Files Stored in Resources: Part 1 - Text and Binary[^]
Soren Madsen
"When you don't know what you're doing it's best to do it quickly" - Jase #DuckDynasty
|
|
|
|
|
I have a Windows dialog-based application here. I have a button that calls ChooseColor() to let the user select a new color for the program. However, when I click the button, the color dialog opens, but the mouse and keyboard appear to be completely ignored on it.
I've never seen this happen before, does anyone know what could cause this?? The relevant code is included below.
//****************************************************************
static int select_color(HWND hwnd, COLORREF old_attr)
{
static CHOOSECOLOR cc ;
static COLORREF crCustColors[16] ;
// init-int this array did not affect the mouse problem
// uint idx ;
// for (idx=0; idx<16; idx++) {
// crCustColors[idx] = RGB(idx, idx, idx) ;
// }
ZeroMemory(&cc, sizeof(cc));
cc.lStructSize = sizeof (CHOOSECOLOR) ;
cc.rgbResult = old_attr ;
cc.lpCustColors = crCustColors ;
cc.Flags = CC_RGBINIT | CC_FULLOPEN ;
// cc.hwndOwner = hwnd ; // this hangs parent, as well as me
if (ChooseColor(&cc) == TRUE) {
return (int) cc.rgbResult ;
} else {
return -1 ;
}
}
//******************************************************************
case WM_COMMAND: // for keyboard handling
{ // create local context
DWORD cmd = HIWORD (wParam) ;
DWORD target = LOWORD(wParam) ;
switch (cmd) {
case BN_CLICKED:
switch(target) {
case IDB_ATTR_SET:
result = select_color(hwnd, test_init.set_bit) ;
if (result >= 0) {
// do something with the value
}
break;
} //lint !e744 switch target
return true;
} //lint !e744 switch cmd
//************
Later note: I created a stripped-down version of this application, which demonstrates this issue. I don't see any way to attach a file here, but the package can be downloaded from my website:
home.comcast.net/~derelict/files/ChooseColor.hang.zip
This is built using MinGW toolchain. It has been tested on multiple Win7/64bit and WinXP/SP3/32bit machines, all showing the same behavior.
|
|
|
|
|
I just tried the above code and it works fine.
Veni, vidi, abiit domum
|
|
|
|
|
Huh?!?!?
You can select cells in the color dialog, and the cancel/okay buttons work??
That's bizarre...
Did you build with MinGW ? If so, what version? (though I don't think that matters)...
I also went back to another small dialog-based application that I wrote some time ago, and pasted the select_color() function into it and called it from a button, and that worked fine as well.
This is really twisting my brain in a knot !!!!!
|
|
|
|
|
Derell Licht wrote: Did you build with MinGW ? No, just standard Win32 code. I suspect there is something else happening in your code that causes this problem.
Veni, vidi, abiit domum
|
|
|
|
|
Please clarify... when you say "I just tried the above code and it works fine.", do you mean you put the code fragment that I printed, in another program and ran it? I was hoping you downloaded and built my sample code... I guess that would be a problem if you don't use MinGW.
I agree that it is something in my code, but I'm damned if I can figure out what !!
I'm comparing the stripped-down failing code against another working Win32 utility that I have (where the button code works fine), and for the life of me I cannot figure out what the difference is!!
What I'm doing now, is I made a copy of the working project, and am pasting pieces of my target project into it, one piece at a time, until I hopefully find what breaks the color dialog. My great fear is that I'll never find it, and the copied project will work fine - and I'll NEVER figure out why this one is broken...
//************************
Later note: yeah, I got the application completely ported over from the original project to the new project based on a dialog where the ChooseColor() worked properly, and the entire project works fine.
Of course, I can't find any difference between the two, that could explain the original problem. I guess I'll never know...
|
|
|
|
|
hi all
i want to disapear hibernate in startup with registry by c++
and i've got problem with it
#include <windows.h>
#include <iostream>
#include "string.h"
using namespace std;
int main ()
{
HKEY hKey;
LPCTSTR sk = TEXT("SYSTEM\\CurrentControlSet\\Control\\Power");
LONG openRes = RegOpenKeyEx(HKEY_LOCAL_MACHINE, sk, 0, KEY_ALL_ACCESS , &hKey);
if (openRes==ERROR_SUCCESS) {
printf("Success opening key.");
} else {
printf("Error opening key.");
}
LPCTSTR value = TEXT("HibernateEnabled");
LPCTSTR data = L"0\0";
LONG setRes = RegSetValueEx (hKey, value, 0, REG_DWORD, (LPBYTE)data, 1);
if (setRes == ERROR_SUCCESS) {
printf("Success writing to Registry.");
} else {
printf("Error writing to Registry.");
}
cout << setRes << endl;
LONG closeOut = RegCloseKey(hKey);
if (closeOut == ERROR_SUCCESS) {
printf("Success closing key.");
} else {
printf("Error closing key.");
}
cin.get();
}
what is the problem with it !
please help me
|
|
|
|
|
mohamad mahdi zeinali wrote: what is the problem with it ! Could be anything, but you have not explained what happens when you try this code.
Veni, vidi, abiit domum
|
|
|
|
|
<a href="http://upload.tehran98.com/upme/uploads/d593532d97d852781.jpg">http://upload.tehran98.com/upme/uploads/d593532d97d852781.jpg</a>[<a href="http://upload.tehran98.com/upme/uploads/d593532d97d852781.jpg" target="_blank" title="New Window">^</a>]
|
|
|
|
|
LPCTSTR data = L"0\0";
LONG setRes = RegSetValueEx (hKey, value, 0, REG_DWORD, (LPBYTE)data, 1);
You are storing a Unicode string instead of an integer. The data should be a DWORD containing either 0 or 1 , like:
DWORD data = 0;
LONG setRes = RegSetValueEx (hKey, value, 0, REG_DWORD, (LPBYTE)&data, sizeof data);
Veni, vidi, abiit domum
|
|
|
|
|
Hi,
I am using WNetGetConnection() API to check that my network drive(mapped to a local share folder) is connected or not. When i run this application as run as administrator with UAC enabled, this API return success even if n/w drive is disconnected. Its works fine when i run application without admin privilege( standard user). Anybody got the same issue?
Any help or guidance would be appreciated.
Sample code
LPTSTR lpszDeviceName = 0;
lpszDeviceName = new TCHAR[ 256];
DWORD dwcchBuff = MAX_PATH;
DWORD dwResult = 0;
dwResult = WNetGetConnection( _T("Z:"), lpszDeviceName, &dwcchBuff );
if( NO_ERROR != dwResult )
{
printf("Media removed\n");
}
else
{
printf("Media inserted\n");
}
|
|
|
|
|
On my machine, the code seems to be working properly in both the scenario. Please ensure that you've not set user specific rights to the locally shared folder.
|
|
|
|
|
Hi,
Thanks for your reply.
Hmm.. I have just shared the folder( permission to everyone i think). The problem is still exists when UAC is enabled( my UAC settings is default) and I run application as admin. Its works fine when UAC is disabled( i.e Never notify).
Thanks
Arun
|
|
|
|
|
I would like to output three columns of numbers with the decimal points lined up. I wrote the following piece of code which I thought would do it.
for( int i = 0; i<100; i++ ) {
double f1 = (int)(i/20);
double f2 = 3.1415*i;
double f3 = 3.1415*(f2+3);
cout.width( 10 );
cout.precision( 4 );
cout << std::left << f1 << " ";
cout.width( 10 );
cout << std::left << f2 << " ";
cout.width( 10 );
cout << std::left << f3 << endl;
}
However, the decimal points are not lined up. Also, I want to do this in C++ not C. That is, I do not want to use, printf, fprintf or sprintf. How do I get the decimal points to line up vertical?
Thanks
Bob
|
|
|
|
|
Check if this is helpful.
{
cout << fixed;
for( int i = 0; i<10; i++ ) {
double f1 = (int)(i/20);
double f2 = 3.1415*i;
double f3 = 3.1415*(f2+3);
std::cout << std::setfill (' ') << std::setw (10);
cout.width( 10 );
cout.precision( 4 );
cout << f1 << " ";
cout.width( 10 );
cout << f2 << " ";
cout.width( 10 );
cout << f3 << endl;
}
getch();
}
|
|
|
|
|
Thanks for the response. However, it failed to produce the results I wanted. Here is part of the output that I got:
0 0 9.425
0 3.142 19.29
0 6.283 29.16
0 9.425 39.03
0 12.57 48.9
0 15.71 58.77
The decimal points are not lined up. What I want is:
0 0.0 9.425
0 3.142 19.29
0 6.283 29.16
0 9.425 39.03
0 12.57 48.9
0 15.71 58.77
In what I want the decimal points are all in the same column.
|
|
|
|