Author Topic: Compiler Loop  (Read 5647 times)

Offline zachris

  • Single posting newcomer
  • *
  • Posts: 9
Compiler Loop
« on: September 25, 2015, 03:53:56 pm »
Using Code::Blocks on Windows7
Compiling MinGw C++

This is about an occasional problem when compiling code that uses the EIGEN  template library.

I know the posting guidelines explicitly state that compiler errors ARE NOT a Code::Blocks problem. But, I've asked this question on the the Eigen forum and one the MinGw forum, and both have stated that this is a Code:Blocks problem. So here it goes.

I have one block of code in my program that makes use of functions that are part of the Eigen template library. Every time I update that code block it needs to be recompiled. Using the Build option causes an endless compiler loop that repeatedly references items from the Eigen template.  I need to abort build to get this loop to stop.  I then run Build again, and everything seems to compile just fine.

So, at one level this is not really a problem because I can get my program to successfully compile and run. I can also compile the code from the command line outside of Code::Blocks just fine. This is probably the best indicator that this IS a Code::Blocks problem.

It is a mystery.

What is going on here? What might I be doing wrong that is causing this? Is this an indication that I might not be able to compile this code within Code::Blocks in the future?

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Compiler Loop
« Reply #1 on: September 25, 2015, 07:52:34 pm »
This is about an occasional problem when compiling code that uses the EIGEN  template library.
I've never heard about a compiler loop. Does it mean C::B compiles forever? Or is it freezing which would point more to CC, for example? Are you sure that not something like your computer clock is not synchronised or you are compiling from a network share with invalid time stamps?

I'm afraid we will need a minimal sample to reproduce this. Is it possible you create an EIGEN "Hello World" that compiles forever?
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline zachris

  • Single posting newcomer
  • *
  • Posts: 9
Re: Compiler Loop
« Reply #2 on: October 05, 2015, 12:56:31 am »
Here is a simple "Hello World" that can go into an endless compiler loop. It is not a freeze, but an seemingly endless loop of the compiler.

I am not compiling from a network. MinGW, Code::Blocks, and my code all exist on the same hard drive of my Windows7 computer.

The loop does not happen every time. And when it does it is because of a change within  the MatrixStuff.cpp file or the MatrixStuff.h file.

To get the program to compile, I need to Abort and the Build again. Usually this results in a successful compile.

Main.cpp
Code
#include <iostream>
#include "MatrixStuff.h"

using namespace std;

int main()
{
   a(0,0)=1; a(0,1)=0; a(0,2)=0;
    a(1,0)=0; a(1,1)=1; a(1,2)=0;
    a(2,0)=0; a(2,1)=0; a(2,2)=1;

    b(0,0)=1; b(0,1)=2; b(0,2)=3;
    b(1,0)=4; b(1,1)=5; b(1,2)=6;
    b(2,0)=7; b(2,1)=8; b(2,2)=9;

    c=multiply(a,b);
    cout << "Hello world!" << endl;

    cout << c;
    return 0;
}

MatrixStuff.cpp

Code
#include "MatrixStuff.h"

Eigen::MatrixXd multiply (Eigen::MatrixXd, Eigen::MatrixXd)
 {
     return a*b;
 }

MatrixStuff.h
Code
#ifndef MATRIXSTUFF_H_INCLUDED
#define MATRIXSTUFF_H_INCLUDED

#include "Eigen/Dense"
    Eigen::MatrixXd a(3,3);
    Eigen::MatrixXd b(3,3);
    Eigen::MatrixXd c(3,3);


Eigen::MatrixXd multiply (Eigen::MatrixXd, Eigen::MatrixXd);

#endif // MATRIXSTUFF_H_INCLUDED


I know this code is not the best example of coding style. All it does is multiply a matrix by an identity matrix. And it does that in the most convoluted way possible, which was necessary to demonstrate the problem.

To repeat, the compiler loop does not happen every time. And it only happens when h file (or the associated cpp file) that directly accesses Eigen is chaged.



Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Compiler Loop
« Reply #3 on: October 05, 2015, 07:33:12 am »
The loop does not happen every time. And when it does it is because of a change within  the MatrixStuff.cpp file or the MatrixStuff.h file.
I don't have the Eigen lib, so the code does not compile. Please try to set the file's time stamps on all file (including Eigen) to a reasonable date.

But I really wonder why "a loop" should happen. 99% of all software is developed like this and works just fine. I doubt its really a C::B issue.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