Results 1 to 5 of 5

Thread: having trouble compiling clanlib programs on a mac

  1. #1

    Default having trouble compiling clanlib programs on a mac

    Hey everybody. I've downloaded clanlib and followed the instructions in the INSTALL.macosx, to the point that I can successfully compile a program within xcode and it will run.

    The problem is that this program expects there to be a frameworks folder (with all the frameworks that the installation created inside it) in "argv[0]/../frameworks". I know this because when I remove the frameworks folder it complains that it can't find it (at runtime). This would mean that these clanlib programs are compiled to link dynamically (right?).

    I would like to link statically and compile on the command line. I tried this command to compile the program off of the getting started page:

    g++ -F/Users/Mike/Desktop/ClanLib-0.8.0/MacOSX/ ~/ClanLibTest.cpp -o ~/ClanLibTest

    The -F argument is a mac only argument that tells the compiler where to search for frameworks similiar to -I

    It gives me the following errors:

    /usr/bin/ld: Undefined symbols:
    _main
    CL_SetupCore::CL_SetupCore(bool)
    CL_SetupCore::~CL_SetupCore()
    CL_ClanApplication::CL_ClanApplication()
    CL_ClanApplication::~CL_ClanApplication()
    typeinfo for CL_ClanApplication
    collect2: ld returned 1 exit status

    I'm using Mac os 10.4.9 (on an intel mac), ClanLib 0.8.0, Xcode 2.2.1, and g++ 4.0.1.

    How do you compile ClanLib programs from the command line on the mac.

  2. #2

    Default

    After some more searching and messing around I found out that frameworks are a mac-only form of a shared library. So I guess I answered my static linking question.

    I also found out that what clanlib/xcode is doing is compiling these programs to (dynamically) link to a "private embedded framework", when I want to link them to a regular shared framework in "/Library/Frameworks". This can be checked with "otool -L /path/to/your/program" and changed with "install_name_tool -change old_framework_path new_framework_path /path/to/your/program".

    Code:
    Mikes-Computer:~ Mike$ otool -L ~/ClanLibTest
    /Users/Mike/ClanLibTest:
            @executable_path/../Frameworks/ClanLib.framework/Versions/A/ClanLib (compatibility version 1.0.0, current version 1.0.0)
            @executable_path/../Frameworks/ClanApp.framework/Versions/A/ClanApp (compatibility version 1.0.0, current version 1.0.0)
            @executable_path/../Frameworks/ClanCore.framework/Versions/A/ClanCore (compatibility version 1.0.0, current version 1.0.0)
            /usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 7.4.0)
            /usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0)
            /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 88.3.7)
    Mikes-Computer:~ Mike$ install_name_tool -change @executable_path/../Frameworks/ClanLib.framework/Versions/A/ClanLib /Library/Frameworks/ClanLib.framework/Versions/A/ClanLib ~/ClanLibTest
    Mikes-Computer:~ Mike$ otool -L ~/ClanLibTest/Users/Mike/ClanLibTest:
            /Library/Frameworks/ClanLib.framework/Versions/A/ClanLib (compatibility version 1.0.0, current version 1.0.0)
            @executable_path/../Frameworks/ClanApp.framework/Versions/A/ClanApp (compatibility version 1.0.0, current version 1.0.0)
            @executable_path/../Frameworks/ClanCore.framework/Versions/A/ClanCore (compatibility version 1.0.0, current version 1.0.0)
            /usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 7.4.0)
            /usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0)
            /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 88.3.7)

    Oh and if anyone is having the same problem, the reason that I was getting the undefined symbols is that I didn't link with the ClanCore & ClanApp frameworks.

  3. #3
    Administrator Seth's Avatar
    Join Date
    Jul 2002
    Location
    Japan
    Posts
    5,343

    Default

    Hi Mike,

    What I did for my program is dragged the frameworks from the Clanlib project into my application that I used, then set it up to copy the frameworks into the application directory during the build, so the app is "stand-alone". (I sure don't want people to need clanlib frameworks installed separately!)

    I'd give you more details on how to set this up but I can't be arsed to turn my mac on right now.

    (you can download and look at the final directory structure here if you want: www.rtsoft.com/novashell

    How do you compile ClanLib programs from the command line on the mac.
    XCode can build from the command line, here is my .sh file that does it:

    Code:
    Pause()
    {
        key=""
        echo -n Hit any key to continue....
        stty -icanon
        key=`dd count=1 2>/dev/null`
        stty icanon
    }
    
    sh mac_svn_update.sh
    
    cd ../mac
    echo Building universal release game binaries
    
    xcodebuild -target novashell_release
    if [ $? -ne 0 ]
    then
    echo -e "Error building game, check it out. \a"
    Pause
    exit
    else
    echo "Success!"
    fi
    Seth A. Robinson
    Robinson Technologies

  4. #4

    Default

    ...so the app is "stand-alone". (I sure don't want people to need clanlib frameworks installed separately!)
    There seems to be both good and bad things about private embedded frameworks. I think they will work better for deployment purposes than for development purposes. They also only work if you decide to put your program in an application bundle.

    XCode can build from the command line
    I wasn't referring to XCode. Here is what I was talking about:

    Code:
    g++ ~/ClanLibTest.cpp -o ~/ClanLibTest -F/Users/Mike/Desktop/ClanLib-0.8.0/MacOSX/ -framework ClanLib -framework ClanCore -framework ClanApp
    This works for people who don't like Xcode.

    I added the ClanLib frameworks to /Library/Frameworks/ so that I can compile and run ClanLib programs easily. Then when this program is ready for deployment I can just use install_name_tool and decide whether it would be better to use a private embedded framework or a shared framework. That's the way I plan on doing development with ClanLib anyway.

    By the way, thanks for the help Seth (and ClanLib too).

  5. #5
    ClanLib Developer
    Join Date
    Sep 2006
    Location
    Denmark
    Posts
    554

    Default

    I would highly recommend against installing the ClanLib frameworks as shared frameworks. Shared frameworks suffer from the usual problems that all other shared dynamic libraries have: versioning conflicts. One ClanLib application may be dependent on a bug existing in a certain version of ClanLib, and another application may have chosen to fix the bug in the ClanLib code (it is open source after all). If both applications install a shared framework using the same version, the second program will break the first program.

    Shared libraries in general only makes sense if a significant amount of applications share the functionality, and even when that is the case, it can be argued that modern computers have enough memory and disk space to only make it reasonable for OS specific frameworks.

    I'm not sure why you are against building your application as an Application Framework, since it is actually one of the really neat features of OS X. When you build it as an app framework, you effectively make it look like one unit to the Finder application, and thus allow a user to treat your application as a single executable. Application frameworks can actually include multiple executables (i.e. for powerpc, x86 and x64 architectures), and they can include all resources required for your application to operate. You also escape any installation requirements - double-click and your app starts. Want it moved to a different computer or disk drive? No problem, just drag the app icon to it.

    If you really prefer a static binary in the older unix way, try the --static parameter to gcc. If that doesn't work, try see if the configure script works for OS X. If it does, it should build you static or dynamic libraries of the type you desire.

Similar Threads

  1. Error in compiling Examples
    By Nikitto46 in forum Official ClanLib SDK Forums
    Replies: 5
    Last Post: 10-16-2007, 02:07 PM
  2. Error in compiling my first program
    By Nikitto46 in forum Official ClanLib SDK Forums
    Replies: 2
    Last Post: 03-29-2007, 02:42 PM
  3. Trouble
    By FQ101 in forum Funeral Quest
    Replies: 1
    Last Post: 02-09-2007, 05:05 AM
  4. error compiling 0.9 svn
    By voudras in forum Official ClanLib SDK Forums
    Replies: 0
    Last Post: 01-11-2007, 06:47 AM
  5. anyone else having trouble getting
    By jimbobbucky in forum Funeral Quest
    Replies: 4
    Last Post: 07-16-2003, 04:41 AM

Bookmarks

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
  •