2016-06-09 53 views
0

我是C++的新手,由於uni的要求,我們都使用代碼塊。我在10.10.5 OS X上使用它。現在我必須做一個使用allegro5庫的項目,但我無法安裝它!我花了很多時間嘗試跟隨像http://partitionseven.blogspot.com/2011/01/compiling-allegro-5-with-mac-os-x-snow.html這樣的不同教程,但沒有成功。 有什麼辦法讓它工作?代碼塊osx allegro

編輯

我specifing鐺工具 - 有沒有這樣的目錄在我的Mac /開發人員的/ usr/bin中/鐺當第一encouter問題。我只能在finder中直接找到usr/bin/clang,但是usr文件夾是灰色的 - 這是否意味着什麼? 只有當我點擊Xcode->顯示內容時,才能找到這個路徑/ Developer/usr/bin/clang。所以這是第一件事情不是完全在教程中。不過我能夠運行cmake但我得到一個日誌中這樣的:

The C compiler identification is AppleClang 6.1.0.6020053 
The CXX compiler identification is AppleClang 6.1.0.6020053 
Check for working C compiler: /usr/bin/clang 
Check for working C compiler: /usr/bin/clang -- works 
Detecting C compiler ABI info 
Detecting C compiler ABI info - done 
Detecting C compile features 
Detecting C compile features - done 
Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ 
Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -- works 
Detecting CXX compiler ABI info 
Detecting CXX compiler ABI info - done 
Detecting CXX compile features 
Detecting CXX compile features - done 
Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE) 
Check if the system is big endian 
Searching 16 bit integer 
Looking for sys/types.h 
Looking for sys/types.h - found 
Looking for stdint.h 
Looking for stdint.h - found 
Looking for stddef.h 
Looking for stddef.h - found 
Check size of unsigned short 
Check size of unsigned short - done 
Using unsigned short 
Check if the system is big endian - little endian 
Looking for include file dirent.h 
Looking for include file dirent.h - found 
Looking for include file inttypes.h 
Looking for include file inttypes.h - found 
Looking for include files sys/types.h, linux/joystick.h 
Looking for include files sys/types.h, linux/joystick.h - not found 
Looking for include file stdbool.h 
Looking for include file stdbool.h - found 
Looking for include file stdint.h 
Looking for include file stdint.h - found 
Looking for include file sys/io.h 
Looking for include file sys/io.h - not found 
Looking for include file sys/stat.h 
Looking for include file sys/stat.h - found 
Looking for include file sys/time.h 
Looking for include file sys/time.h - found 
Looking for include file time.h 
Looking for include file time.h - found 
Looking for include file sys/utsname.h 
Looking for include file sys/utsname.h - found 
Looking for include file sys/types.h 
Looking for include file sys/types.h - found 
Looking for include file soundcard.h 
Looking for include file soundcard.h - not found 
Looking for include file sys/soundcard.h 
Looking for include file sys/soundcard.h - not found 
Looking for include file machine/soundcard.h 
Looking for include file machine/soundcard.h - not found 
Looking for include file linux/soundcard.h 
Looking for include file linux/soundcard.h - not found 
Looking for include file libkern/OSAtomic.h 
Looking for include file libkern/OSAtomic.h - found 
Looking for include file sys/inotify.h 
Looking for include file sys/inotify.h - not found 
Looking for include file sys/timerfd.h 
Looking for include file sys/timerfd.h - not found 
Looking for getexecname 
Looking for getexecname - not found 
Looking for mkstemp 
Looking for mkstemp - found 
Looking for mmap 
Looking for mmap - found 
Looking for mprotect 
Looking for mprotect - found 
Looking for sched_yield 
Looking for sched_yield - found 
Looking for sysconf 
Looking for sysconf - found 
Looking for fseeko 
Looking for fseeko - found 
Looking for ftello 
Looking for ftello - found 
Check size of _Bool 
Check size of _Bool - done 
Performing Test ALLEGRO_HAVE_PROCFS_ARGCV 
Performing Test ALLEGRO_HAVE_PROCFS_ARGCV - Failed 
Performing Test ALLEGRO_HAVE_SV_PROCFS_H 
Performing Test ALLEGRO_HAVE_SV_PROCFS_H - Failed 
Performing Test ALLEGRO_HAVE_VA_COPY 
Performing Test ALLEGRO_HAVE_VA_COPY - Success 
Check if constructors are supported - yes 
Found OpenGL: /System/Library/Frameworks/OpenGL.framework 
Looking for pthread.h 
Looking for pthread.h - found 
Looking for pthread_create 
Looking for pthread_create - found 
Found Threads: TRUE 
Found OpenAL: /System/Library/Frameworks/OpenAL.framework 
Found FLAC: /usr/local/include 
Performing Test FLAC_COMPILES 
Performing Test FLAC_COMPILES - Success 
Could NOT find DUMB (missing: DUMB_INCLUDE_DIR DUMB_LIBRARY) 
WARNING: libdumb not found, disabling support. <http://dumb.sourceforge.net/> 
Found VORBIS: /usr/local/include 
Performing Test VORBIS_COMPILES 
Performing Test VORBIS_COMPILES - Success 
Found Freetype: /usr/local/lib/libfreetype.dylib (found version "2.6.3") 
Found ZLIB: /usr/lib/libz.dylib (found version "1.2.8") 
Found PhysFS: /usr/local/lib/libphysfs.dylib 
Found PHYSFS: /usr/local/lib/libphysfs.dylib 
Performing Test PHYSFS_IMPLICIT_ZLIB 
Performing Test PHYSFS_IMPLICIT_ZLIB - Success 
Could NOT find LATEX (missing: LATEX_COMPILER) 
Configuring done 
CMake Warning (dev): 
    Policy CMP0042 is not set: MACOSX_RPATH is enabled by default. Run "cmake 
    --help-policy CMP0042" for policy details. Use the cmake_policy command to 
    set the policy and suppress this warning. 

    MACOSX_RPATH is not specified for the following targets: 

    allegro 
    allegro_acodec 
    allegro_audio 
    allegro_color 
    allegro_dialog 
    allegro_font 
    allegro_image 
    allegro_main 
    allegro_memfile 
    allegro_physfs 
    allegro_primitives 
    allegro_ttf 

