Spaces in Paths

A number of readers have recently written me about an error they see when attempting to compile or execute an application or script in books such as, C++ All-In-One for Dummies, 3rd EditionBeginning Programming with Python For Dummies, Python for Data Science for Dummies, and Machine Learning for Dummies. Development environments often handle spaces differently because they’re designed to perform tasks such as compiling applications and running scripts. I had touched on this issue once before in the Source Code Placement post. When you see an error message that tells you that a file or path isn’t found, you need to start looking at the path and determine whether it contains any spaces. The best option is to create a directory to hold your source code and to place that directory off the root directory of your drive if at all possible. Keeping the path small and simple is your best way to avoid potential problems compiling code or running scripts.

The problem for many readers is that the error message is buried inside a whole bunch of nonsensical looking text. The output from your compiler or interpreter can contain all sorts of useful debugging information, such as a complete listing of calls that the compiler, interpreter, or application made. However, unless you know how to read this information, which is often arcane at best, it looks like gobbledygook. Simply keep scanning through the output until you see something that humans can read and understand. More often than not, you see an error message that helps you understand what went wrong, such as not being able to find a file or path. Please let me know if you ever have problems making the code examples in my books work, but also be sure to save yourself some time and effort by reading those error messages. Let me know if you have any thoughts or concerns about spaces in directory paths at John@JohnMuellerBooks.com.

 

Getting Your Favorite Application on the Web

The world where users sit in front of a desktop system all day managing data is going away. Users won’t settle for just sitting in front of a computer any longer—they want to compute using their smartphone, tablet, and any other device that comes to mind. A time is coming when a user who has an idea in the middle of the night will talk to the alarm clock, which will make the required changes while the user goes back to sleep. For today, however, users appear content to make their changes using the interesting array of technologies that are already available. Who knows, perhaps someone out there is actually using their Apple Watch to make changes to a report they need to give in a few hours.

The point of writing HTML5 Programming with JavaScript for Dummies, CSS3 for Dummies, and Security for Web Developers is to make these technologies available desktop developers who have become a bit nervous about the future of their favorite language. It’s unlikely that any developer has failed to observe the movement from the desktop to everywhere else. Fortunately, many languages you use today will compile to JavaScript. All you really need is the right tool to make the move. In fact, a recent ComputerWorld article discusses six of these tools in enough detail for you to at least gain an appreciation of what they can do for you. Therefore, it’s possible for you to move some of your favorite applications to the new reality of computing. The applications may run a bit more slowly, but they should work well.

Of course, some developers are in denial. They point out the reams of code already in existence and how organizations around the world will refuse the give them up. The organization may very well refuse to give the desktop application code up, but the user has already done so. Applications require willing users. In the absence of willing users, no mandate will force anyone to use a broken application. Users will find a way around the mandate and it’s likely that no amount of coercion will force users to comply with the dreams of developers who have stuck by the desktop system.

We’re talking average users here. Any user who uses applications for mundane tasks that long ago became the essence of modern business. Developers will still find people who actually do need the power of desktop applications. it’s entirely possible that both engineers and scientists will continue to use desktop applications far into the future, but these applications are at the periphery. The days of the desktop are gone—it’s time to get used to the idea that your next application will probably be web-based and that you’ll use a language appropriate for that venue to create it. In the meantime, you do have options for moving your existing code. Let me know your thoughts about applications that run anywhere on any device at John@JohnMuellerBooks.com.

 

Antivirus and Application Compilation

Sometimes applications don’t get along, especially when one application is designed to create new content at a low level and the other is designed to prevent low level access to a system. Such is the case with compilers and antivirus applications in some cases. I haven’t been able to reproduce this behavior myself, but enough readers have told me about it that I feel I really do need to address it in a post. There are situations where you’re working with source code from one of my books, compile it, and then have your antivirus application complain that the code is infected with something (even though you know it isn’t). Sometimes the antivirus program will go so far as to simply delete the application you just compiled (or place it in a virus vault).

The solution to the problem can take a number of forms. If your antivirus application provides some means of creating exceptions for specific applications, the easiest way to overcome the problem is to create such an exception. You’ll need to read the documentation for your antivirus application to determine whether such a feature exists.

In some cases, the compiler or its associated Integrated Development Environment (IDE) simply don’t follow all the rules required to work safely in protected directories, such as the C:\Program Files directory on a Windows system. This particular issue has caused readers enough woe that my newer books suggest installing the compiler and its IDE in a directory the reader owns. For example, I now ask readers to install Code::Blocks in the C:\CodeBlocks directory on Windows systems because installing it elsewhere has caused some people problems.

