Re: Re: mathlink beginner problem
- To: mathgroup at smc.vnet.net
- Subject: [mg33169] Re: [mg32900] Re: mathlink beginner problem
- From: Adalbert Hanssen <hanssen at zeiss.de>
- Date: Wed, 6 Mar 2002 01:55:55 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
Hi, Borut, I have no idea about gcc, but I once had a similar problem in a completely different context. Since no one else gave you a technical hint, I'll try it giving you some technical background on compilers, although I am not sure, if it really helps you. >Hi, > >AFAIK MathLink does not work with GCC. Get the free Borland C/C++ 5.5 >compiler if you like an command line. > >Regards > Jens > >Borut L wrote: >> >> Hi, >> >> I am feeling very depressed after I'd spent a full day with MathLink and >> having had no success. Please help. >> >> I use windows 2000 with Mathematica 4.0. >> I installed the free gcc compiler MinGW. >> Before moving on a real problem, I tough trying out a simple exercise would >> be a wise idea. I copied mathlink.h into /include and mprep into /bin. Then >> I tried to compile the addtwo.c (with .tm) from Todd Gayley's tutorial to >> MathLink like this: >> >> mprep addtwo.tm -o add.c >> gcc -o add add.c (this should make an executable out of a source, with >> source being preprocessed template file, if I understand this correctly) >> >> Then, ugly thing went over the screen, many of them, all like the two below: >> >> C:\DOCUME~1\bonaro\LOCALS~1\Temp\ccuYaaaa.o(.text+0x18e):add.c: undefined >> reference to `GetStockObject@4' It seems to me, that your compiler tries to reference GetStockObject (probably, it would be written this way on the C level, probably through macro expansion). Different compilers use different naming conventions. Some put one or two underscores after every external symbol name (i.e. f() will reference an external symbol f_ or f__, some put an @ after it instead of the underscore, others additionally put the alignment class or the number of arguments after the @ or they code other compiler specific things. Other compilers do the same thing by prepending each name in this manner. The reason is, that some compilers support different calling conventions, i.e. register based versus stack based. Before you can use compilation, linkage and debugging tools together with foreign libraries, you have to check very carefully, if the calling conventions completely matches. Some compilers have command line or pragma controllable features, which can influence the code generation, i.e. they manage different calling conventions and maybe even the way, how external references are made. Unfortunately I don't know gcc. You have to look up the documentation to see, if you can manage it, co generate output, which is compatible to the mathlink library object code. If you have found out about it, others in this group might be happy, to know about your findings. >> C:\DOCUME~1\bonaro\LOCALS~1\Temp\ccuYaaaa.o(.text+0x2ae):add.c: undefined >> reference to `MLGetInteger@8' >> >> (C:\DOCUME~\... is my temp dir) >> >> I tried various other approaches, but nothing worked. Nothing! >> >> Thank You for Your help, >> >> Borut Levart The easiest way, however is to use compilation tools, which are compatible with the supplied libraries, as Jens said. Best regards, Adalbert