You are not logged in.

#1 2011-04-21 05:20:25

The Mishanator
Member
From: Washington (state)
Registered: 2009-09-08
Posts: 54

cross compile with unix headers

is there a way to compile a program in linux for windows that contains unix headers (ie sys/socket.h)?
i've tried

i486-mingw32-gcc test.c -o test.exe -I/usr/include -L/usr/lib -static

but i get this:

In file included from /usr/include/sys/socket.h:40:0,
                 from test.c:1:
/usr/include/bits/socket.h:431:23: warning: 'struct mmsghdr' declared inside parameter list
/usr/include/bits/socket.h:431:23: warning: its scope is only this definition or declaration, which is probably not what you want
/tmp/cceCwExM.o:test.c:(.text+0x26): undefined reference to `_socket'
collect2: ld returned 1 exit status

the program i was compiling isnt anything fancy, just

#include <sys/socket.h>
#include <netdb.h>

int main(void) {
    int s = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
    return 0;
}

is it even possible? in windows, one can use cygwin's posix implementation (or whatnot) but i cant find these headers/libs for mingw.

Last edited by The Mishanator (2011-04-21 05:21:55)

Offline

#2 2011-04-21 15:45:42

tavianator
Member
From: Waterloo, ON, Canada
Registered: 2007-08-21
Posts: 859
Website

Re: cross compile with unix headers

I'm not an expert on windows compilation, but I don't think that the mingw compiler targets the cygwin environment.  I believe you'll have to use the cygwin gcc to do that, and I'm not sure if it supports cross compilation.

Offline

#3 2011-04-21 21:22:11

The Mishanator
Member
From: Washington (state)
Registered: 2009-09-08
Posts: 54

Re: cross compile with unix headers

Is there a cygwin gcc for linux?

Offline

#4 2011-04-22 14:40:23

tavianator
Member
From: Waterloo, ON, Canada
Registered: 2007-08-21
Posts: 859
Website

Re: cross compile with unix headers

Like I said, I'm not sure, but a quick google search seems to indicate that you could compile a cygwin gcc on linux, but it's fairly involved.

Offline

Board footer

Powered by FluxBB