Compiling C++ module compiling problem

BlitzMax Forums/BlitzMax Programming/Compiling C++ module compiling problem

gameshastra(Posted 2007) [#1]
Hi,
I am trying to compile a C++ module with blitzmax
I have installed mingw 3.1.0 to c:\mingw
set the environment variable MINGW to c:|mingw
and included c:\mingw\bin in the path
My code is not compiling and giving a lot of errors.

This is with reference to the topic I created in the GUI group on custom mouse pointers in which some c code was given to me by brucey
Since I am not getting any response in that group I thought about posting the question here
Regards,
D.Ramesh


H&K(Posted 2007) [#2]
Hummm, lots of errors eh. Ummm, maybe the E key doesnt work on you keyboard, and youve missed the E from everything that needs an E


gameshastra(Posted 2007) [#3]
That's not the case
I am talking about the code brucey posted in the GUI group in the topic Custom Mouse Pointers In the same posting I have given a list of the errors . I need some help here

Ramesh


H&K(Posted 2007) [#4]
Well, post a link then, cos I for one am not going to do a google search to find the errors you posted. Admitedly, I probably wont know what the problem is either, but you never know.

I posted these errors somewhere else, what the problem



H&K(Posted 2007) [#5]
C:/Program Files/BlitzMax/mod/pub.mod/stdc.mod/stdc.h:5:19: ctype.h: No such file or directory
C:/Program Files/BlitzMax/mod/pub.mod/stdc.mod/stdc.h:6:19: stdio.h: No such file or directory
C:/Program Files/BlitzMax/mod/pub.mod/stdc.mod/stdc.h:7:20: string.h: No such file or directory
C:/Program Files/BlitzMax/mod/pub.mod/stdc.mod/stdc.h:8:20: stdlib.h: No such file or directory
C:/Program Files/BlitzMax/mod/pub.mod/stdc.mod/stdc.h:9:20: stdarg.h: No such file or directory
C:/Program Files/BlitzMax/mod/pub.mod/stdc.mod/stdc.h:10:20: assert.h: No such file or directory
C:/Program Files/BlitzMax/mod/pub.mod/stdc.mod/stdc.h:11:22: sys/stat.h: No such file or directory
C:/Program Files/BlitzMax/mod/pub.mod/stdc.mod/stdc.h:12:18: time.h: No such file or directory
C:/Program Files/BlitzMax/mod/pub.mod/stdc.mod/stdc.h:24:21: direct.h: No such file or directory

Well do you have all these header files or not?
If so, are they properly linked, (That is in C++ the compiler looks in loads of places, but BMax tends not to, so 1) Put them in a path that Bmax can find, or 2)Change the referance to them to a absolute path.


Brucey(Posted 2007) [#6]
Ho hum... I know whenever I see my name there's trouble...

Anyways... ignore what H&K says above, especially since he left an E out of reference... (that and he seems to have misplaced his patients)

The errors indicate that your MinGW installation possibly isn't quite right. The Header files are part of MinGW, and if all is well, the compiler should have no trouble finding them.

Proper things to check...
1) In the Program menu of the IDE, is "Build Modules" and "Rebuild All Modules" enabled or not? (If not, your MinGW isn't set up properly).
2) Is your BlitzMax up to date? (1.24 with latest syncmods) - better safe than sorry.
3) If you open a CMD window, and enter "gcc --version" (without the quotes), do you get the version information for gcc? (this indicates if your path at least is correct).
4) Double-check that c:\mingw\bin is there. There should also be folders like c:\mingw\include , etc.

Then report back here for tea and biscuits... ;-)


Brucey(Posted 2007) [#7]
By the way... starting your BlitzMax programming career trying to compile up a c++ file is a bit of a leap into the unknown.

The lesser of us tend to start with a simple Hello World.bmx ....

Just a thought :-)


gameshastra(Posted 2007) [#8]
Thanks Brucey

Following is the status of the items you listed
1) Build and Rebuild All in the ide are enabled
2) Blitzmax version is 1.24 and we have used synchronize modules to download the MaxGUI module that we purchased
3) gcc --version is working
4) c:\mingw is there C:\mingw\bin c:\mingw\include are existing
the other directories under mingw are doc,lib,mingw,mingw32,uninstall


