.:: Bots United ::.

.:: Bots United ::. (http://forums.bots-united.com/index.php)
-   General Programming (http://forums.bots-united.com/forumdisplay.php?f=25)
-   -   compile GNU/Linux binaries in Windows (http://forums.bots-united.com/showthread.php?t=3626)

Whistler 21-02-2005 02:41

compile GNU/Linux binaries in Windows
 
... It's just possible, this is what you need :)
http://filebase.bots-united.com/inde...on=file&id=278

It's actually just a mere build of the MinGW source code with some extra configs, as MinGW and GNU/Linux version of gcc are actually the same code.

koraX 21-02-2005 08:37

Re: compile GNU/Linux binaries in Windows
 
binaries can be compiled ?
what is this program doing ?
Does it compile source code ? If so, does it have support for SUSv3 or LSBSv2.01 under windows ?

Whistler 21-02-2005 11:27

Re: compile GNU/Linux binaries in Windows
 
it's just a GCC built under Windows in this way:
./configure --prefix=c:/gcc-gnulinux --target=i686-pc-linux-gnu
make
make install

Actually MinGW and *NIX gcc are the same code, this just enabled the GNU/Linux compiling instead of default MinGW Windows compiling. It should compile the same as GNU/Linux, but perhaps you need some extra libraries to compile something other than bots.

Pierre-Marie Baty 21-02-2005 15:05

Re: compile GNU/Linux binaries in Windows
 
Can it do cross-compiles? I'd be interested in compiling native Linux binaries for my metamod stuff without needing to upload my sources each time on the BU server.

sPlOrYgOn 21-02-2005 18:29

Re: compile GNU/Linux binaries in Windows
 
I just tried it with pbmm but it seems to create a .so file twice the size of when it is compiled on linux and also gets a badf load...:(
can i compile on the BU server too?

Pierre-Marie Baty 21-02-2005 19:55

Re: compile GNU/Linux binaries in Windows
 
Anybody who has a shell account on the BU machine can compile his plugins... but I think you don't have one yet because you don't have any website for your bot. One more reason to change that :)

Whistler 22-02-2005 01:40

Re: compile GNU/Linux binaries in Windows
 
well I've found the problem... try NOT to use "-march" parameter (like -march=i586 or so) and use "_i386.so" as the end of the filename and it should work in Metamod

also note that "gcc" is the C compiler, and "g++" is the c++ compiler so make sure you are compiling C++ code with "g++" command.

but the file size is still big, as it's totally staticly linked.

Whistler 22-02-2005 05:22

Re: compile GNU/Linux binaries in Windows
 
well you also need to use the "-static" parameter...

here's the work Makefile
PHP Code:

CPP g++
TARGET podbot_mm
BASEFLAGS 
= -Dstricmp=strcasecmp -Dstrcmpi=strcasecmp
OPTFLAGS 
= -DNDEBUG
CPPFLAGS 
= ${BASEFLAGS} ${OPTFLAGS} -O2 --I"../metamod-1.17/metamod" -I"../hlsdk/multiplayer/common" -I"../hlsdk/multiplayer/dlls" -I"../hlsdk/multiplayer/engine" -I"../hlsdk/multiplayer/pm_shared"

OBJ =     bot.\
    
bot_chat.\
    
bot_client.\
    
bot_combat.\
    
bot_globals.\
    
bot_sounds.\
    
compress.\
    
dll.\
    
engine.\
    
util.\
    
waypoint.o

${TARGET}_i386.so: ${OBJ}
    ${
CPP} -fPIC -shared -static -$@ ${OBJ} -ldl -lm

clean
:
    
rm -*.o
    rm 
-*.map

%.o:    %.cpp
    
${CPP} ${CPPFLAGS} -$< -$@

%.
o:    %.c
    
${CPP} ${CPPFLAGS} -$< -$@ 

looks like it's still far from being perfect :(

KaCaT 22-02-2005 08:07

Re: compile GNU/Linux binaries in Windows
 
Works fine, thanks! :)

btw, I've just found another similiar way to compile win32 binaries from linux 8D:
http://www.wxwidgets.org/technote/crosscmp.htm

Pierre-Marie Baty 22-02-2005 14:30

Re: compile GNU/Linux binaries in Windows
 
Yes, and I believe that's what Will Day does with metamod, he compiles everything on GNU/Linuts :)

The Storm 22-02-2005 17:02

Re: compile GNU/Linux binaries in Windows
 
Can someone explain me how to compile with this EPB. It will be good to have a linux version.

sfx1999 22-02-2005 17:12

Re: compile GNU/Linux binaries in Windows
 
So, how do I cross compile for the PDP-11? :P

Whistler 23-02-2005 03:17

Re: compile GNU/Linux binaries in Windows
 
"Can someone explain me how to compile with this EPB. It will be good to have a linux version."
just create a file named "Makefile" in your source directory, like this one:
PHP Code:

 CPP g++
TARGET epb
BASEFLAGS 
= -Dstricmp=strcasecmp -Dstrcmpi=strcasecmp
OPTFLAGS 
= -DNDEBUG
CPPFLAGS 
= ${BASEFLAGS} ${OPTFLAGS} -O2 --I"./hlsdk"

OBJ =     bot.o
    bot_chat
.o
    bot_client
.o
    bot_combat
.o
    bot_globals
.o
    bot_sounds
.o
    compress
.o
    dll
.o
    engine
.o
    util
.o
    waypoint
.o

${TARGET}_i386.so: ${OBJ}
    ${
CPP} -fPIC -shared -static -$@ ${OBJ} -ldl -lm

clean
:
    
rm -*.o
    rm 
-*.map

%.o:    %.cpp
    
${CPP} ${CPPFLAGS} -$< -$@

%.
o:    %.c
    
${CPP} ${CPPFLAGS} -$< -$@ 

(note that you MUST have a backslash after each ".o" file; the forum has bugs which ate up all backslashes)

write all your .cpp files in the list, change all .cpp to .o.

Then install the compiler, start a DOS prompt, run the setvars.bat file first and change into your source dir. Then run "make" and it should produce a epb_i386.so file and that's it.

Pierre-Marie Baty 23-02-2005 15:05

Re: compile GNU/Linux binaries in Windows
 
Quote:

Originally Posted by Whistler
(note that you MUST have a backslash after each ".o" file; the forum has bugs which ate up all backslashes)

I wonder what it would be like with the [ code ] tags instead...
Code:

CPP = g++
TARGET = epb
BASEFLAGS = -Dstricmp=strcasecmp -Dstrcmpi=strcasecmp
OPTFLAGS = -DNDEBUG
CPPFLAGS = ${BASEFLAGS} ${OPTFLAGS} -O2 -w -I"./hlsdk"
 
OBJ =        bot.o \\
        bot_chat.o \\
        bot_client.o \\
        bot_combat.o \\
        bot_globals.o \\
        bot_sounds.o \\
        compress.o \\
        dll.o \\
        engine.o \\
        util.o \\
        waypoint.o
 
${TARGET}_i386.so: ${OBJ}
        ${CPP} -fPIC -shared -static -o $@ ${OBJ} -ldl -lm
 
clean:
        rm -f *.o
        rm -f *.map
 
%.o:        %.cpp
        ${CPP} ${CPPFLAGS} -c $< -o $@
 
%.o:        %.c
        ${CPP} ${CPPFLAGS} -c $< -o $@

*edit* damn, yer right.
I'd better look into that someday.

The Storm 23-02-2005 16:27

Re: compile GNU/Linux binaries in Windows
 
It's not working :
here is the error messege:
make : <e=2>:
make : *** [EPB_i386.so] Error 2

Whistler 24-02-2005 01:25

Re: compile GNU/Linux binaries in Windows
 
in which step this error happened? would you post the full output?

(also you need to add the log.o to the list in Makefile if you haven't deleted it, and if you've created new files you need to add them as well)

The Storm 24-02-2005 22:23

Re: compile GNU/Linux binaries in Windows
 
Here :

dll.cpp:20: error: expected `>` before '*' token
dll.cpp:20: error: expected `,` or `;` before '*' token
dll.cpp:22: error: expected `>` before '*' token
dll.cpp:22: error: expected `,` or `;` before '*' token
dll.cpp:29: error: `GETNEWDLLFUNCTIONS` does not name a type
make: *** [dll.o] Error 1

The strange is that when I compile it with MSVC there is no problem.

Whistler 25-02-2005 01:29

Re: compile GNU/Linux binaries in Windows
 
then it's bacause something GNU/Linux specific is missing in the code... you gotta fix it first
search for "__linux__" in HPB bot and you'll see what's required

edit: I think this is the problem:
PHP Code:

// stuff for Win32 vs. Linux builds

#ifndef __linux__

typedef int (FAR *GETENTITYAPI)(DLL_FUNCTIONS *, int);
typedef int (FAR *GETNEWDLLFUNCTIONS)(NEW_DLL_FUNCTIONS *, int *);
typedef void (DLLEXPORT *GIVEFNPTRSTODLL)(enginefuncs_t *, globalvars_t *);
typedef void (FAR *LINK_ENTITY_FUNC)(entvars_t *);

#else

#include <dlfcn.h>
#define GetProcAddress dlsym

typedef int BOOL;

typedef int (*GETENTITYAPI)(DLL_FUNCTIONS *, int);
typedef int (*GETNEWDLLFUNCTIONS)(NEW_DLL_FUNCTIONS *, int *);
typedef void (*GIVEFNPTRSTODLL)(enginefuncs_t *, globalvars_t *);
typedef void (*LINK_ENTITY_FUNC)(entvars_t *);

#endif 

and it seems that in POD-Bot the GETNEWDLLFUNCTIONS isn't declared after the #else.

The Storm 26-02-2005 09:50

Re: compile GNU/Linux binaries in Windows
 
Thanks you Whistler. You was write ! The problem was in bot.h.
Now I succseful compile EPB for Linux. With the next release I will publish and the Linux version of EPB.
Thnaks you again.

EDIT : Did I must publish the source code of EPB if I publish a Linux version ?

Whistler 27-02-2005 02:29

Re: compile GNU/Linux binaries in Windows
 
"Did I must publish the source code of EPB if I publish a Linux version ?"
Nope, as you are just *USING* gcc, which is totally free and not restricted :)
perhaps you can read through the GPL to see in which case you need to release the sources.

sfx1999 27-02-2005 03:06

Re: compile GNU/Linux binaries in Windows
 
The PDP-11 is too new anyway. How do I cross compile for the ENIAC?

Whistler 27-02-2005 03:19

Re: compile GNU/Linux binaries in Windows
 
"The PDP-11 is to new anyway. How do I cross compile for the ENIAC?"
I don't think ENIAC uses software :) AFAIK you have to change the hardware to make programs in ENIAC

for PDP-11 there are several emulators and nowadays AT&T UNIX is free software, so you may find those ones :)

