Code::Blocks Forums

User forums => Help => Topic started by: Lastmerlin on April 26, 2008, 10:11:56 pm

Title: [Solved] problems using c::b with mingw
Post by: Lastmerlin on April 26, 2008, 10:11:56 pm
I am trying to get a (so far linux only) project working on Windows Vista using Code::Blocks with MinGW.

The project consists of two separate programs, a server and a client. The structure is: Each part has its own source files (of course) but there are also some source files which are used both in the client and the server part (mainly some common data structures and some basic network stuff).
When trying to compile within C::B I get following error:

Quote
Compiling: main.cpp
mingw32-g++.exe: 5: No such file or directory

I have reduced the program to three files:
main.cpp
shared/debug.h
shared/debug.cpp

These files are also reduced to few lines, so i just quote them:

main.cpp:
Quote
#include <iostream>

using namespace std;

int main()
{
    cout << "Hello world!" << endl;
    return 0;
}


shared/debug.h
Quote
struct Test
{
  Test();

  int i;
};

shared/debug.cpp:
Quote
#include "debug.h"

Test::Test()
{
    i=0;
}

This is a minimal setup to reproduce the error.
If I remove the debug.* file then everything works fine.
I can also compile the whole thing in cmd:
Quote
C:\Users\hans\tests\cbtest>g++ -c -o main.o main.cpp

C:\Users\hans\tests\cbtest>g++ -c -o shared\debug.o shared\debug.cpp

C:\Users\hans\tests\cbtest>g++ -o hello main.o shared\debug.o

C:\Users\hans\tests\cbtest>hello
Hello world!

The first error message does not say that there is a problem with compiling main.cpp - main.cpp is compiled correctly and main.o is present after pressing >built< . But after compiling main.cpp it seems that c::b cant find the compiler any more. If I press built a second time i get:

Quote
Compiling: shared\debug.cpp
mingw32-g++.exe: 5: No such file or directory

So shared\debug.o is created but the next call of g++ (for linking) fails. After pressing built a third time i have my hello world program complete.

Quote
Linking console executable: bin\Debug\cbtest.exe
Output size is 584.46 KB

So always exactly _one_ source file is compiled and the next compiler call causes the error. This behavior is not nice, if your project gets a bit more than two .cpp files...

I have already extended the $path variable, this seems a common problem with mingw and vista. This didnt solve it :(

Thanks for any suggestions.
Title: Re: problems using c::b with mingw
Post by: MortenMacFly on April 27, 2008, 09:04:40 am
Please provide a zipped project (including the files you describe here *and* the C::B project file). Most likely this is a wrong project / target setup.
Title: Re: problems using c::b with mingw
Post by: Lastmerlin on April 27, 2008, 12:55:37 pm
la voila :)

I hope that this project shows the problem.

[attachment deleted by admin]
Title: Re: problems using c::b with mingw
Post by: Jenna on April 27, 2008, 01:20:41 pm
In the "Build Options" of your project you have to put an equal sign between "DEBUG_LEVEL" and  "5":
Code
DEBUG_LEVEL=5
Title: Re: problems using c::b with mingw
Post by: Lastmerlin on April 27, 2008, 07:12:35 pm
ah, this does it. Thank you very much.
Title: Re: problems using c::b with mingw
Post by: MortenMacFly on April 27, 2008, 08:07:54 pm
ah, this does it. Thank you very much.
Well... erm... nor more to say. Seems I was too late for offering a solution. ;-) Thanks Jens! :P