Results 1 to 5 of 5

Thread: Cross-compiling using mingw32 - adding libraries (freeglut)

  1. #1
    Join Date
    Jun 2008
    Location
    Uppsala, Sweden
    Beans
    30
    Distro
    Ubuntu 9.04 Jaunty Jackalope

    Cross-compiling using mingw32 - adding libraries (freeglut)

    So during the last few months I've been doing a simple game in c++ using opengl. Now that it's finished, it seems like all of my friends use windows, which I don't, so I realized I had to compile it for windows.

    I did a bit of research and found out that what I wanted to do was to cross-compile it, which could be done using the mingw32 package (available in the repos). Ok so I installed the thing and tried it on a small 'hello world' style program and it was all fine. However when I tried compiling my game, it was clear that the mingw32 libraries didn't have the freeglut libraries (only standard glut), hence glutLeaveMainLoop et al wasn't found. So I have to add these myself. The problem is that I have never done such a thing! If I'm not completely off, I first have to grab the freeglut source, compile it for windows (how?) and put the files in the mingw32 include folder.

    As you see I need a bit of help, and I'd be very grateful if someone could tell me the basic procedure!

    Also, what about the includes in the game source code? Do I have to change some of them, or add something like <windows.h> (which i've never understood)?

    Thanks in advance!

    Note: I found this thread. Since it's more about the wine related problem I decided to make a new thread. Hope that's ok.

  2. #2
    Join Date
    Dec 2006
    Location
    Australia
    Beans
    1,097
    Distro
    Xubuntu 15.10 Wily Werewolf

    Re: Cross-compiling using mingw32 - adding libraries (freeglut)

    If you have a copy of Windows, you could install VirtualBox and run Windows within VirtualBox to compile Free GLUT from source. I use this approach to test and compile programs on Windows.

    If you're feeling brave, you can try doing a normal ./configure && make, but use these flags for ./configure:
    Code:
    ./configure --prefix=/usr/i586-mingw32msvc --host=i586-mingw32msvc --build=i586-linux
    Be warned: the command above is just a rough guess and you will most probably need to change it. Trial is error is inevitable.

    I have found that the --build flag is particularly problematic. If you run /usr/share/libtool/config/config.guess, then it will spit out a value you can use for the --build flag.

    Again, I have to emphasise that this will probably involve a lot of trial and error, and may possibly bork your Mingw32 installation (or even worse, depending on your adventurousness).
    Last edited by samjh; November 12th, 2008 at 02:05 PM.

  3. #3
    Join Date
    Jun 2008
    Location
    Uppsala, Sweden
    Beans
    30
    Distro
    Ubuntu 9.04 Jaunty Jackalope

    Re: Cross-compiling using mingw32 - adding libraries (freeglut)

    Quote Originally Posted by samjh View Post
    If you have a copy of Windows, you could install [url=www.virtualbox.org]VirtualBox and run Windows within VirtualBox to compile Free GLUT from source. I use this approach to test and compile programs on Windows.

    If you're feeling brave, you can try doing a normal ./configure && make, but use these flags for ./configure:
    Code:
    ./configure --prefix=/usr/i586-mingw32msvc --host=i586-mingw32msvc --build=i586-linux
    Be warned: the command above is just a rough guess and you will most probably need to change it. Trial is error is inevitable.

    I have found that the --build flag is particularly problematic. If you run /usr/share/libtool/config/config.guess, then it will spit out a value you can use for the --build flag.

    Again, I have to emphasise that this will probably involve a lot of trial and error, and may possibly bork your Mingw32 installation (or even worse, depending on your adventurousness).
    ok thanks! this actually worked very well. here's what i did:

    Code:
    ./configure --prefix=/home/kalle/lib/freeglut --target=i586-mingw32msvc --host=i586-mingw32msvc --build=i686-pc-linux-gnu
    so now i have a couple of header files, a library .a file (and a '.la' file which i don't really know what it's for). Do i just have to put the header files in the include/GL directory and the .a file in the lib directory respectively, or do i have to let mingw32 "know they're there"?

  4. #4
    Join Date
    Dec 2006
    Location
    Australia
    Beans
    1,097
    Distro
    Xubuntu 15.10 Wily Werewolf

    Re: Cross-compiling using mingw32 - adding libraries (freeglut)

    I think if you put those files in the include and lib directories of your /usr/i586-mingw32msvc directory, it should be able to find them. Just make sure to specify the correct -I and -l flags when you compile.

    In fact, I think a sudo make install from your freeglut source directory should probably install those files for you, as you specified --prefix=/usr/i586-mingw32msvc for ./configure.

    Again, no guarantees. Cross-compiling is usually a pain in the posterior.

  5. #5
    Join Date
    Jun 2008
    Location
    Uppsala, Sweden
    Beans
    30
    Distro
    Ubuntu 9.04 Jaunty Jackalope

    Re: Cross-compiling using mingw32 - adding libraries (freeglut)

    Thanks again for your reply. Now I've got it working and this was how it was done:

    First I tried what you suggested, put the files in the correct folders and tried to compile. The compilation itself was ok, but I got a lot of linking errors. I could get rid of some of the by tweaking the -l commands, but all the errors involving freeglut specific commands just wasn't going away. At some point I lost interest.

    So since I actually already had a working WinXP virtual machine installed I followed your advice. And since there were a lot more documentation available regarding how to install freeglut on windows, I finally got it working (in conjugation with minGW). Considering the fact that it now works, I don't think I will bother setting up the original cross compiler under ubuntu, although it would be more convenient.

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •