Forum > Cocoa

SDL2 on mac

(1/2) > >>

xinyiman:
Hi everyone, I need to compile a project that uses sdl2s on mac. I downloaded the binaries from the link

https://www.libsdl.org/download-2.0.php

I copied the framework to / Library / Frameworks as explained in the readme.txt but it doesn't compile. Tells me:


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---Hint: (11030) Start of reading config file /fpcupdeluxe/installazioni/20210424_stabile/fpc/bin/x86_64-darwin/fpc.cfgHint: (11031) End of reading config file /fpcupdeluxe/installazioni/20210424_stabile/fpc/bin/x86_64-darwin/fpc.cfgFree Pascal Compiler version 3.2.0-r45643 [2021/04/24] for x86_64Copyright (c) 1993-2020 by Florian Klaempfl and others(1002) Target OS: Darwin for x86_64(3104) Compiling trustInvaders.lpr(9001) Assembling (pipe) /Users/ngit/Downloads/TrustInvaders/lib/x86_64-darwin/trustInvaders.s(9015) Linking /Users/ngit/Downloads/TrustInvaders/bin/x86_64-darwin/trustInvadersUndefined symbols for architecture x86_64:  "_SDL_RenderDrawRect", referenced from:      _SDLGAMEENEMIES$_$TENEMY_$__$$_DRAW in sdlGameEnemies.o      _SHOTS$_$TEXPLOSION_$__$$_DRAW in Shots.o      _SHOTS$_$TSHOT_$__$$_DRAWSHOT in Shots.o  "_SDL_SetTextureColorMod", referenced from:      _SCNGAMEPLAY$_$TMENU_$__$$_DRAW in scnGamePlay.o      _SDLGAMEENEMIES$_$TENEMY_$__$$_DRAW in sdlGameEnemies.o      _SHOTS$_$TEXPLOSION_$__$$_DRAW in Shots.o  "_SDL_SetTextureBlendMode", referenced from:      _SCNMAINMENU$_$TMAINMENUSCENE_$__$$_DOONRENDER$PSDL_RENDERER in scnMainMenu.o      _SCNGAMEPLAY$_$TMENU_$__$$_DRAW in scnGamePlay.o  "_SDL_JoystickNameForIndex", referenced from:      _SDLENGINE$_$TENGINE_$__$$_DOCHECKDEVICES in sdlEngine.o  "_Mix_PauseMusic", referenced from:      _SDLGAMESOUND$_$TSOUNDMANAGER_$__$$_STOPMUSIC$LONGINT in sdlGameSound.o  "_Mix_PlayMusic", referenced from:      _SDLGAMESOUND$_$TSOUNDMANAGER_$__$$_PLAYMUSIC$LONGINT$LONGINT in sdlGameSound.o      _SDLGAMESOUND$_$TSOUNDMANAGER_$__$$_STOPMUSIC$LONGINT in sdlGameSound.o  "_Mix_LoadMUS", referenced from:      _SDLGAMESOUND$_$TSOUNDMANAGER_$__$$_LOADMUSIC$ANSISTRING$$LONGINT in sdlGameSound.o  "_Mix_FreeChunk", referenced from:      _SDLGAMESOUND$_$TSOUNDMANAGER_$__$$_DESTROY in sdlGameSound.o  "_SDL_JoystickOpen", referenced from:      _SDLENGINE$_$TENGINE_$__$$_DOCHECKDEVICES in sdlEngine.o  "_IMG_Load", referenced from:      _SDLGAMETEXTURE$_$TTEXTUREMANAGER_$__$$_LOADPNGTEXTURE$ANSISTRING$$TTEXTURE in sdlGameTexture.o  "_TTF_OpenFont", referenced from:      _SDLGAMETEXT$_$TFONTS_$__$$_LOADFONTS$ANSISTRING in sdlGameText.o  "_SDL_RenderPresent", referenced from:      _SDLENGINE$_$TENGINE_$__$$_DORENDER in sdlEngine.o  "_SDL_SetRenderDrawBlendMode", referenced from:      _SDLGAMETEXT$_$TTEXTMANAGER_$__$$_DRAW$ANSISTRING$LONGINT$LONGINT$TGAMEFONT in sdlGameText.o      _SDLGAMETEXT$_$TTEXTMANAGER_$__$$_DRAW$ANSISTRING$LONGINT$LONGINT$TGAMEFONT$BYTE in sdlGameText.o      _SCNINTRO$_$TINTROSCENE_$__$$_DOONRENDER$PSDL_RENDERER in scnIntro.o      _SCNMAINMENU$_$TMAINMENUSCENE_$__$$_DOONRENDER$PSDL_RENDERER in scnMainMenu.o      _SCNGAMEPLAY$_$TGAMEPLAYSCENE_$__$$_DRAWUI in scnGamePlay.o      _SCNGAMEPLAY$_$TMENU_$__$$_DRAW in scnGamePlay.o      _SDLPARTICLES$_$TEMITTER_$__$$_DRAW in sdlParticles.o      ...  "_SDL_SetTextureAlphaMod", referenced from:      _SDLGAMETEXT$_$TTEXTMANAGER_$__$$_DRAW$ANSISTRING$LONGINT$LONGINT$TGAMEFONT$BYTE in sdlGameText.o      _SCNINTRO$_$TINTROSCENE_$__$$_DOONRENDER$PSDL_RENDERER in scnIntro.o      _SCNMAINMENU$_$TMAINMENUSCENE_$__$$_DOONRENDER$PSDL_RENDERER in scnMainMenu.o      _SCNGAMEPLAY$_$TMENU_$__$$_DRAW in scnGamePlay.o      _SHOTS$_$TEXPLOSION_$__$$_DRAW in Shots.o  "_SDL_RenderCopy", referenced from:      _SDLGAMETEXT$_$TTEXTMANAGER_$__$$_DRAW$ANSISTRING$LONGINT$LONGINT$TGAMEFONT in sdlGameText.o      _SDLGAMETEXT$_$TTEXTMANAGER_$__$$_DRAW$ANSISTRING$LONGINT$LONGINT$TGAMEFONT$BYTE in sdlGameText.o      _SCNINTRO$_$TINTROSCENE_$__$$_DOONRENDER$PSDL_RENDERER in scnIntro.o      _SCNMAINMENU$_$TMAINMENUSCENE_$__$$_DOONRENDER$PSDL_RENDERER in scnMainMenu.o      _SCNGAMEPLAY$_$TGAMEPLAYSCENE_$__$$_DRAWUI in scnGamePlay.o      _SCNGAMEPLAY$_$TMENU_$__$$_DRAW in scnGamePlay.o      _SDLGAMEPLAYER$_$TPLAYER_$__$$_DRAW in sdlGamePlayer.o      ...  "_TTF_RenderUTF8_Blended", referenced from:      _SDLGAMETEXT$_$TGAMEFONTTEXTURELIST_$__$$_ADD$ANSISTRING$TGAMEFONT$$LONGINT in sdlGameText.o  "_Mix_PlayChannelTimed", referenced from:      _SDL2_MIXER_$$_MIX_PLAYCHANNEL$LONGINT$PMIX_CHUNK$LONGINT$$LONGINT in sdl2_mixer.o  "_SDL_CreateTextureFromSurface", referenced from:      _SDLGAMETEXT$_$TGAMEFONTTEXTURELIST_$__$$_ADD$ANSISTRING$TGAMEFONT$$LONGINT in sdlGameText.o      _SDLGAMETEXTURE$_$TTEXTUREMANAGER_$__$$_LOADPNGTEXTURE$ANSISTRING$$TTEXTURE in sdlGameTexture.o  "_SDL_FreeSurface", referenced from:      _SDLGAMETEXT$_$TGAMEFONTTEXTURELIST_$__$$_ADD$ANSISTRING$TGAMEFONT$$LONGINT in sdlGameText.o      _SDLGAMETEXTURE$_$TTEXTUREMANAGER_$__$$_LOADPNGTEXTURE$ANSISTRING$$TTEXTURE in sdlGameTexture.o  "_SDL_JoystickNumAxes", referenced from:      _SDLENGINE$_$TENGINE_$__$$_DOCHECKDEVICES in sdlEngine.o  "_IMG_Init", referenced from:      _SDLENGINE$_$TENGINE_$__$$_INITIALIZE$LONGINT$LONGINT$ANSISTRING in sdlEngine.o  "_SDL_DestroyTexture", referenced from:      _SDLGAMETEXT$_$TGAMEFONTTEXTURELIST_$__$$_DESTROY in sdlGameText.o  "_SDL_GetError", referenced from:      _SDLENGINE$_$TENGINE_$__$$_INITIALIZE$LONGINT$LONGINT$ANSISTRING in sdlEngine.o      _SDL2_IMAGE_$$_IMG_GETERROR$$PCHAR in sdl2_image.o      _SDL2_MIXER_$$_MIX_GETERROR$$PCHAR in sdl2_mixer.o      _SDL2_TTF_$$_TTF_GETERROR$$PCHAR in sdl2_ttf.o      _SDLGAMETEXT$_$TGAMEFONTTEXTURELIST_$__$$_ADD$ANSISTRING$TGAMEFONT$$LONGINT in sdlGameText.o      _SDLGAMETEXTURE$_$TTEXTUREMANAGER_$__$$_LOADPNGTEXTURE$ANSISTRING$$TTEXTURE in sdlGameTexture.o  "_SDL_RWFromFile", referenced from:      _SDL2_MIXER_$$_MIX_LOADWAV$PCHAR$$PMIX_CHUNK in sdl2_mixer.o  "_SDL_RenderCopyEx", referenced from:      _SCNINTRO$_$TINTROSCENE_$__$$_DOONRENDER$PSDL_RENDERER in scnIntro.o      _SCNMAINMENU$_$TMAINMENUSCENE_$__$$_DOONRENDER$PSDL_RENDERER in scnMainMenu.o      _SCNGAMEPLAY$_$TMENU_$__$$_DRAW in scnGamePlay.o      _SHOTS$_$TSHOT_$__$$_DRAWSHOT in Shots.o  "_Mix_LoadWAV_RW", referenced from:      _SDL2_MIXER_$$_MIX_LOADWAV$PCHAR$$PMIX_CHUNK in sdl2_mixer.o  "_SDL_GetTicks", referenced from:      _SDLENGINE$_$TENGINE_$__$$_RUN in sdlEngine.o      _SDLGAMEUTILS$_$TFPSCOUNTER_$__$$_RESET in sdlGameUtils.o      _SDLGAMEUTILS$_$TFPSCOUNTER_$__$$_INCREMENT in sdlGameUtils.o      _SDLSCENE$_$TSCENE_$__$$_DOONUPDATE$REAL in sdlScene.o      _SDLSCENE$_$TSCENE_$__$$_EXECUTEDELAYED$LONGWORD$TSCENEMETHOD in sdlScene.o      _SCNINTRO$_$TINTROSCENE_$__$$_CREATE$$TINTROSCENE in scnIntro.o      _SDLGAMEENEMIES$_$TENEMY_$__$$_UPDATE$REAL in sdlGameEnemies.o      ...  "_Mix_FreeMusic", referenced from:      _SDLGAMESOUND$_$TSOUNDMANAGER_$__$$_DESTROY in sdlGameSound.o      _SDLGAMESOUND$_$TSOUNDMANAGER_$__$$_FREEMUSIC$LONGINT in sdlGameSound.o  "_Mix_Quit", referenced from:      _SDLENGINE$_$TENGINE_$__$$_DESTROY in sdlEngine.o  "_SDL_Delay", referenced from:      _SDLENGINE$_$TENGINE_$__$$_RUN in sdlEngine.o  "_SDL_ShowCursor", referenced from:      _SDLENGINE$_$TENGINE_$__$$_HIDECURSOR in sdlEngine.o  "_SDL_RenderDrawLine", referenced from:      _SCNMAINMENU$_$TMAINMENUSCENE_$__$$_DOONRENDER$PSDL_RENDERER in scnMainMenu.o      _SCNGAMEPLAY$_$TGAMEPLAYSCENE_$__$$_DRAWUI in scnGamePlay.o      _SCNGAMEPLAY$_$TMENU_$__$$_DRAW in scnGamePlay.o  "_SDL_CreateWindow", referenced from:      _SDLENGINE$_$TENGINE_$__$$_INITIALIZE$LONGINT$LONGINT$ANSISTRING in sdlEngine.o  "_SDL_CreateRenderer", referenced from:      _SDLENGINE$_$TENGINE_$__$$_INITIALIZE$LONGINT$LONGINT$ANSISTRING in sdlEngine.o  "_IMG_Quit", referenced from:      _SDLENGINE$_$TENGINE_$__$$_DESTROY in sdlEngine.o  "_SDL_SetWindowTitle", referenced from:      _SDLENGINE$_$TENGINE_$__$$_ONFPSCOUNTERUPDATED$TFPSCOUNTER$WORD in sdlEngine.o  "_SDL_RenderFillRect", referenced from:      _SCNMAINMENU$_$TMAINMENUSCENE_$__$$_DOONRENDER$PSDL_RENDERER in scnMainMenu.o      _SCNGAMEPLAY$_$TGAMEPLAYSCENE_$__$$_DRAWUI in scnGamePlay.o      _SCNGAMEPLAY$_$TMENU_$__$$_DRAW in scnGamePlay.o      _STARTFIELD$_$TSTARFIELD_$__$$_DRAW in StartField.o      _SDLPARTICLES$_$TEMITTER_$__$$_DRAW in sdlParticles.o  "_SDL_Quit", referenced from:      _SDLENGINE$_$TENGINE_$__$$_DESTROY in sdlEngine.o  "_SDL_RenderClear", referenced from:      _SDLENGINE$_$TENGINE_$__$$_DORENDER in sdlEngine.o  "_SDL_Init", referenced from:      _SDLENGINE$_$TENGINE_$__$$_INITIALIZE$LONGINT$LONGINT$ANSISTRING in sdlEngine.o  "_Mix_OpenAudio", referenced from:      _SDLENGINE$_$TENGINE_$__$$_INITIALIZE$LONGINT$LONGINT$ANSISTRING in sdlEngine.o  "_SDL_DestroyRenderer", referenced from:      _SDLENGINE$_$TENGINE_$__$$_DESTROY in sdlEngine.o  "_TTF_Init", referenced from:      _SDLENGINE$_$TENGINE_$__$$_INITIALIZE$LONGINT$LONGINT$ANSISTRING in sdlEngine.o  "_SDL_DestroyWindow", referenced from:      _SDLENGINE$_$TENGINE_$__$$_DESTROY in sdlEngine.o  "_SDL_HasIntersection", referenced from:      _SDLGAMEOBJECTS$_$TGAMEOBJECT_$__$$_CHECKCOLLISIONS$TGAMEOBJECTLIST in sdlGameObjects.o      _SDLGAMEOBJECTS$_$TGAMEOBJECT_$__$$_CHECKCOLLISIONS$TGAMEOBJECT in sdlGameObjects.o  "_SDL_NumJoysticks", referenced from:      _SDLENGINE$_$TENGINE_$__$$_DOCHECKDEVICES in sdlEngine.o  "_SDL_JoystickNumButtons", referenced from:      _SDLENGINE$_$TENGINE_$__$$_DOCHECKDEVICES in sdlEngine.o  "_TTF_CloseFont", referenced from:      _SDLGAMETEXT$_$TFONTS_$__$$_DESTROY in sdlGameText.o  "_SDL_JoystickClose", referenced from:      _SDLENGINE$_$TENGINE_$__$$_DOCHECKDEVICES in sdlEngine.o  "_SDL_SetRenderDrawColor", referenced from:      _SDLENGINE$_$TENGINE_$__$$_DORENDER in sdlEngine.o      _SCNMAINMENU$_$TMAINMENUSCENE_$__$$_DOONRENDER$PSDL_RENDERER in scnMainMenu.o      _SCNGAMEPLAY$_$TGAMEPLAYSCENE_$__$$_DRAWUI in scnGamePlay.o      _SCNGAMEPLAY$_$TMENU_$__$$_DRAW in scnGamePlay.o      _STARTFIELD$_$TSTARFIELD_$__$$_DRAW in StartField.o      _SDLPARTICLES$_$TEMITTER_$__$$_DRAW in sdlParticles.o      _SDLGAMEENEMIES$_$TENEMY_$__$$_DRAW in sdlGameEnemies.o      ...  "_SDL_PollEvent", referenced from:      _SDLENGINE$_$TENGINE_$__$$_DOHANDLEEVENTS in sdlEngine.o  "_SDL_JoystickNumBalls", referenced from:      _SDLENGINE$_$TENGINE_$__$$_DOCHECKDEVICES in sdlEngine.old: symbol(s) not found for architecture x86_64An error occurred while linking Error: (9013) Error while linkingFatal: (10026) There were 1 errors compiling module, stoppingFatal: (1018) Compilation abortedError: /fpcupdeluxe/installazioni/20210424_stabile/fpc/bin/x86_64-darwin/ppcx64 returned an error exitcode 
Why?

howardpc:
In your .lpr do you have something like the following?
--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---{$ifdef darwin}{$linkframework SDL2}{$linkframework SDL2_mixer}// add these and others as required by the routines you use// e.g. {$linkframework SDL2_ttf}// e.g. {$linkframework SDL2_image}{$endif}

xinyiman:
Thanks for the tip. Now when I compile it tells me:

ld: framework not found SDL2

But as I said above, I'm sure I have the framework on my mac.

trev:
You need to tell the linker where to look for the SDL2 framework.

On the fpc command line add: OPT="-XR/path/to/sdl2_framework"

Or in an .fpc.cfg file in your home directory:

#include /private/etc/fpc.cfg
-XR/path/to/sdl2_framework

xinyiman:
Ok, I created .fp.cfg file


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---#include /private/etc/fpc.cfg-XR/Library/Frameworks/SDL2.framework
In "Project options"->"Configuration and target"-> check "Use other configuration files to compilator (@) " + "/Users/ngit/.fp.cfg"

When I compile return this


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---Compila il progetto, Destinazione: /Users/ngit/Downloads/TrustInvaders/bin/x86_64-darwin/trustInvaders: Codice di uscita 1, Errori: 1, suggerimenti: 6Hint: Start of reading config file /fpcupdeluxe/installazioni/20210424_stabile/fpc/bin/x86_64-darwin/fpc.cfgHint: End of reading config file /fpcupdeluxe/installazioni/20210424_stabile/fpc/bin/x86_64-darwin/fpc.cfgHint: Start of reading config file /Users/ngit/.fp.cfgHint: Start of reading config file /private/etc/fpc.cfgHint: End of reading config file /private/etc/fpc.cfgHint: End of reading config file /Users/ngit/.fp.cfgVerbose: Free Pascal Compiler version 3.2.0-r45643 [2021/04/24] for x86_64Verbose: Copyright (c) 1993-2020 by Florian Klaempfl and othersVerbose: Target OS: Darwin for x86_64Verbose: Compiling trustInvaders.lprVerbose: Assembling (pipe) /Users/ngit/Downloads/TrustInvaders/lib/x86_64-darwin/trustInvaders.sVerbose: Linking /Users/ngit/Downloads/TrustInvaders/bin/x86_64-darwin/trustInvadersDebug: ld: library not found for -lobjcAn error occurred while linking Error: Error while linkingVerbose: There were 1 errors compiling module, stoppingVerbose: Compilation abortedVerbose: /fpcupdeluxe/installazioni/20210424_stabile/fpc/bin/x86_64-darwin/ppcx64 returned an error exitcode 

Navigation

[0] Message Index

[#] Next page

Go to full version