sfx1999 27-02-2005 05:45

Re: compile GNU/Linux binaries in Windows
 
Oops! I just fixed an error in my last post.

Anyway, I think it is kind of funny that GCC supports the PDP-11. I mean, the machine is so damn old. I have never even seen one.

FrostyCoolSlug 11-04-2005 05:15

Re: compile GNU/Linux binaries in Windows
 
As a note, mingw won't nessecerily compile ALL linux apps to windows, for example, anything which acts as a socket server (for whatever reason) requires the use of winsock, NOT the standard *nix socket.h you can use defines for it all, but it will get messy. For use in bots, its a 'quick fix', but don't expect it to hold out too well, POSIX is still a long way from being ported properly to windows (Hence the larger files).

As another note, cygwin doesn't support Shared Objects.. its a lose lose situation if you have something with both ;)

Whistler 14-06-2005 15:21

Re: compile GNU/Linux binaries in Windows
 
I've rebuilt the compiler and now it is GCC 2.95 so that it can build HPB bot straightly... and there is also no need to use "-static" now

you may want to redownload it

The Storm 01-07-2005 11:53

Re: compile GNU/Linux binaries in Windows
 
Whislter where is setvars.bat file? I can't compile in this way. :(

Whistler 01-07-2005 13:14

Re: compile GNU/Linux binaries in Windows
 
use this command:
path c:\gcc-gnulinux\bin;%path%

Pierre-Marie Baty 01-07-2005 17:09

Re: compile GNU/Linux binaries in Windows
 
Could you make it so that the install dir is changeable ?

The Storm 01-07-2005 19:14

Re: compile GNU/Linux binaries in Windows
 
Quote:

Originally Posted by Pierre-Marie Baty
Could you make it so that the install dir is changeable ?

I think that is only needed to change the command :

path c:\gcc-gnulinux\bin;%path%

with the dir that you are moved the folder.
For drive D: it will be :

path D:\gcc-gnulinux\bin;%path%

Pierre-Marie Baty 01-07-2005 19:50

Re: compile GNU/Linux binaries in Windows
 
I'm not sure. The GNU linker is weird. Whistler certainly knows more about it.

Whistler 02-07-2005 06:01

Re: compile GNU/Linux binaries in Windows
 
Maybe you will need to recompile the source code, as the path is hardcoded in the executable.

I'm not sure if setting the GCC_EXEC_PREFIX environment variable to the correct path and add a whole bunch of -I and -L parameters to the commandline will work, I haven't tried this. See the gcc manuals for details.


All times are GMT +2. The time now is 19:22.

Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.