在 Xcode 4 中使用快板 [英] Using allegro with Xcode 4

查看:21
本文介绍了在 Xcode 4 中使用快板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 Xcode 4 构建一个简单的快板项目.

I am trying to build a simple allegro project with Xcode 4.

#include <stdio.h>
#include <allegro5/allegro.h>

int main(int argc, char **argv)
{
    ALLEGRO_DISPLAY *display = NULL;

    if(!al_init()) {
        fprintf(stderr, "failed to initialize allegro!\n");
        return -1;
    }

    display = al_create_display(640, 480);
    if(!display) {
        fprintf(stderr, "failed to create display!\n");
        return -1;
    }

    al_clear_to_color(al_map_rgb(0,0,0));

    al_flip_display();

    al_rest(10.0);

    al_destroy_display(display);

    return 0;
}

我可以使用以下命令从终端构建运行它,但在 Xcode 4 中我没有运气.我没有 Xcode 3 可以再尝试了.=\

I can build an run it from the terminal using the following command, but in Xcode 4 I have had no luck. I don't have Xcode 3 to try anymore. =\

gcc alleg5test.c -o alleg5test -L/usr/local/lib -lallegro -lallegro_main

我的 Xcode 4 项目是使用控制台应用程序模板创建的.对构建设置进行了以下更改

My Xcode 4 project is created using the console application template. The following changes were made to the build settings

标题搜索路径/usr/local/include
库搜索路径/usr/local/lib
其他链接器标志 -framework Cocoa -lallegro -lallegro_main

Header Search Paths /usr/local/include
Library Search Paths /usr/local/lib
Other Linker Flags -framework Cocoa -lallegro -lallegro_main

当我尝试从 Xcode 构建项目时出现以下错误

I get the following errors when I try to build the project from Xcode

Build target Test of project Test with configuration Debug

CompileC /Users/zrbecker/Library/Developer/Xcode/DerivedData/Test-hbexqsyhqhbcnfdswhkuzhjokkih/Build/Intermediates/Test.build/Debug/Test.build/Objects-normal/i386/main.o Test/main.cpp normal i386 c++ com.apple.compilers.gcc.4_2
cd /Users/zrbecker/Documents/Programming/Test
setenv LANG en_US.US-ASCII
/Developer/usr/bin/gcc-4.2 -x c++ -arch i386 -fmessage-length=0 -pipe -Wno-trigraphs -fpascal-strings -O0 -Wreturn-type -Wunused-variable -Wshorten-64-to-32 -DDEBUG -isysroot /Developer/SDKs/MacOSX10.6.sdk -fasm-blocks -mmacosx-version-min=10.6 -gdwarf-2 -fvisibility-inlines-hidden -iquote /Users/zrbecker/Library/Developer/Xcode/DerivedData/Test-hbexqsyhqhbcnfdswhkuzhjokkih/Build/Intermediates/Test.build/Debug/Test.build/Test-generated-files.hmap -I/Users/zrbecker/Library/Developer/Xcode/DerivedData/Test-hbexqsyhqhbcnfdswhkuzhjokkih/Build/Intermediates/Test.build/Debug/Test.build/Test-own-target-headers.hmap -I/Users/zrbecker/Library/Developer/Xcode/DerivedData/Test-hbexqsyhqhbcnfdswhkuzhjokkih/Build/Intermediates/Test.build/Debug/Test.build/Test-all-target-headers.hmap -iquote /Users/zrbecker/Library/Developer/Xcode/DerivedData/Test-hbexqsyhqhbcnfdswhkuzhjokkih/Build/Intermediates/Test.build/Debug/Test.build/Test-project-headers.hmap -I/Users/zrbecker/Library/Developer/Xcode/DerivedData/Test-hbexqsyhqhbcnfdswhkuzhjokkih/Build/Products/Debug/include -I/Users/zrbecker/local/include -I/Users/zrbecker/Library/Developer/Xcode/DerivedData/Test-hbexqsyhqhbcnfdswhkuzhjokkih/Build/Intermediates/Test.build/Debug/Test.build/DerivedSources/i386 -I/Users/zrbecker/Library/Developer/Xcode/DerivedData/Test-hbexqsyhqhbcnfdswhkuzhjokkih/Build/Intermediates/Test.build/Debug/Test.build/DerivedSources -F/Users/zrbecker/Library/Developer/Xcode/DerivedData/Test-hbexqsyhqhbcnfdswhkuzhjokkih/Build/Products/Debug -F/Users/zrbecker/Documents/Programming/Test/../../../Library/Frameworks -c /Users/zrbecker/Documents/Programming/Test/Test/main.cpp -o /Users/zrbecker/Library/Developer/Xcode/DerivedData/Test-hbexqsyhqhbcnfdswhkuzhjokkih/Build/Intermediates/Test.build/Debug/Test.build/Objects-normal/i386/main.o

