Developer forums (C::B DEVELOPMENT STRICTLY!) > Plugins development
OpenCV project wizard for MinGW and Linux
ollydbg:
--- Quote from: scarphin on May 01, 2013, 04:52:19 pm ---I think I've found the bug.
--- Code: ---VersionString += Major;
VersionString += Minor;
VersionString += Revision;
--- End code ---
Every time there is an error and the adjustment page cannot continue, these lines add 'Major' + 'Minor' + 'Revision' to 'VersionString' again and again.
--- End quote ---
Thanks, I fixed this bug by adding a line to reset the VersionString
--- Code: ---VersionString = _T(""); // set to empty string, then append three version numbers
--- End code ---
--- Quote ---...
Then I checked search directories and the entries were,
--- Code: ---$(#cv)\x86\mingw\lib
$(#cv)\x86\mingw\bin
--- End code ---
but they should be,
--- Code: ---$(#cv.lib)
$(#cv.bin)
--- End code ---
because I've changed them in version adjustment page to use these values. And if I change them manually, the wizard works.
--- End quote ---
1.
--- Code: ---$(#cv.bin)
--- End code ---
does not exist. If you define a global variable named "cv", cv.include and cv.bin are automatically defined by C::B, but no "cv.bin". (see the code snippet in C::B source below). So if you leave cv.include setting empty in Global variable editor dialog, this value is translated to "include" subfolder of cv base.
--- Code: ---wxString UserVariableManager::Replace(const wxString& variable)
{
wxString package = variable.AfterLast(wxT('#')).BeforeFirst(wxT('.')).MakeLower();
wxString member = variable.AfterFirst(wxT('.')).MakeLower();
wxString path(cSets + m_ActiveSet + _T('/') + package + _T('/'));
wxString base = m_CfgMan->Read(path + cBase);
if (base.IsEmpty())
{
if (Manager::Get()->GetProjectManager()->IsLoading())
{
// a project/workspace is being loaded.
// no need to bug the user now about global vars.
// just preempt it; ProjectManager will call Arrogate() when it's done.
Preempt(variable);
return variable;
}
else
{
wxString msg;
msg.Printf(_("In the currently active Set, Code::Blocks does not know\nthe global compiler variable \"%s\".\n\nPlease define it."), package.c_str());
InfoWindow::Display(_("Global Compiler Variables"), msg , 8000, 1000);
UsrGlblMgrEditDialog d;
d.AddVar(package);
PlaceWindow(&d);
d.ShowModal();
}
}
if (member.IsEmpty() || member.IsSameAs(cBase))
return base;
if (member.IsSameAs(cInclude) || member.IsSameAs(cLib) || member.IsSameAs(cObj))
{
wxString ret = m_CfgMan->Read(path + member);
if (ret.IsEmpty())
ret = base + _T('/') + member;
return ret;
}
wxString ret = m_CfgMan->Read(path + member);
return ret;
}
--- End code ---
Notice: if (member.IsSameAs(cInclude) || member.IsSameAs(cLib) || member.IsSameAs(cObj))
The reason I use such setting is that when I extract the file: OpenCV-2.4.4.exe, I see such structure:
E:\code\opencv\OpenCV-2.4.4\opencv\build -> I set this folder as "cv" base
E:\code\opencv\OpenCV-2.4.4\opencv\build\include -> this becomes $(#cv.include), in-fact, it is the same as $(cv)\include, but we prefer the former way :).
E:\code\opencv\OpenCV-2.4.4\opencv\build\x86\mingw\lib -> this becomes $(#cv)\x86\mingw\lib
E:\code\opencv\OpenCV-2.4.4\opencv\build\x86\mingw\bin -> this becomes $(#cv)\x86\mingw\bin
The most import thing is the "cv" base, then all the sub-paths are relative paths.
2, In such directory structure, you can either set cv.lib in Global variable editor dialog as $(#cv)\x86\mingw\lib, then you can use $(#cv.lib) in your compiler settings, or you can leave cv.lib in Global variable editor dialog as empty string, then use $(#cv)\x86\mingw\lib in your compiler settings.
3, The reason I have $(#cv)\x86\mingw\bin in linker search paths is that C::B will automatically add this path to PATH when it run the app, so you don't need to add to bin paths to your system's PATH.
--- Quote ---Edit: I think the lines under 'function SetupProject(project)'
--- Code: ---project.AddIncludeDir(OpenCVPathDefaultInc);
project.AddLibDir(OpenCVPathDefaultLib);
project.AddLibDir(OpenCVPathDefaultBin);
--- End code ---
should be
--- Code: ---project.AddIncludeDir(OpenCVPathInc);
project.AddLibDir(OpenCVPathLib);
project.AddLibDir(OpenCVPathBin);
--- End code ---
--- End quote ---
Thanks, fixed.
--- Quote ---2- You included CV ver1 style headers in 'main.cpp', wouldn't it be better if they are ver2 style? Just a thought.
--- End quote ---
Ok, updated to new cv::Mat.
The attachment is the new wizard package, feedback are welcome, thanks.
[attachment deleted by admin]
scarphin:
--- Quote from: ollydbg on May 02, 2013, 03:45:04 am ---
--- Quote ---...
Then I checked search directories and the entries were,
--- Code: ---$(#cv)\x86\mingw\lib
$(#cv)\x86\mingw\bin
--- End code ---
but they should be,
--- Code: ---$(#cv.lib)
$(#cv.bin)
--- End code ---
because I've changed them in version adjustment page to use these values. And if I change them manually, the wizard works.
--- End quote ---
1.
--- Code: ---$(#cv.bin)
--- End code ---
does not exist. If you define a global variable named "cv", cv.include and cv.bin are automatically defined by C::B, but no "cv.bin". (see the code snippet in C::B source below). So if you leave cv.include setting empty in Global variable editor dialog, this value is translated to "include" subfolder of cv base.
--- End quote ---
When I said 'they should be, $(#cv.lib) and $(#cv.bin)', I meant my system, not general. Sorry for the confusion.
I made a user-defined 'bin' entry in global settings to point to the cv's bin directory which is '\cvfolder\bin' in my self build and NOT '\cvfolder\x86\mingw\bin'. But the wizard still use
--- Code: ---project.AddLibDir(OpenCVPathDefaultBin);
--- End code ---
So this will always add '\cvfolder\x86\mingw\bin' to the project and not the one user defines on the settings page, '\cvfolder\bin' in my case. Was that on purpose?
One last thing, isn't it better to define '$(#cv.lib)' as the default value for 'OpenCVPathDefaultLib', in case there is a global variable setting already?
Wizard works ok now, thnx again. ;)
ollydbg:
--- Quote from: scarphin on May 02, 2013, 10:32:55 am ---I made a user-defined 'bin' entry in global settings to point to the cv's bin directory which is '\cvfolder\bin' in my self build and NOT '\cvfolder\x86\mingw\bin'. But the wizard still use
--- Code: ---project.AddLibDir(OpenCVPathDefaultBin);
--- End code ---
So this will always add '\cvfolder\x86\mingw\bin' to the project and not the one user defines on the settings page, '\cvfolder\bin' in my case. Was that on purpose?
One last thing, isn't it better to define '$(#cv.lib)' as the default value for 'OpenCVPathDefaultLib', in case there is a global variable setting already?
--- End quote ---
Well, this is indeed a mistake, sorry, I changed to "OpenCVPathLib".
BTW:
I changed my file/folder structure, now the folders are: (I also change all the default paths to follow the below structure)
E:\code\opencv\OpenCV-2.4.4\opencv\build -> I set this folder as "cv" base
E:\code\opencv\OpenCV-2.4.4\opencv\build\include -> include path
E:\code\opencv\OpenCV-2.4.4\opencv\build\lib -> lib path
E:\code\opencv\OpenCV-2.4.4\opencv\build\bin -> bin path
Now, I follow your advice, and add a sub-field named "bin" and set its value to "$(#cv)\bin", then everything works fine.
I think if I add a sub-field named "bin", but left its value as empty string, C::B should default set it to "$(#cv)\bin", just the similar way as "lib" and "include", but this is just a feature request in C::B. :)
Attachment is the version 2 of the wizard, thanks for your feedbacks.
[attachment deleted by admin]
ollydbg:
--- Quote from: ollydbg on May 02, 2013, 11:48:22 am ---I think if I add a sub-field named "bin", but left its value as empty string, C::B should default set it to "$(#cv)\bin", just the similar way as "lib" and "include", but this is just a feature request in C::B. :)
--- End quote ---
I think it is quite easy to implement this feature request, look at the last lines of function: UserVariableManager::Replace
--- Code: ---wxString UserVariableManager::Replace(const wxString& variable)
{
wxString package = variable.AfterLast(wxT('#')).BeforeFirst(wxT('.')).MakeLower();
wxString member = variable.AfterFirst(wxT('.')).MakeLower();
...
...
if (member.IsEmpty() || member.IsSameAs(cBase))
return base;
if (member.IsSameAs(cInclude) || member.IsSameAs(cLib) || member.IsSameAs(cObj))
{
wxString ret = m_CfgMan->Read(path + member);
if (ret.IsEmpty())
ret = base + _T('/') + member;
return ret;
}
wxString ret = m_CfgMan->Read(path + member);
return ret;
}
--- End code ---
The last two line:
--- Code: --- wxString ret = m_CfgMan->Read(path + member);
return ret;
--- End code ---
Can change to:
--- Code: ---
wxString ret = m_CfgMan->Read(path + member);
if (ret.IsEmpty())
ret = base + _T('/') + member;
return ret;
--- End code ---
So, if member-field "bin" has defined but have an empty value string, we use the sub-folder of "bin", any ideas?
MortenMacFly:
--- Quote from: ollydbg on May 02, 2013, 03:33:45 pm ---So, if member-field "bin" has defined but have an empty value string, we use the sub-folder of "bin", any ideas?
--- End quote ---
Well but what if you toggle a compiler flag and want to have it on ("-Wall") in the one case and off ("") in the other case? This is not covered then as "" will be translated all the time which is not what you want.
As it is now, you can safely just enter "bin" (the fields name) into it and it will work as desired in all cases.
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version