D.Ramesh


gameshastra(Posted 2007) [#9]
Originally we installed blitzmax_118_win32.exe for blitzmax
then we install blitzmaxupdate124_win32_x86.exe to get version 1.24.

Ramesh


Dreamora(Posted 2007) [#10]
just to make sure

Your code is MingW 3.1.0.1 = GCC 3.3 / 3.4 compliant, not following any newer C++ features?


H&K(Posted 2007) [#11]
Sorry. I was a bit of a btch there. No sleep Marathon fall of angels game.

Still looks like a path problem to me.
"c:\mingw\bin" Did you spell/type this right in enviroment variables?


Brucey(Posted 2007) [#12]
Can't think of anything else really.

What happens when you choose Build Modules? It should build all modules the first time. If that works, then I reckon there's something wrong with the code you are trying to compile...


SebHoll(Posted 2007) [#13]
Are you running Vista?


gameshastra(Posted 2007) [#14]
I am running Window XP. Is there a way of setting additional include paths for the compiler. The C++ code giving problem is given below

#include "win32gui/win32hwnd.h"

extern "C" {

void SetCustomPointer(char * file);

}

void SetCustomPointer(char * file) {

bbSetCursor((HCURSOR)LoadImage( 0, (LPCTSTR) file, IMAGE_CURSOR, 0, 0, LR_LOADFROMFILE | LR_SHARED));

}
-----
Ramesh


gameshastra(Posted 2007) [#15]
The gcc version it gives is 3.2.3

---
Ramesh


Brucey(Posted 2007) [#16]
*sigh* ... yes, yes, it's all my fault.

This code really wants to be wrapped up in a "proper" module where it would have been tested properly and even debugged before release.
As yet I have not had time to pull off such a feat (and hinted as such in the original post). That and I need to look into the GTK way of doing it too before I stuff all the cross-platform code into a module.

Seb's probably not too busy, and I bet he's always wanted to make a module... ;-)


gameshastra(Posted 2007) [#17]
blitzmax is installed in c:/program files/blitzmax and the win32hwnd.h file above is in
C:\Program Files\BlitzMax\mod\brl.mod\win32maxgui.mod\win32gui

How does mingw know how to include files from there ?

Ramesh


Winni(Posted 2007) [#18]
#include "win32gui/win32hwnd.h"

I'm no C++ guru, but I certainly dislike the language. :)

Anyway, doesn't that #include directive instruct the compiler to look in a subdirectory "win32gui" of the current directory for the header file named "win32hwnd.h"?

If you want the compiler to look for it in the default include directory, you have to put it in <> like so:

#include <win32gui/win32hwnd.h>


Brucey(Posted 2007) [#19]
It shouldn't matter in BlitzMax if you've previously done something like :

Import "dir/*.h"

Blitz adds all the headers with -I so it should find it. - And it does in my original example.

How does mingw know how to include files from there ?

Because in the .bmx file you have something like :

Import BRL.Win32MaxGUI

which itself sets up all it's own imports and header includes.

It's all kind of one big cascading monster of path settings which, by the time it's your own code's turn to compile something, everything should be set up and ready to go.


TomToad(Posted 2007) [#20]
MINGW to c:|mingw

Was this just a typing error in your message or do you really have your environment variable set up like this? If the latter, it should be c:\mingw.

Also I had a similar problem once. Turned out to be a bad MingW install. A reinstall of MingW fixed that.


SebHoll(Posted 2007) [#21]
Seb's probably not too busy


Sorry, but I am *actually* really busy at the moment with work. However, I needed a break after lunch so I had a crack at making a module and, well, this is the result. I give to you V1.10 of BaH.ChangeCursor (thought I'd use Brucey's extension in case it eventually finds it way onto syncmods). I really hate coding with Windows API but after 2-3 hours, I've managaged to get it working. I wonder how you've managed to do this for every single one of your modules Brucey - it takes a lot out of you! I don't know C++ at all, and it took a while to get all the structs right, but you should be able to set a pixmap as a cursor on Windows and OS X.

Anyway, this is seriously all I have time to do, but I thought I'd post it anyway for gameshastra who appears to be having real difficulty with compiling C++.


Brucey(Posted 2007) [#22]
Heh... cool.. I might have a look at this tomorrow at work :-)

I wonder how you've managed to do this for every single one of your modules

It's not too bad really. Core work is usually in Linux - cuz everything always works first time there. The usually it's a "See if it will compile first time on Mac". Does 80% of the time. Windows sux the most usually as it does things backwards more often than not. But because of the three platforms, each has it's own issues which result in much better code at the end of the day.

btw, how can you possibly put work before BlitzMax coding ?!!?!?! ;-)


SebHoll(Posted 2007) [#23]
btw, how can you possibly put work before BlitzMax coding ?!!?!?! ;-)

:-)

I forgot that your Mac OS X hack was based upon pixmaps so would be really easy to implement - therefore I've added the code from the other thread, and have re-uploaded the ZIP file (now V1.10). Not sure about memory leaks but its there. I've updated my original post to take account of this - though I haven't tested it on my Mac yet.


Brucey(Posted 2007) [#24]
I'll try and squeeze in some time at the weekend and see if I can't get a GTK implementation working.
I could also sort out leaks and things if you want, when I get the chance. It's something to do...


gameshastra(Posted 2007) [#25]
with seb's code I get the error can't find interface to module bah.changecursor

To change the cursor I would like code that uses win32 API directly and not through GTK.

Ramesh


SebHoll(Posted 2007) [#26]
with seb's code I get the error can't find interface to module bah.changecursor

Did you extract the zip file into the BlitzMax\mod directory? - You should then have file structure of something like BlitzMax\mod\bah.mod\changecursor.mod . If you've done this and are still getting the problem, try running Build Modules and Document Modules from the BlitzMax IDE Tools menu.


gameshastra(Posted 2007) [#27]
Thanks
It is working with seb's code now. I will check it out further to establish it is working well for my application.
I need to also be able to compile a c++ subroutine from within blitzmax in case I need to implement some c++ code for my application. I also need to know if I can pass a window handle also to a c++ module. The latter I should put in its own topic .

Until I get any other problems.
Thanks very much

Ramesh


SebHoll(Posted 2007) [#28]
I also need to know if I can pass a window handle also to a c++ module

Yep, you can by using QueryGadget(myWindow,QUERY_HWND), which will return the handle given to the window internally by the API.


gameshastra(Posted 2007) [#29]
Hi Seb,
I am having a problem on another machine with the changecursor module. I thought it may required to have the the ming compiler on that machine and installed that as well. I still get the error can't find interface to module changecursor.mod. The BlitzMax version on that machine is 1.18 your help is appreciated.
Thanks
Ramesh


Gabriel(Posted 2007) [#30]
Modules built for one version of BMax are not compatible with other versions. You either have to have the same version on both ( and I can't see why you'd be running an old version anyway ) or compile it on the machine with the old version separately.


gameshastra(Posted 2007) [#31]
Firstly I must hugely thank seb and brucey for adding a module for changing the cursor on my request. I was testing out the same these few days so that I can test that it works without any bugs.
The module is working well with maxgui but not without it Is it possible to make it work in blitzmax without maxgui.

Ramesh


gameshastra(Posted 2008) [#32]
Hi,
The custom cursor module works with Maxgui but not with a single graphics application window. In our project it is required to do this. Can the code be modified for this.
Regards,
Ramesh