Go Back   AC3D Forums > Technical > AC3D Developers
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Display Modes
Old 7th January 2008, 01:14 PM   #1
conzar
Member
Advanced member
 
conzar's Avatar
 
Join Date: May 2006
Posts: 36
Default Compiling for GNU/Linux, OSX, and XP

Hello all,
So I have developed some plugins under GNU/Linux. I am able to compile the plugins and run them in the GNU/Linux version of AC3D without any trouble. I created a script to handle the compiling for me which is listed below in the code section.

So I guess what I would like to know is how do you compile under OSX and Windows? When I try to run this script in OSX, it fails b/c "ld" doens't know what the "-shared" flag is.

I have no idea how to compile in windows.

Does anyone have a script for compiling in either of the metioned OS's?

Code:
#!/bin/bash

AC3D_HOME=/Applications/creators/ac3dmac
AC3D_PLUGIN=$AC3D_HOME/plugins
AC3D_SCRIPTS=$AC3D_HOME/scripts

function compile {
    g++ -c $PROG.cpp
}

function linkIt {
    ld -shared $PROG.o -o $PROG.p
}

function copy {
    cp $PROG.p $AC3D_PLUGIN/.
    #cp $PROG.tcl $AC3D_SCRIPTS/.
    cp $PROG.tcl $AC3D_PLUGIN/.
}


if [ $1 ]; then
    PROG=$1
    echo 'Compiling '
    compile
    echo 'Linking'
    linkIt
    echo 'Copying'
    copy

else
    echo "Usage: compile <prog name>"
fi
conzar is offline   Reply With Quote
Old 7th January 2008, 02:57 PM   #2
Andy
Administrator
Professional user
 
Andy's Avatar
 
Join Date: Jun 2003
Posts: 4,451
Default Re: Compiling for GNU/Linux, OSX, and XP

OS X is slightly different to Linux

from a makefile:

Quote:
UNIVERSAL=-arch ppc -arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4

CFLAGS= -dynamic -DMAC -DMACINTOSH -I${INCLUDE} ${UNIVERSAL}
CC=g++
LD=g++
Andy is offline   Reply With Quote
Old 7th January 2008, 05:01 PM   #3
conzar
Member
Advanced member
 
conzar's Avatar
 
Join Date: May 2006
Posts: 36
Default Re: Compiling for GNU/Linux, OSX, and XP

So I've created a script for OSX; however, I get the following error when I try to run it.
Code:
i686-apple-darwin9-g++-4.0.1: ppc: No such file or directory
It looks like the compiler doesn't like the UNIVERSAL variable. Any ideas?

Code:
#!/bin/bash
UNIVERSAL="-arch ppc -arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4"
CFLAGS="-dynamic -DMAC -DMACINTOSH -I$INCLUDE $UNIVERSAL"
CC=g++
LD=g++ 
    
function compile {
    $CC $CFLAGS -c $PROG.cpp
}
function linkIt {
    $LD $CFLAGS -shared $PROG.o -o $PROG.p
}   
    
if [ $1 ]; then
    PROG=$1
    echo 'Compiling '
    compile
    echo 'Linking'
    linkIt
else
    echo "Usage: compile <prog name>"
fi
conzar is offline   Reply With Quote
Old 9th January 2008, 06:16 PM   #4
conzar
Member
Advanced member
 
conzar's Avatar
 
Join Date: May 2006
Posts: 36
Default Re: Compiling for GNU/Linux, OSX, and XP

Ok guys, I figured out how to compile the plugin for OS X.

The code for this is shown below
Code:
CFLAGS="-dynamic -DMAC -DMACINTOSH"
PROG=$1

g++ $CFLAGS -c $PROG.cpp
g++ -dynamiclib -flat_namespace -undefined suppress -o $PROG.p $PROG.o
Ok. So now that I am compiling under GNU/Linux and OSX, how do I compile under win XP? I only have the headers so I think from reading other forum posts that I need a .dll. Is this right? I also read that there is a makefile associated with this .dll. I really don't want to have to use an IDE in windows to compile this so any command line script would be great.
conzar is offline   Reply With Quote
Old 10th January 2008, 07:09 AM   #5
Andy
Administrator
Professional user
 
Andy's Avatar
 
Join Date: Jun 2003
Posts: 4,451
Default Re: Compiling for GNU/Linux, OSX, and XP

Here's a bit from a windows makefile:

Code:
 
.cpp.p:
cl -DWINDOWS -I..\src -c $*.cpp -o $*.obj /Zi
link /dll /out:$@ $*.obj ..\ac3d.lib /DEBUG /DEBUGTYPE:CV
for a script, you'll need to replace $@ by pluginname.p and $* by the source filename without extension
Andy is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



All times are GMT -4. The time now is 02:41 PM.


AC3D Forum
(C) Inivis Limited 2020