Ld /Users/zrbecker/Library/Developer/Xcode/DerivedData/Test-hbexqsyhqhbcnfdswhkuzhjokkih/Build/Products/Debug/Test normal i386
cd /Users/zrbecker/Documents/Programming/Test
setenv MACOSX_DEPLOYMENT_TARGET 10.6
/Developer/usr/bin/g++-4.2 -arch i386 -isysroot /Developer/SDKs/MacOSX10.6.sdk -L/Users/zrbecker/Library/Developer/Xcode/DerivedData/Test-hbexqsyhqhbcnfdswhkuzhjokkih/Build/Products/Debug -L/Users/zrbecker/local/lib -F/Users/zrbecker/Library/Developer/Xcode/DerivedData/Test-hbexqsyhqhbcnfdswhkuzhjokkih/Build/Products/Debug -F/Users/zrbecker/Documents/Programming/Test/../../../Library/Frameworks -filelist /Users/zrbecker/Library/Developer/Xcode/DerivedData/Test-hbexqsyhqhbcnfdswhkuzhjokkih/Build/Intermediates/Test.build/Debug/Test.build/Objects-normal/i386/Test.LinkFileList -mmacosx-version-min=10.6 -framework Cocoa -lallegro -lallegro_main -framework OpenGL -o /Users/zrbecker/Library/Developer/Xcode/DerivedData/Test-hbexqsyhqhbcnfdswhkuzhjokkih/Build/Products/Debug/Test

ld: warning: ignoring file /Users/zrbecker/local/lib/liballegro.dylib, file was built for unsupported file format which is not the architecture being linked (i386)
ld: warning: ignoring file /Users/zrbecker/local/lib/liballegro_main.dylib, file was built for unsupported file format which is not the architecture being linked (i386)
Undefined symbols for architecture i386:
"_main", referenced from:
start in crt1.10.6.o
(maybe you meant: __al_mangled_main)
"_al_install_system", referenced from:
__al_mangled_main in main.o
"_al_create_display", referenced from:
__al_mangled_main in main.o
"_al_map_rgb", referenced from:
__al_mangled_main in main.o
"_al_clear_to_color", referenced from:
__al_mangled_main in main.o
"_al_flip_display", referenced from:
__al_mangled_main in main.o
"_al_rest", referenced from:
__al_mangled_main in main.o
"_al_destroy_display", referenced from:
__al_mangled_main in main.o
ld: symbol(s) not found for architecture i386
collect2: ld returned 1 exit status

这条消息似乎暗示我的库编译错误,但正如我所说,我从终端编译得很好.

This message seems to be suggesting that I have my libraries compiled wrong, but like I said, I compiled fine from the terminal.

我从源代码构建了快板.

I built allegro from source.

tar -xzf allegro-5.0.0.tar.gz
cd allegro-5.0.0
mkdir Build
cd Build
cmake ..
make
sudo make install

我也尝试用 Clang 构建,在上面我添加了这两个命令.

I also tried building with Clang where I added these two command before the above.

export PATH=/Developer/usr/bin:$PATH
export CC=clang

不确定这是否是有用的信息,但我认为它不会造成伤害.

Not sure if that is helpful information, but I assume it couldn't hurt.

感谢您的建议.

推荐答案

这个问题(关于 XCode 4)应该在 快板 5.0.1:

This problem (regarding XCode 4) should be fixed in Allegro 5.0.1:

在 OS X 上强制 _al_mangled_main 的默认"可见性,否则如果使用 XCode4 构建,动态链接器找不到符号

Force "default" visibility of _al_mangled_main on OS X, otherwise the dynamic linker cannot find the symbol if building with XCode4

这篇关于在 Xcode 4 中使用快板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