I have the following bakefile (WinSparkle.bkl)
toolsets = vs2008 vs2010 vs2012 vs2013;
if ( $toolset == vs2008 )
SUFFIX = "";
if ( $toolset == vs2010 )
SUFFIX = "-2010";
if ( $toolset == vs2012 )
SUFFIX = "-2012";
if ( $toolset == vs2013 )
SUFFIX = "-2013";
vs2008.solutionfile = WinSparkle$(SUFFIX).sln;
vs2010.solutionfile = WinSparkle$(SUFFIX).sln;
vs2012.solutionfile = WinSparkle$(SUFFIX).sln;
vs2013.solutionfile = WinSparkle$(SUFFIX).sln;
// Common settings:
win32-crt-linkage = static;
archs = x86 x86_64;
defines += _CRT_SECURE_NO_WARNINGS;
// Build binaries compatible with Windows XP (SP3) -- it's still useful for
// installer stuff like WinSparkle.dll
vs2012.option.Configuration.PlatformToolset = v110_xp;
vs2013.option.Configuration.PlatformToolset = v120_xp;
if ( $(config) == Release ) {
vs2008.option.VCCLCompilerTool.Optimization = 1;
vs2008.option.VCCLCompilerTool.FavorSizeOrSpeed = 2;
vs2008.option.VCCLCompilerTool.WholeProgramOptimization = true;
vs2008.option.VCCLCompilerTool.StringPooling = true;
vs2008.option.VCLinkerTool.LinkTimeCodeGeneration = 1;
vs2010.option.Configuration.WholeProgramOptimization = true;
vs2010.option.ClCompile.Optimization = MinSpace;
vs2010.option.ClCompile.FavorSizeOrSpeed = Size;
vs2010.option.ClCompile.WholeProgramOptimization = true;
vs2010.option.ClCompile.StringPooling = true;
vs2010.option.ClCompile.FunctionLevelLinking = true;
vs2010.option.Link.OptimizeReferences = true;
vs2010.option.Link.EnableCOMDATFolding = true;
vs2010.option.Link.LinkTimeCodeGeneration = UseLinkTimeCodeGeneration;
vs2012.option.Configuration.WholeProgramOptimization = true;
vs2012.option.ClCompile.Optimization = MinSpace;
vs2012.option.ClCompile.FavorSizeOrSpeed = Size;
vs2012.option.ClCompile.WholeProgramOptimization = true;
vs2012.option.ClCompile.StringPooling = true;
vs2012.option.ClCompile.FunctionLevelLinking = true;
vs2012.option.Link.OptimizeReferences = true;
vs2012.option.Link.EnableCOMDATFolding = true;
vs2012.option.Link.LinkTimeCodeGeneration = UseLinkTimeCodeGeneration;
vs2013.option.Configuration.WholeProgramOptimization = true;
vs2013.option.ClCompile.Optimization = MinSpace;
vs2013.option.ClCompile.FavorSizeOrSpeed = Size;
vs2013.option.ClCompile.WholeProgramOptimization = true;
vs2013.option.ClCompile.StringPooling = true;
vs2013.option.ClCompile.FunctionLevelLinking = true;
vs2013.option.Link.OptimizeReferences = true;
vs2013.option.Link.EnableCOMDATFolding = true;
vs2013.option.Link.LinkTimeCodeGeneration = UseLinkTimeCodeGeneration;
}
// 3rd party library dependencies:
submodule 3rdparty/dependencies.bkl;
shared-library WinSparkle {
vs2008.projectfile = $(id)$(SUFFIX).vcproj;
vs2010.projectfile = $(id)$(SUFFIX).vcxproj;
vs2012.projectfile = $(id)$(SUFFIX).vcxproj;
vs2013.projectfile = $(id)$(SUFFIX).vcxproj;
defines += XML_STATIC;
includedirs += 3rdparty/expat/lib;
deps += WinSparkle_expat;
includedirs += 3rdparty/wxWidgets_setup_h 3rdparty/wxWidgets/include;
deps += WinSparkle_wx;
libs += comctl32 kernel32 user32 comctl32 rpcrt4 version wininet;
defines += BUILDING_WIN_SPARKLE;
// Public API headers:
headers {
include/winsparkle.h
include/winsparkle-version.h
}
includedirs += include;
// Private headers:
headers {
src/appcast.h
src/appcontroller.h
src/download.h
src/error.h
src/settings.h
src/threads.h
src/ui.h
src/updatechecker.h
src/updatedownloader.h
src/utils.h
}
sources {
src/appcast.cpp
src/appcontroller.cpp
src/dll_api.cpp
src/dllmain.cpp
src/download.cpp
src/error.cpp
src/settings.cpp
src/threads.cpp
src/ui.cpp
src/updatechecker.cpp
src/updatedownloader.cpp
src/winsparkle.rc
}
}
submodule examples/examples.bkl;
I downloaded bakefile for windows and installed it. Then I did the following
C:\winsparkle>bakefile -f msvc WinSparkle.bkl
file:///C:/winsparkle/WinSparkle.bkl:2:
parser
error :
Start tag expected, '<' not found
toolsets = vs2008 vs2010 vs2012 vs2013;
^
error: file 'C:\winsparkle\WinSparkle.bkl' is invalid
Any suggestions on what might be going wrong ??
If you want to regenerate the projects for some reason, you'll need Bakefile 1.x, not 0.2.x: https://github.com/vslavik/bakefile. Or just use the projects included in the repository.
Related
I have created a simple Protobuf based config file and have been using it without any issues until now. The issue is that I added two new items to my settings (Config.proto) and now whatever value I set for the last variable is reflected in the previous one.
The following snapshot demonstrates this better. As you can see below, the value of fv_shape_predictor_path and fv_eyenet_path depend solely on order of being set. the one that is set last changes the others value.
I made sure the cpp files related to Config.proto are built afresh. I also tested this under Linux and there it works just fine. It seems its only happening in windows! it also doesn't affect any other items in the same settings. its just these two new ones.
I have no idea what is causing this or how to go about it. For reference this is how the protobuf looks like:
syntax = "proto3";
package FVConfig;
message Config {
FV Configuration = 4 ;
message FAN_MODELS_WEIGHTS{
string fan_2DFAN_4 = 1;
string fan_3DFAN_4 = 2;
string fan_depth = 3;
}
message S3FD_MODELS_WEIGHTS{
string s3fd = 1;
}
message DLIB_MODELS_WEIGHTS{
string dlib_default = 1;
}
message MTCNN_MODELS_WEIGHTS {
string mt_onet = 1;
string mt_pnet = 2;
string mt_rnet = 3;
}
message FV_MODEL_WEIGHTS {
string r18 = 1;
string r50 = 2;
string r101 = 3;
repeated ModelContainer new_models_weights = 4;
message ModelContainer{
string model_name = 1;
string model_weight_path = 2;
string description = 3;
}
}
message FV {
MTCNNDetectorSettings mtcnn = 1 ;
FaceVerificationSettings fv = 2 ;
}
message MTCNNDetectorSettings {
Settings settings = 1;
MTCNN_MODELS_WEIGHTS model_weights = 4;
message Settings {
string mt_device = 2;
int32 mt_webcam_source = 100;
int32 mt_upper_threshold = 600;
int32 mt_hop = 700;
}
}
message FaceVerificationSettings {
Settings settings = 1;
FV_MODEL_WEIGHTS model_weights = 2;
message Settings {
string fv_model_name = 1;
string fv_model_checkpoint_path = 2;
bool fv_rebuild_cache = 3;
bool fv_short_circut = 6;
bool fv_accumulate_score = 7;
string fv_config_file_path = 10;
string fv_img_bank_folder_root = 11;
string fv_cache_folder = 12;
string fv_postfix = 13;
string fv_device = 14;
int32 fv_idle_interval = 15;
bool fv_show_dbg_info = 16;
// these are the new ones
string fv_shape_predictor_path = 17;
string fv_eyenet_path = 18;
}
}
} //end of Config message
What am I missing here? How should I be going about this? Restarting Windows and Visual Studio didn't do any good either. I'm using protobuf 3.11.4 both on Linux and Windows.
This issue seems to only exist in the Windows version of Protobuf 3.11.4 (didn't test with any newer version though).
Basically what happened was that I use to first create a Config object and initialize it with some default values. When I added these two entries to my Config.proto, I forgot to also add an initialization entry like other entries, thinking I'm fine with the default (which I assumed would be "").
This doesn't pose any issues under Linux/G++ and the program builds and runs just fine and works as intended. However under Windows this results in the behavior you just witnessed i.e. setting any of those newly added entries, would also set the other entries values. So basically I either had to create a whole new Config object or had to explicitly set their values when using the load_default_config.
To be more concrete this is the snippet I used for setting some default values in my Protobuf configs.
These reside in a separate header called Utility.h:
inline FVConfig::Config load_default_config()
{
FVConfig::Config baseCfg;
auto config = baseCfg.mutable_configuration();
load_fv_default_settings(config->mutable_fv());
load_mtcnn_default_settings(config->mutable_mtcnn());
return baseCfg;
}
inline void load_fv_default_settings(FVConfig::Config_FaceVerificationSettings* fv)
{
fv->mutable_settings()->set_fv_config_file_path(fv::config_file_path);
fv->mutable_settings()->set_fv_device(fv::device);
fv->mutable_settings()->set_fv_rebuild_cache(fv::rebuild_cache);
...
// these two lines were missing previously and to my surprise, this was indeed
// the cause of the weird behavior.
fv->mutable_settings()->set_fv_shape_predictor_path(fv::shape_predictor_path);
fv->mutable_settings()->set_fv_eyenet_path(fv::eyenet_path);
auto new_model_list = fv->mutable_model_weights()->mutable_new_models_weights()->Add();
new_model_list->set_model_name("r18");
new_model_list->set_description("default");
new_model_list->set_model_weight_path(fv::model_weights_r18);
}
inline void load_mtcnn_default_settings(FVConfig::Config_MTCNNDetectorSettings* mt)
{
mt->mutable_settings()->set_mt_device(mtcnn::device);
mt->mutable_settings()->set_mt_hop(mtcnn::hop);
....
}
Not sure this counts as a bug in Protobuf, or my wrong approach here.
I want to convert an objective c code to objective cpp and use it in my application. Given the following code:
CFTypeRef dynamicValue = (__bridge CFTypeRef)([[NSBundle bundleWithPath:aStr] objectForInfoDictionaryKey: #"CFPlugInDynamicRegistration"]);
BOOL removeFlag = NO;
if(dynamicValue == nil)
{
removeFlag = NO;
}
else if( CFGetTypeID(dynamicValue) == CFBooleanGetTypeID() )
{
removeFlag = CFBooleanGetValue(dynamicValue);
}
else if( CFGetTypeID(dynamicValue) == CFStringGetTypeID() )
{
removeFlag = ( [[(__bridge NSString*)dynamicValue lowercaseString] isEqualToString:#"yes"] ? YES:NO);
}
if( removeFlag )
{
[unloadedArray addObject:aStr];
[sortedArray removeObjectAtIndex:hoge];
}
I get an error when changing the file name from file.m to file.mm and building: "no matching function for call to 'CFBooleanGetValue'"
I tried to #include <CoreFoundation/CFNumber.h> but I get the same error (I guess it's an ifdef issue).
Do you know any way I can cast without the missing function? Should I try to use the same function anyway?
Objective-C++ doesn't have automatic framework linking.
You need #include <CoreFoundation/CoreFoundation.h> and manually link CoreFoundation framework.
you can use this CFNumberGetTypeID()
NSString *aStr = #"";
CFTypeRef dynamicValue = (__bridge CFTypeRef)([[NSBundle bundleWithPath:aStr] objectForInfoDictionaryKey: #"CFPlugInDynamicRegistration"]);
BOOL removeFlag = NO;
if(dynamicValue == nil)
{
removeFlag = NO;
}
else if( CFGetTypeID(dynamicValue) == CFNumberGetTypeID() )
{
removeFlag = [(__bridge NSNumber *)dynamicValue boolValue];
}
else if( CFGetTypeID(dynamicValue) == CFStringGetTypeID() )
{
removeFlag = ( [[(__bridge NSString*)dynamicValue lowercaseString] isEqualToString:#"yes"] ? YES:NO);
}
if( removeFlag )
{
[unloadedArray addObject:aStr];
[sortedArray removeObjectAtIndex:hoge];
}
In C++ a conversion from a void * (here: CFTypeRef) to a
pointer of a different type (here: CFBooleanRef aka __CFBoolean *) requires an explicit
cast. So this would solve the issue:
removeFlag = CFBooleanGetValue(static_cast<CFBooleanRef>(dynamicValue));
But actually I would forget about the CF types and bridging, and change the code to
id dynamicValue = [[NSBundle bundleWithPath:#"path"] objectForInfoDictionaryKey: #"CFPlugInDynamicRegistration"];
BOOL removeFlag = NO;
if ([dynamicValue isKindOfClass:[NSNumber class]]) {
removeFlag = ((NSNumber *)dynamicValue).boolValue;
} else if ([dynamicValue isKindOfClass:[NSString class]]) {
removeFlag = [((NSString *)dynamicValue).lowercaseString isEqualToString:#"yes"];
}
This compiles in Objective-C and Objective-C++.
I want to open a dialog to search for a filepath, without already creating the File and only saving the pathfile in a textBox.
This is what I already got, but it creates a new file:
System::IO::Stream^ myStream;
SaveFileDialog^ saveFileDialog1 = gcnew SaveFileDialog;
saveFileDialog1->Filter = "txt files (*.txt)|*.txt";
saveFileDialog1->FilterIndex = 2;
saveFileDialog1->RestoreDirectory = true;
if ( saveFileDialog1->ShowDialog() == ::DialogResult::OK )
{
if ( (myStream = saveFileDialog1->OpenFile()) != nullptr )
{
textBox->Text = saveFileDialog1->FileName;
myStream->Close();
}
}
Calling OpenFile is what's creating the file. Don't do it.
System::IO::Stream^ myStream;
SaveFileDialog^ saveFileDialog1 = gcnew SaveFileDialog;
saveFileDialog1->Filter = "txt files (*.txt)|*.txt";
saveFileDialog1->FilterIndex = 2;
saveFileDialog1->RestoreDirectory = true;
if ( saveFileDialog1->ShowDialog() == ::DialogResult::OK )
{
textBox->Text = saveFileDialog1->FileName;
}
I'm trying to run some C++ code someone gave me. At first there was a broken link to an istream file, which I fixed by adding the include path:
C:\Program Files (x86)\Embarcadero\RAD Studio\7.0\include\dinkumware
The code now compiles but it doesn't stop at any breakpoints, for example those in the formcreate:
// Initialise the form and read in the module and inverter names.
void __fastcall TMain::FormCreate(TObject *Sender)
{
ifstream inits;
ifstream inverters;
ifstream modules;
char line[1000];
AnsiString FTO;
inits.open("PVSM.ini", ios::in);
if (inits.is_open())
{
inits.getline(line,1000);
AnsiString parmm(line);
ModDir = parmm.SubString(1,parmm.Pos(" ")-1);
inits.getline(line,1000);
AnsiString parmi(line);
InvDir = parmi.SubString(1,parmi.Pos(" ")-1);
inits.getline(line,1000);
AnsiString parmt(line);
MetDir = parmt.SubString(1,parmt.Pos(" ")-1);
inits.getline(line,1000);
AnsiString parms(line);
ShdDir = parms.SubString(1,parms.Pos(" ")-1);
inits.getline(line,1000);
AnsiString parmx(line);
ExpDir = parmx.SubString(1,parmx.Pos(" ")-1);
}
else // Should never get here, but if ini file missing use defaults
{
ModDir = "C://";
InvDir = "C://";
MetDir = "C://";
ShdDir = "C://";
}
inits.close();
FTO = InvDir + "inverters.data";
inverters.open(FTO.c_str(), ios::in);
if (inverters.is_open())
{
while ( inverters.getline(line,1000) )
{
AnsiString inverter(line);
IVBox->Items->Add(inverter);
}
}
inverters.close();
FTO = ModDir + "modules.data";
modules.open(FTO.c_str(), ios::in);
if (modules.is_open())
{
while ( modules.getline(line,1000) )
{
AnsiString module(line);
ModBox->Items->Add(module);
}
}
modules.close();
CMod = 1;
CStr = 1;
CCell = 1;
nStore = 0;
grid = true;
pasan = false;
debug = false;
calc = false;
cell = false;
module = false;
array1 = false;
inv = false;
PV = true;
Parray = false;
Pcurve = false;
LastType = 'X';
CurrTp = -1; //* Not currently set
AllSame = true;
LdMeteo = false;
mpp = true;
}
It just opens the form as if it was run from the .exe file, except it shows
Compiling MyProject.cbproj (Release configuration).... Success
in the message bar
I've tried switching from release to debug mode, tried changing the output directories so it compiles new .obj files. No success.
I'm running Rad studio 2010, it was originally written in XE5, but I think this is an issue with folder structure rather than IDE version?
Any suggestions?
Some ideas (from various sources) that may or may not be useful to you:
make sure that you're using the Debug configuration and do a Build of the project, not just a Compile: switching back to debug configuration and doing a compile after a release build isn't enough
in your project options for Win32(Debug) make sure that the following options are set to the correct values
[C++ Compiler] → [Debugging] → [Debug information] = True;
[C++ Compiler] → [Debugging] → [Debug line number information] = True;
[C++ Compiler] → [Optimizations] → [Disable all optimizations] = True;
[C++ Compiler] → [Optimizations] → [Generate fastest possible code] = False;
[C++ Linker] → [Full Debug information] = True;
[Delphi Compiler] → [Optimization] = False;
[Delphi Compiler] → [Use debug .dcus] = True;
(e.g. the default configuration template for MDI application is wrong)
delete all the .pch, .# and .tds files and let the compiler recreate
if you are running the IDE under VirtualBox consider that some versions have problem with breakpoints (v4.3.x)
As a last resort you could try { _asm { int 3 } } to simulate a breakpoint.
Also take a look at:
Quality Central
Delphi: why breakpoints from time to time are not usable (green highlighted line on IDE)?
im writing a simple webcrawler. the problem is, with the link extraction.
i uses the cpp-netlib with boost. here a few lines of my CLink Class.
CLink::CLink(const CLink& father, const std::string& relUrl )
{
uri = relUrl;
boost::network::uri::uri instance(relUrl);
boost::network::uri::uri instanceFather(father.uri);
if ( (valid = boost::network::uri::is_valid(instance)) == 1)
{
scheme = boost::network::uri::scheme(instance);
user_info = boost::network::uri::user_info(instance);
host = boost::network::uri::host(instance);
port = boost::network::uri::port(instance);
path = boost::network::uri::path(instance);
query = boost::network::uri::query(instance);
fragment = boost::network::uri::fragment(instance);
uri = scheme;
uri += "://";
uri += host;
uri += path;
}
else
{
if ( (valid = boost::network::uri::is_valid(instanceFather)) == 1)
{
scheme = boost::network::uri::scheme(instanceFather);
user_info = boost::network::uri::user_info(instanceFather);
host = boost::network::uri::host(instanceFather);
port = boost::network::uri::port(instanceFather);
path = boost::network::uri::path(instance);
query = boost::network::uri::query(instance);
fragment = boost::network::uri::fragment(instance);
uri = scheme;
uri += "://";
uri += host;
uri += path;
}
}
};
CLink::CLink( const std::string& _url )
{
uri = _url;
boost::network::uri::uri instance(_url);
if ( (valid = boost::network::uri::is_valid(instance) ) == 1)
{
scheme = boost::network::uri::scheme(instance);
user_info = boost::network::uri::user_info(instance);
host = boost::network::uri::host(instance);
port = boost::network::uri::port(instance);
path = boost::network::uri::path(instance);
query = boost::network::uri::query(instance);
fragment = boost::network::uri::fragment(instance);
uri = scheme;
uri += "://";
uri += host;
uri += path;
}
else
std::cout << "err " << std::endl;
};
the links from the webpage i took with the htmlcxx lib. i took the HTML::Node and normalize them wih the boost filesystem.
if ( url.find("http://") == std::string::npos)
{
std::string path = link.get_path() + url;
url = link.get_host() + path;
boost::filesystem::path result;
boost::filesystem::path p(url);
for(boost::filesystem::path::iterator it=p.begin(); it!=p.end(); ++it)
{
if(*it == "..")
{
if(boost::filesystem::is_symlink(result) )
result /= *it;
else if(result.filename() == "..")
result /= *it;
else
result = result.parent_path();
}
else if(*it == ".")
{
// Ignore
}
else
{
// Just cat other path entries
result /= *it;
}
}
url = "http://" + result.string();
}
return ret;
Now the problem is.
i try to fetch http://www.wikipedia.de/ and i get the urls like
properties
http://wikimedia.de/wiki/Vereinszeitung
... ...
and on the site http://wikimedia.de/wiki/Vereinszeitung there is a link like /wiki/vereinsatzung
so often i get links like
http://wikimedia.de/wiki/Vereinszeitung/wiki/Freies_Wissen
does someone have a idee?
You need to have a special case for absolute links (those that start with /).
If the href starts with /, then the resulting link should be (using the terms from The URI template which come from the RFC):
[scheme]://[authority][what you got in href]
What you are currently constructing is:
[scheme]://[authority][path][what you got in href]
So you're duplicating the path information.
So if link.get_path() starts with /, you should simply change:
std::string path = link.get_path() + url;
url = link.get_host() + path; // this is incorrect btw, missing the [port]
to
url = link.get_host() + ":" + link.get_port() + url;
It would probably be cleaner to do the path normalization on the path only, not on the URL (i.e. add host:port after normalizing the path).
[And I think your code will fail if it encounters an https link.]