Would it be possible to get a minGW version of the w32 c interface?I can link to it without linker errors, but I am getting weird runtimebehavior and this is what I would expect.Has anyone else tried to link using MinGW?Thanks
Michael,
I’m sorry, MinGW isn’t one of our supported compilers
/Simon
michael wrote:> Would it be possible to get a minGW version of the w32 c interface?i think minGW has a version of the w32{api, c interface}> I can link to it without linker errors, but I am getting weird runtime> behavior and this is what I would expect.if it links ok, maybe it does work… have you tried a trivialexample?> Has anyone else tried to link using MinGW?no, but i’m willing to help out – post your trivial extensionor client and i’ll see what i can do.ta, jack
Jack,
Below is a short test example. Built with mingw-gcc44 on win32 and
linked to w32 c interface libraries.
On linux 64 with gcc44, this outputs
>3
>98
On w32, this outputs
>1948
and throws error “The instruction at “0x00401429” referenced memory at
“0x00000004”. The memory cound not be “read”.”
Does this occur because malloc/new in msvc dll is different than mingw
malloc/new? Wouldn’t we need a mingw produced library in order to make
it work?
#include <k.h>
#include
using std::cout;
using std::endl;
void test()
{
const char* server = “”;
int port = 5001;
int handle = khp(server, port);
if (handle < 0)
{
cout << “Could not connect” << endl;
return;
}
cout << handle << endl;
K data = k(handle, “( sym:a
b`c)”, (K) 0);
cout << data->t << endl;
kclose(handle);
}
int main()
{
test();
return 0;
}
</k.h>
michael.plumlee wrote:
> Below is a short test example. Built with mingw-gcc44 on win32 and
> linked to w32 c interface libraries.
what commands did you issue to compile and link the code below?
>
> On linux 64 with gcc44, this outputs
>> 3
>> 98
>
> On w32, this outputs
>> 1948
>
> and throws error “The instruction at “0x00401429” referenced memory at
> “0x00000004”. The memory cound not be “read”.”
>
> Does this occur because malloc/new in msvc dll is different than mingw
> malloc/new? Wouldn’t we need a mingw produced library in order to make
> it work?
>
> -----
>
> #include <k.h>
> #include
>
> using std::cout;
> using std::endl;
>
> void test()
> {
> const char* server = “”;
> int port = 5001;
> int handle = khp(server, port);
> if (handle < 0)
> {
> cout << “Could not connect” << endl;
> return;
> }
>
> cout << handle << endl;
> K data = k(handle, “( sym:a
b`c)”, (K) 0);
> cout << data->t << endl;
>
> kclose(handle);
> }
>
> int main()
> {
> test();
> return 0;
> }
>
</k.h>
hi michael,
while i’m still interested in how you built your program,
i have a simple test case that works in MinGW:
in the MSYS bash shell:
$ cd /c/q
$ ls w32
c.dll c.lib c.obj q.exe
$ cat t.c #my code
#include “k.h”
main()
{K k,l,m;I i,j;
i=khp(“”,-1);
O(“khp=%d\n”,i);
k=ki(9);
O(“k=%d\n”,k->i);
r0(k);
R 0;
}
$ gcc t.c w32/c.lib
$ export PATH=$PATH:/c/q/w32/
$ ./a.exe
khp=-1
k=9
i use the c.lib (stub for the dll) because i can’t seem
to link statically to c.obj (missing tls_index and tls_array).
however i get the same result using MS tools linking to c.obj only:
C:\q> cl w32\c.obj t.c /nologo /link /defaultlib:wsock32 /nodefaultlib:libcmt
C:\q>c.exe
khp=-1
k=9
ta, jack.
Jack,
I was following the instructions on the MinGW site. It says to create
a .a using dlltool. I linked to the .a instead of the .lib like you
did. Otherwise, I built the program the same way. Once I linked to
the .lib, everything worked. Both in the simple program and my other
one. Thanks for the help.