This warning is for project developers. Use -Wno-dev to suppress it. 

Generating done 

由CMake的生成的文件

MacBook-Air-ukasz:build lukasz$ ls 
CMakeCache.txt  cmake_install.cmake include 
CMakeFiles  demos   lib 
Makefile  docs   tests 
addons   examples 

謝謝@MikeKinghan,好像我又進了一步 - 我沒有得到錯誤。但我已經開放的代碼塊,粘貼示例代碼(一個來自教程),我得到一個錯誤,而copiling

g++ -c /Users/lukasz/Desktop/test_allegro/test.cpp -o /Users/lukasz/Desktop/test_allegro/test.o 
g++ -o /Users/lukasz/Desktop/test_allegro/test /Users/lukasz/Desktop/test_allegro/test.o 
Undefined symbols for architecture x86_64: 
    "_al_clear_to_color", referenced from: 
     __al_mangled_main in test.o 
    "_al_create_display", referenced from: 
     __al_mangled_main in test.o 
    "_al_destroy_display", referenced from: 
     __al_mangled_main in test.o 
    "_al_flip_display", referenced from: 
     __al_mangled_main in test.o 
    "_al_install_system", referenced from: 
     __al_mangled_main in test.o 
    "_al_map_rgb", referenced from: 
     __al_mangled_main in test.o 
    "_al_rest", referenced from: 
     __al_mangled_main in test.o 
    "_main", referenced from: 
    implicit entry/start for main executable 
    (maybe you meant: __al_mangled_main) 
ld: symbol(s) not found for architecture x86_64 
clang: error: linker command failed with exit code 1 (use -v to see invocation) 

編輯

當我運行從終端與

測試應用
gcc alleg5test.c -o alleg5test -L/usr/local/lib -lallegro -lallegro_main 
./alleg5test 

它的工作 - 我有一個黑色的屏幕。所以可能我必須「用代碼塊加入庫,任何想法 - 我只發現了一個windows教程。

+0

歡迎來到SO,你需要分享你已經採取的步驟以及未能透露你在做什麼錯誤的具體證據,參見[如何提問](http:// stackoverflow 。com/help/how-to-ask) –

+0

除乳膠缺失外,看起來還行。安裝Latex,根據建議修復 策略警告(請參閱[thread](http://stackoverflow.com/q/31561309/1362568)),再次運行CMake,然後在每個教程中繼續執行 。 –

+0

這是SO上的一個問題。你已經解決了你發佈的問題 ,並且使你能夠解決一個新問題(關於哪一個 我什麼都不知道)。盡你最大努力通過你自己的努力解決新問題 - 包括[學習如何使用Code :: Blocks](http://wiki.codeblocks.org/index.php/User_documentation) - 如果你可以' t,發佈一個新問題。 –

回答

1

由於SO限制,我無法回覆,但這裏有一種可能性:您的Allegro庫是爲i386構建的,不包括x86_64體系可以檢查庫在命令行上,但它並不總是告訴你,你有什麼,除非你用i386和x86_64你這樣做是這樣的:。

file liballegro.afile liballegro.dylib

如果有關於x86_64的任何信息,那麼我就錯了,如果它不是這個問題,那麼你有兩種選擇:或者將Allegro構建爲x86_64,或者將你的程序構建爲i386 。要建立快板爲64位x86和i386的,以下內容添加到您的CMake命令是這樣的:

cmake .. -DCMAKE_OSX_ARCHITECTURES="x86_64;i386" ...

或者只在指定的cmake的GUI,變量。您可以通過刪除它和分號來忽略其中一個或另一個。

現在要構建具有特定體系結構的程序,如果您從命令行使用gcc(如鏈接的教程),請使用-m開關。要建立i386的,使用-m32並建立x86_64的使用-m64(或者你現在可以在Mac上使用-arch i386 -arch x86_64兩個我認爲(不知道和不)所以,你的命令是:

gcc -m64 ...地方.. 。和以前一樣