We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi, In the project settings, I check the "Create batch file" opitons in the "Output" panel to generate a batch file, so that I may build the project without the Keil IDE. But the keil is install in the dir "D:\Program Files\Keil" on my computer (there is a ' ' in the path string). The last line of the batch file created by keil is D:\Program Files\Keil\ARM\BIN40\fromelf.exe ".\output\test.axf" --i32combined --output ".\output\test.hex" Note that there's no quote surrounding the path string. So I have to add the quotes to avoid the syntax error. It's very troublesome to editor the batch file every time after I rebuild the project in the Keil IDE (when a new source file is added, I have to rebuild it to update the batch file).
How can I solved this? Write another batch file to automaticly check and modify the batch file and finally open it?
So don't do that, then!
Seriously, it will cause you all kinds of grief like this - don't do it!
Sorry that doesn't fix the immediate problem.
Thanks for your reply. This is the first time I met the path name issue sice using Keil. Actually I've just written a simple windows console program and create another .bat file to help me automaticly fix this.
Ugly code. But it works.
// use this code to build a program, error_check.exe #include <iostream> #include <fstream> #include <stdio.h> #include <string> #include <list> char default_name[]="APP.BAT"; using namespace std; int main(int argc,char *argv[]) { char* name; if(argc>1){ name=argv[1]; cout<<"file name:"<<name<<endl; // output file name parameter } else name=default_name; ifstream fi(name, ios::_Nocreate); if(!fi.is_open()){ // if can't open cout<<"file open failed."<<endl; return 1; } // read file into memory typedef list<string> LineList; LineList list; for(string line; getline(fi,line);){ //line.search list.push_back(line); } bool shouldModify = false; string subStr("fromelf.exe"); // only check the last line string& s = list.back(); auto pos = s.find(subStr); if(pos!=-1){ if((s.at(0)!='"')&&(s.at(pos+subStr.length())!='"')){ cout<<"find a syntax error :"<<endl <<"\t"<<s<<endl <<"\t"<<"missing \""<<endl; shouldModify = true; const char *quote = "\""; s.insert(pos+subStr.length(), quote); s.insert(0,quote); cout<<"auto modify :"<<endl <<"\t"<<s<<endl; } } fi.close(); if(shouldModify){ ofstream fo(name, ios::_Nocreate); if(!fo.is_open()){ cout<<"file open failed."<<endl; return 1; } for(auto i=list.begin(); i!=list.end(); i++){ fo<<*i<<endl; } fo.close(); } }
:: arm_build.bat error_check.exe :: APP.BAT is generated automaticly by Keil IDE. APP.BAT
It's not just Keil. It's pretty much anything that relies upon command-line utilities to do the real work - which is pretty much any development tool!
Two rules to be safe:
1. No spaces in filenames (including folder names) where the tools are installed;
2. No spaces in filenames (including folder names) for any source file (including project files, etc).
Yes. And3 no Chinese Character besides :(
I guess it is because that many development tool are developed when the Windows did not even support long file name.
No. Unix systems do support spaces, but most Unix-based development tools still don't handle them correctly anyway.
And most Windows development tools are based on Unix tools.
Talking about Windows and file name support - M$ have for ages had rules for how to write well-working programs. Like not expecting what characters are valid in a file name except the characters that are explicitly forbidden. Despite that, it took many years before M$ managed to follow that rule in their own programs. They often either failed to save/load with people used national characters, or could save/load but used a font that showed a black box instead of the national characters.
The problems with spaces in file and directory names comes from todays use of graphical user interfaces, where spaces are natural to use. People who worked on the command line, either directly noticed issues with spaces and avoided using them, or learned to quote or escape their commands.
From the problems with spaces in file and directory names, we have to assume that Keil staff forgets to install their tools or source code in paths with spaces and then verify that all generated files do quote or escape spaces as required.
Thanks. I may reinstall Keil to another directory someday.
The default installation folder, I think, is C:\Keil
I don't like to go cluttering-up my root folder like that, but someone else installed it for me...
I clutter my root directory with a \bin\ where I add a number of tools that I don't want to disappear into the huge Program Files tree. All tools that makes use of command-lines or similar gets into the \bin\ tree, to make sure that Makefile etc will function as expected.
I also have \doc\ and \usr\ and these together with \bin are my main directories to backup.
Yes, that's what I do.
"I also have \doc\ and \usr\"
Likewise.
Note that the "My Documents" shortcut can be set to point to such a place...