A number of issues

BlitzMax Forums/BlitzMax Beginners Area/A number of issues

xcessive(Posted 2011) [#1]
I just started with Bmax and am having a number of issues with it.

Firstly, I have installed MinGW (correctly, with all environment variables set up). However .cpp files don't seem to work. .c files compile and run fine. But in C++ functions cause the error "undefined reference to `FUNCTION NAME HERE'"

My second issue is with lists. I have been treating them like vectors but they are obviously not that similar. How do I access the object contained within a list?

For example: list.ValueAtIndex.method() doesnt work for me, and neither does list.last.field.

So my question is, how do I access the object as if it were through and handle/pointer/reference (whatever its called in Bmax)

Finally are there any good modules for arithmetic parsing? Or are there any built in? For example I input a string and it executes the arithmetic contained in the string.

eg. parse("10+5*(2+3)") would return 75.


Perturbatio(Posted 2011) [#2]
How do I access the object contained within a list?


You need to cast it when you retrieve it from the list since it will be returned simply as an Object type.


As regards Mathematics parsing, look in Brucey's Modules list (it has it's own forum area here).


xcessive(Posted 2011) [#3]
Ok thanks. How does one cast types in blitzmax?


xcessive(Posted 2011) [#4]
Sorry for the double post, but I just rebuilt all modules (I installed one of bruceys modules) and now I get all sorts of errors whenever I try and compile anything. Also the module did not work, it spits out about 100 lines of error in the console.

I get this whenever I compile anything:
Warning: .drectve `-aligncomm:_joyhandle,5' unrecognized
Warning: .drectve `-aligncomm:_ReadStream,2 ' unrecognized
Warning: .drectve `-aligncomm:_WriteStream,2 ' unrecognized
Warning: .drectve `-aligncomm:_ccinfo,5 ' unrecognized
Warning: .drectve `-aligncomm:_jerr,5' unrecognized
Warning: .drectve `-aligncomm:_stdin_,2 ' unrecognized
Warning: .drectve `-aligncomm:_stdout_,2 ' unrecognized
Warning: .drectve `-aligncomm:_stderr_,2' unrecognized
Warning: .drectve `-aligncomm:_bbGCStackTop,2 ' unrecognized
Warning: .drectve `-aligncomm:__bbusew,2' unrecognized
Warning: .drectve `-aligncomm:__bbNeedsLock,2 ' unrecognized
Warning: .drectve `-aligncomm:__bbLock,2' unrecognized

I'm pretty sure bruceys module doesnt work because of the aforementioned .cpp issue. I keep getting "undefined reference to" error.

eg:


C:/Program Files (x86)/BlitzMax/mod/bah.mod/muparser.mod/muparser.debug.win32.x86.a(glue.cpp.debug.win32.x86.o):glue.cpp:(.text+0x67): undefined reference to `_Unwind_Resume'
C:/Program Files (x86)/BlitzMax/mod/bah.mod/muparser.mod/muparser.debug.win32.x86.a(glue.cpp.debug.win32.x86.o):glue.cpp:(.text+0x7d): undefined reference to `_Unwind_Resume'
C:/Program Files (x86)/BlitzMax/mod/bah.mod/muparser.mod/muparser.debug.win32.x86.a(glue.cpp.debug.win32.x86.o):glue.cpp:(.text+0x146): undefined reference to `_Unwind_Resume'
C:/Program Files (x86)/BlitzMax/mod/bah.mod/muparser.mod/muparser.debug.win32.x86.a(glue.cpp.debug.win32.x86.o):glue.cpp:(.text+0x19d): undefined reference to `_Unwind_Resume'
C:/Program Files (x86)/BlitzMax/mod/bah.mod/muparser.mod/muparser.debug.win32.x86.a(glue.cpp.debug.win32.x86.o):glue.cpp:(.text+0x1aa): undefined reference to `_Unwind_Resume'
C:/Program Files (x86)/BlitzMax/mod/bah.mod/muparser.mod/muparser.debug.win32.x86.a(glue.cpp.debug.win32.x86.o):glue.cpp:(.text+0x233): more undefined references to `_Unwind_Resume' follow
C:/Program Files (x86)/BlitzMax/mod/bah.mod/muparser.mod/muparser.debug.win32.x86.a(glue.cpp.debug.win32.x86.o):glue.cpp:(.eh_frame+0x12): undefined reference to `__gxx_personality_v0'
C:/Program Files (x86)/BlitzMax/mod/bah.mod/muparser.mod/muparser.debug.win32.x86.a(muParserBase.cpp.debug.win32.x86.o):muParserBase.cpp:(.text+0x23f): undefined reference to `_Unwind_Resume'
C:/Program Files (x86)/BlitzMax/mod/bah.mod/muparser.mod/muparser.debug.win32.x86.a(muParserBase.cpp.debug.win32.x86.o):muParserBase.cpp:(.text+0x4d2): undefined reference to `_Unwind_Resume'

Last edited 2011


slenkar(Posted 2011) [#5]
instead of list.last.field.

do

myobject(list.last).field

you are casting from 'object' which has no fields
to 'myobject' which has the correct field

ah dunno about muparser, try posting it in bruceys mod forum

Last edited 2011

Last edited 2011


xcessive(Posted 2011) [#6]
Thanks very much, but that just gave me an error saying
"Unable to convert type from 'Object()' to '<unknown>'"


slenkar(Posted 2011) [#7]
are you literally typing in 'myobject(list.last).field' ?

what is the name of the object you are trying to get out of the list?
and what is the name of the field?


xcessive(Posted 2011) [#8]
No, I assumed that by myobject you meant the type of object I was using. Hence: myCustomType(list.last).name, was what i used.
"Print myCustomType(list.last).name"

The name of the object..? Do you mean to original handler I used? It was called test, ("test:myCustomType = new myCustomType") although i assumed that the list stored the actual object, not the pointer.

Name of the field is "name".

Last edited 2011


skidracer(Posted 2011) [#9]
Are you using latest BlitzMax from accounts->product updates section of this website?

What version of MinGW? The installer use to require selecting the g++ option to get c++ support when you first run it.

Also, recomended location for BlitzMax and MingW installations is c:/BlitzMax and C:/MinGW respectively so as to avoid any Vista type UAC difficulties which can manifest in all manner of wierd and wonderful ways.


slenkar(Posted 2011) [#10]
my bad, 'last' is a method of the list so you have to put brackets after it


e.g.

print mycustomobject(list.last()).name

to use valueatindex:

print mycustomobject(list.valueatindex(0)).name
print mycustomobject(list.valueatindex(1)).name
print mycustomobject(list.valueatindex(2)).name
etc.

Last edited 2011

Last edited 2011

Last edited 2011

Last edited 2011


xcessive(Posted 2011) [#11]
g++ is installed correctly, when I enter "g++ --version" in cmd it gives me version 4.5.0. I have the latest minGW (I got it off their site).
MinGW and blitzmax are both in the c:\ directory. I am also using the latest (1.41) version of Bmax.

Also thanks slenkar that worked perfectly!

Last edited 2011


Ole JR(Posted 2011) [#12]
Might it be that your gcc/g++ version 4.5 is the problem?

Think that the lib/linking changed somewhere between 3.x & 4.x

Could explain the 'undefined reference to ...' output.

The ar.exe and ld.exe in the Blitzmax/bin folder are 3.x,
so might work if you copy those over from the mingw/bin folder
and rebuild all modules?

Not sure about this

Last edited 2011


xcessive(Posted 2011) [#13]
Ole JR, thanks for helping. Now I get this error

Building Modules
Compiling:blitz_app.c
gcc: CreateProcess: No such file or directory
Build Error: failed to compile C:/BlitzMax/mod/brl.mod/blitz.mod/blitz_app.c
Process complete

When I try and re-build modules

:s


Czar Flavius(Posted 2011) [#14]
Don't use TList as a vector, it is a linked list. To access the n-th element, it must first seach (n-1) elements. First and Last, and EachIn to iterate all, are super fast though.

For a vector, use a regular array. when the array is full, it's easy enough to resize. Probably someone has already made a C++ style vector Type. If not, making your own would be good practice.

I'm rusty on array splicing, so someome else will need to show how to resize an array while maintaining its contents. You can do it by make a temp array of the right size and copying over, but there's a cool way to do it in a single line.

If you have an error which complains it cannot convert to Something(), this means you are using a function without brackets. The compiler gets confused and thinks you are making a function pointer, and then complains you can't store a function pointer in your normal variable.


Perturbatio(Posted 2011) [#15]
something like:

arr = arr[..10] 'resize to 10 elements


(You still need to initialize the new elements of the array since each new element will be null)

Last edited 2011


Czar Flavius(Posted 2011) [#16]
Are you sure? If the array is at least size 10, it will return the original elements, no? So if it is less than size 10, wouldn't the first portion be intact?


Perturbatio(Posted 2011) [#17]
yes, any existing elements would be intact, I was demonstrating resizing an array with the assumption that you want it bigger, not smaller.


Czar Flavius(Posted 2011) [#18]
Sorry I misunderstood.


GfK(Posted 2011) [#19]
Regarding the C++ problem, I had the same issue and solved it with another environment variable:

Var name: CPLUS_INCLUDE_PATH
Path: C:\MinGW\include;C:\MinGW\lib\gcc\mingw32\4.5.0\include

Check the 4.5.0 bit to make sure its valid for the version of MinGW that you have.


xcessive(Posted 2011) [#20]
I am NOT trying to use a list like a vector, I just said that I initially thought they were similar, but I quickly worked out they were not.

Gfk, I tried that, the path is correct, however im still getting a compiler error everytime I try and use c++.

This is getting ridiculous.


xcessive(Posted 2011) [#21]
Look, just to be clear my problem at the moment is that i can't rebuild the modules I get this error;

Building Modules
Compiling:blitz_app.c
gcc: CreateProcess: No such file or directory
Build Error: failed to compile C:/BlitzMax/mod/brl.mod/blitz.mod/blitz_app.c
Process complete


GfK(Posted 2011) [#22]
The other possible problem is that you're using the wrong version of MinGW. The latest version is absolutely rotten and I couldn't get it working fully - they seem to have updated it recently on the basis that "if it ain't broke, fix it until it is".

Anyway, I'd recommend uninstalling whatever version you currently have, and reinstalling the version which Ziggy links to here.


xcessive(Posted 2011) [#23]
Ok, I tried this, now blitzmax at least works (thanks you!) and can compile its own modules. Extra modules still don't work and I still get the c++ undefined function error.