c++ and includes

BlitzMax Forums/BlitzMax Programming/c++ and includes

Zeke(Posted 2010) [#1]
when i tried to compile bmax app with c++ imports. i got error 'printf: No such file or directory" or something like that. and after some googling, i found solution. "MinGW must be located on the same partition as the files you want to compile "
so when i copied app folder to C-drive it worked.
but i dont want store my projects in C: so i made small fix. i added all MinGW include\ folders to bmk cc_opts.

so in bmk_make.bmx and MakeApp function i added:
	cc_opts:+ " -IC:\MinGW\include"
	cc_opts:+" -IC:\MinGW\include\c++3.4.5"
	cc_opts:+" -IC:\MinGW\include\c++\3.4.5\backward"
	cc_opts:+" -IC:\MinGW\include\c++\3.4.5\mingw32"
	cc_opts:+" -IC:\MinGW\lib\gcc\mingw32\3.4.5\include"

and now it works in any drive.

is there better solution to do this?

i have tried Import "-IC:\MinGW......", not working.
made "module" and ModuleInfo "cc_opts: -IC:\MinGW..." and import that module, not working.

This is my test app

test.bmx:
SuperStrict
Import "cpp.cpp"

Extern
	Global TestMe:Int
	Function add:Int(a:Int , b:Int)
End Extern

Print "TestMe=" + TestMe

Print "Add=" + add(testme , testme)


cpp.cpp:
#include <stdio.h>

int TestMe=69; // c++ globals

extern "C" {	// extern all functions
	int add(int,int);
}

int add(int a,int b) { // function
	printf("Add: %d+%d=%d\n",a,b,(a+b));
	return a+b;
}



markcw(Posted 2010) [#2]
Sorry to be lazy but do you mean you could only get this partially working?

So why can't you store your stuff in C:? I don't understand why you need to complicate this.


xlsior(Posted 2010) [#3]
So why can't you store your stuff in C:?


Why would he _have_ to?

Programs enforcing essentially hardcoded paths on you can be really annoying. Perhaps he stored his project files on a server network share, that's automatically being backed up?


gman(Posted 2010) [#4]
greetings :) you dont need to have them in the same drive, you just need MingW in your path. i keep MingW and BMAX on a portable USB drive. when i need to run BMAX with MingW support i use a BAT file to start BMAX. the BAT file will temporarily add MingW to your path. i tested my setup with your example by relocating MingW to C and updating my BAT file to reflect the C:\MingW directory. my develop drive is D: with this setup your example compiled and ran correctly. see my post here for the BAT file:

http://www.blitzmax.com/Community/posts.php?topic=82239#930030


markcw(Posted 2010) [#5]
What do you mean "have to". I didn't say he had to, I asked why he didn't want to.

Yes there's no need to have the path hard-coded but we're talking about MinGW here. To get it compiling with Bmx on the C: drive is enough for most people.

Anyway, fortunately gman has come to the rescue. :)


Zeke(Posted 2010) [#6]
So why can't you store your stuff in C:? I don't understand why you need to complicate this.

because i keep my projects other drive. and i made fix, modified bmk and thats fine.
and thanks to gman.