Unfortunately, creating exceptions and installing the application in a friendly directory only go so far in fixing the problem. A few antivirus applications are so intent on protecting you from yourself that nothing you do will prevent the behavior. When this happens, you still have a few options. The easiest solution is to turn the antivirus program off just long enough to compile and test the application. Of course, this is also the most dangerous solution because it could leave your system open to attack.

A safer, albeit less palatable solution, is to try a different IDE and compiler. Antivirus programs seem a little picky about which applications they view as a threat. Code::Blocks may cause the antivirus program to react, but Eclipse or Visual Studio might not. Unfortunately, using this solution means that steps in the book may not work precisely as written.

For some developers, the only logical solution is to get a different antivirus application. I’ve personally had really good success with AVG Antivirus. However, you might find that this product doesn’t work for you for whatever reason. Perhaps it interacts badly with some other application on your system or simply doesn’t offer all the features you want.

My goal is to ensure you can use the examples in my books without jumping through a lot of hoops. When you encounter problems that are beyond my control, such as an ornery antivirus application, I’ll still try to offer some suggestions. In this case, the solution truly is out of my control but you can try the techniques offered in this post. Let me know if you find other solutions to the problem at John@JohnMuellerBooks.com.

 

Choosing the GNU C++ Compiler

A number of readers have written to ask me about the reason I chose the GNU C++ computer for C++ All-In-One Desk Reference For Dummies. After all, there are many different C++ compilers on the market today. Actually, my coauthor, Jeff Cogswell, was the one who made that decision, but after listening to his reasons and researching a few of my own, I had to agree that the GNU C++ Compiler was the best choice at the time (and still is from many perspectives):

 

  • Standards Adherence: From what I’ve read and seen in my own coding efforts, the GNU C++ compiler adheres a bit better to the current standards. There are other compilers, such as Microsoft’s Visual C++, that include a host of special additions and exceptions that don’t adhere to the standard. Given the audience for this book, using a compiler that’s strong on the standards is a must. (This book doesn’t use any of the GNU C++ extensions.)
  • Cross-Platform Compatibility: This book has a mixed audience. I’ve received so many e-mails from Macintosh readers that I’ve provided a number of blog posts just for this group. Linux developers also like this compiler and have used my book to learn how to use it. Because there are so many different platforms that this compiler works on, I can reach a much broader audience with the book and help more people write applications in C++ as a result.
  • CodeBlocks Support: In order to write good C++ code, you really do need a good IDE. CodeBlocks is a free compiler that works well on Linux, Macintosh, and Windows machines. If we had chosen another compiler, it may not have been possible to provide great support for all three platforms and some readers would have been left out.
  • Community Support: Both the GNU C++ compiler and CodeBlocks enjoy a broad range of support from the open source community. Getting help with either product is relatively easy and normally free.
  • Cost: Many of the readers of this book are students of limited means or are hobbyists learning to write C++ applications on a shoestring. Using the GNU C++ compiler coupled with CodeBlocks offers a method of teaching C++ programming that doesn’t require any investment by the reader. If cost hadn’t been a factor, there are probably other compilers on the market that might be a little better choice than using GNU C++.


Yes, we could have used some other compiler when writing our book, but at the time, GNU C++ seemed to be the best choice available and I still think it’s the best choice today. Of course, it’s always nice to hear about alternatives. If you think there is a strong competitor for GNU C++ that’s free and runs on all three of the target platforms for this book, let me know at John@JohnMuellerBooks.com. Make sure you provide me with complete information, including a URL for the compiler’s site.

 

Checking Your Compiler in CodeBlocks

Compilers are important because they turn your human-readable source code into executable code that the computer understands. Selecting the right compiler is essential if you want to obtain the best results from your application. Some readers have asked, “Just how do you select a compiler when working with C++ All-In-One Desk Reference For Dummies?” The book assumes that you’re using the GNU GCC Compiler setting and there isn’t any guarantee another compiler will work with the book’s source code. Use these steps to check your compiler setting.

  1. Open the CodeBlocks application.
  2. Choose Settings | Compiler and Debugger. You’ll see the Compiler and Debugger Settings dialog box shown here:
    CompilerSettings
  3. Choose GNU GCC Compiler in the Selected Compiler field as shown in the figure.
  4. Click OK.

You should be ready to work with the book’s code at this point. Let me know if you have any problems choosing the right compiler at John@JohnMuellerBooks.com.