Showing posts with label Compile. Show all posts
Showing posts with label Compile. Show all posts

Thursday, November 06, 2008

Prototypes working on Linux

Although developed aiming a cross-platform solution, the prototypes of my PhD research only have been compiled in Windows. Until now. Moved by the need of having my prototypes running on a Linux system, I dedicated a few hours to creating a makefile and making some slight changes in the code in order to compile the prototypes in Linux. It worked fine! Now I have my prototypes running in both Windows and Linux!

Wednesday, April 09, 2008

Me and C++, a love/hate relationship

It is not something new. It has always been like that. These last two days were just another example of this. Yesterday, I was cursing C++. I have been fighting to solve some major memory leaks on my code... and it was hard... I hate C++!!! Today I finally finished solving that problem and moved forward. Moved to a completely different issue. In this I apply the flexibility and power of C++ to implement an algorithm that can be compiled using only standard libraries or using wxWidgets (and taking advantage of it). The most beautiful point is that I did it in just a couple of hours and the only thing I now have to do, if I want to switch, is change a single line of code. Indeed, I love C++!!!

Tuesday, November 27, 2007

It was just a 'void' !!!

When I compiled a small application I wrote in C++ in Release Mode, the resulting 'exe' file crashed unexpectedly. Indeed the same code compiled in Debug Mode works fine. Initially I thought that it must be due to some failures in variables initialization, but no. When coding, I am usually very careful with that details.

I spent the whole afternoon trying to solve the problem. After a while I had already located the problem. The error occurs when accessing a list. Then I just had to figure out what I did wrong and solve it. But this apparently simple task was indeed a hard challenge. Finally, when I discovered the problem I was astonished by how strange it was.

I am using a list of pointers to instances of a class I defined. However, when I created the class, it was like this:

class MyClass : public {
(...)
MyClass();
(...)
}

Here, the class constructor does not have any parameters. It works perfectly fine in Debug Mode but it generates an error in Release Mode when using a list of pointers to this class. The solution was simple. I just have to change the constructor as depicted below.

class MyClass : public {
(...)
MyClass(void);
(...)
}

Damn! So much time lost because of a simple 'void'. Damn!

Monday, November 05, 2007

Compiling C++ on MS VS without IDE

Although many people ignore this functionality, it is possible to use the Microsoft Visual Studio .NET without opening the IDE. Indeed, many tasks can be made from the command line, thus providing a way to improve the scripting capabilities of this tool. For instance, to compile a project from the command line, only two steps are necessary:

  1. Set the environment variables (eventually they can be already set)

    Run "VCvars32.bat" (in .NET2003)

  2. Compile the project

    Call $ DevEnv project_name /Build configuration_name
With these functionalities, some scripting skills and using the task scheduler, complex tasks can be easily automated.