Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/neo4j/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在windows上使用gcc编译FMOD?_Gcc_Compiler Construction_Linker_Mingw_Fmod - Fatal编程技术网

在windows上使用gcc编译FMOD?

在windows上使用gcc编译FMOD?,gcc,compiler-construction,linker,mingw,fmod,Gcc,Compiler Construction,Linker,Mingw,Fmod,我有来自fmod api文档的以下示例 /*=============================================================================================== PlaySound Example Copyright (c), Firelight Technologies Pty, Ltd 2004-2011. This example shows how to simply load and play multi

我有来自fmod api文档的以下示例

/*===============================================================================================
 PlaySound Example
 Copyright (c), Firelight Technologies Pty, Ltd 2004-2011.

 This example shows how to simply load and play multiple sounds.  This is about the simplest
 use of FMOD.
 This makes FMOD decode the into memory when it loads.  If the sounds are big and possibly take
 up a lot of ram, then it would be better to use the FMOD_CREATESTREAM flag so that it is 
 streamed in realtime as it plays.
===============================================================================================*/
#include <windows.h>
#include <stdio.h>
#include <conio.h>

#include "fmod.h"
#include "fmod_errors.h"

void ERRCHECK(FMOD_RESULT result)
{
    if (result != FMOD_OK)
    {
        printf("FMOD error! (%d) %s\n", result, FMOD_ErrorString(result));
        exit(-1);
    }
}


int main(int argc, char *argv[])
{
    FMOD_SYSTEM      *system;
    FMOD_SOUND       *sound1, *sound2, *sound3;
    FMOD_CHANNEL     *channel = 0;
    FMOD_RESULT       result;
    int               key;
    unsigned int      version;

    /*
        Create a System object and initialize.
    */
    result = FMOD_System_Create(&system);
    ERRCHECK(result);

    result = FMOD_System_GetVersion(system, &version);
    ERRCHECK(result);

    if (version < FMOD_VERSION)
    {
        printf("Error!  You are using an old version of FMOD %08x.  This program requires %08x\n", version, FMOD_VERSION);
        return 0;
    }

    result = FMOD_System_Init(system, 32, FMOD_INIT_NORMAL, NULL);
    ERRCHECK(result);

    result = FMOD_System_CreateSound(system, "../media/drumloop.wav", FMOD_HARDWARE, 0, &sound1);
    ERRCHECK(result);

    result = FMOD_Sound_SetMode(sound1, FMOD_LOOP_OFF); /* drumloop.wav has embedded loop points which automatically makes looping turn on, */
    ERRCHECK(result);                                   /* so turn it off here.  We could have also just put FMOD_LOOP_OFF in the above CreateSound call. */

    result = FMOD_System_CreateSound(system, "../media/jaguar.wav", FMOD_SOFTWARE, 0, &sound2);
    ERRCHECK(result);

    result = FMOD_System_CreateSound(system, "../media/swish.wav", FMOD_HARDWARE, 0, &sound3);
    ERRCHECK(result);

    printf("===================================================================\n");
    printf("PlaySound Example.  Copyright (c) Firelight Technologies 2004-2011.\n");
    printf("===================================================================\n");
    printf("\n");
    printf("Press '1' to play a mono sound using hardware mixing\n");
    printf("Press '2' to play a mono sound using software mixing\n");
    printf("Press '3' to play a stereo sound using hardware mixing\n");
    printf("Press 'Esc' to quit\n");
    printf("\n");

    /*
        Main loop.
    */
    do
    {
        if (_kbhit())
        {
            key = _getch();

            switch (key)
            {
                case '1' :
                {
                    result = FMOD_System_PlaySound(system, FMOD_CHANNEL_FREE, sound1, 0, &channel);
                    ERRCHECK(result);
                    break;
                }
                case '2' :
                {
                    result = FMOD_System_PlaySound(system, FMOD_CHANNEL_FREE, sound2, 0, &channel);
                    ERRCHECK(result);
                    break;
                }
                case '3' :
                {
                    result = FMOD_System_PlaySound(system, FMOD_CHANNEL_FREE, sound3, 0, &channel);
                    ERRCHECK(result);
                    break;
                }
            }
        }

        FMOD_System_Update(system);

        {
            unsigned int ms = 0;
            unsigned int lenms = 0;
            int          playing = 0;
            int          paused = 0;
            int          channelsplaying = 0;

            if (channel)
            {
                FMOD_SOUND *currentsound = 0;

                result = FMOD_Channel_IsPlaying(channel, &playing);
                if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE) && (result != FMOD_ERR_CHANNEL_STOLEN))
                {
                    ERRCHECK(result);
                }

                result = FMOD_Channel_GetPaused(channel, &paused);
                if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE) && (result != FMOD_ERR_CHANNEL_STOLEN))
                {
                    ERRCHECK(result);
                }

                result = FMOD_Channel_GetPosition(channel, &ms, FMOD_TIMEUNIT_MS);
                if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE) && (result != FMOD_ERR_CHANNEL_STOLEN))
                {
                    ERRCHECK(result);
                }

                FMOD_Channel_GetCurrentSound(channel, &currentsound);
                if (currentsound)
                {
                    result = FMOD_Sound_GetLength(currentsound, &lenms, FMOD_TIMEUNIT_MS);
                    if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE) && (result != FMOD_ERR_CHANNEL_STOLEN))
                    {
                        ERRCHECK(result);
                    }
                }
            }

            result = FMOD_Sound_GetLength(sound1, &lenms, FMOD_TIMEUNIT_MS);
            if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE) && (result != FMOD_ERR_CHANNEL_STOLEN))
            {
                ERRCHECK(result);
            }

            FMOD_System_GetChannelsPlaying(system, &channelsplaying);

            printf("Time %02d:%02d:%02d/%02d:%02d:%02d : %s : Channels Playing %2d\r", ms / 1000 / 60, ms / 1000 % 60, ms / 10 % 100, lenms / 1000 / 60, lenms / 1000 % 60, lenms / 10 % 100, paused ? "Paused " : playing ? "Playing" : "Stopped", channelsplaying);
        }

        Sleep(10);

    } while (key != 27);

    printf("\n");

    /*
        Shut down
    */
    result = FMOD_Sound_Release(sound1);
    ERRCHECK(result);
    result = FMOD_Sound_Release(sound2);
    ERRCHECK(result);
    result = FMOD_Sound_Release(sound3);
    ERRCHECK(result);
    result = FMOD_System_Close(system);
    ERRCHECK(result);
    result = FMOD_System_Release(system);
    ERRCHECK(result);

    return 0;
}

您的链接器行中似乎缺少FMOD库,您需要-lfmodex在libfmodex.a中链接到您的项目。

这可能是一个非常愚蠢的问题,但我在哪里可以找到所有这些链接器标志的列表?(
-lfmodex
)。我在手册上或任何地方都找不到它们?任何GCC手册都应该提供有关编译/链接标志的详细信息。例如:FMOD文档应该告诉您需要使用哪些链接器标志。(gcc手册一般会告诉您有关标志的信息,但不会告诉您此特定库使用的标志是
-lfmodex
)。文档不需要解释如何链接库,这是预期的知识。文档已经指出您必须链接libfmodex.a。在将lib与GCC链接时,使用'-l'并指定不带前缀或后缀的名称,因此使用'-lfmodex'。
c:\Users\-r.s-\Desktop\fmod>gcc -c -o test.o test.c -I"C:\Program Files (x86)\FM
OD SoundSystem\FMOD Programmers API Windows\api\inc"

c:\Users\-r.s-\Desktop\fmod>gcc -o test.exe test.o -L"C:\Program Files (x86)\FMO
D SoundSystem\FMOD Programmers API Windows\api\lib"
test.o:test.c:(.text+0x413): undefined reference to `FMOD_System_Create@4'
test.o:test.c:(.text+0x436): undefined reference to `FMOD_System_GetVersion@8'
test.o:test.c:(.text+0x499): undefined reference to `FMOD_System_Init@16'
test.o:test.c:(.text+0x4d4): undefined reference to `FMOD_System_CreateSound@20'

test.o:test.c:(.text+0x4f8): undefined reference to `FMOD_Sound_SetMode@8'
test.o:test.c:(.text+0x533): undefined reference to `FMOD_System_CreateSound@20'

test.o:test.c:(.text+0x56e): undefined reference to `FMOD_System_CreateSound@20'

test.o:test.c:(.text+0x643): undefined reference to `FMOD_System_PlaySound@20'
test.o:test.c:(.text+0x67f): undefined reference to `FMOD_System_PlaySound@20'
test.o:test.c:(.text+0x6bb): undefined reference to `FMOD_System_PlaySound@20'
test.o:test.c:(.text+0x6d8): undefined reference to `FMOD_System_Update@4'
test.o:test.c:(.text+0x722): undefined reference to `FMOD_Channel_IsPlaying@8'
test.o:test.c:(.text+0x757): undefined reference to `FMOD_Channel_GetPaused@8'
test.o:test.c:(.text+0x794): undefined reference to `FMOD_Channel_GetPosition@12
'
test.o:test.c:(.text+0x7c9): undefined reference to `FMOD_Channel_GetCurrentSoun
d@8'
test.o:test.c:(.text+0x7ed): undefined reference to `FMOD_Sound_GetLength@12'
test.o:test.c:(.text+0x82a): undefined reference to `FMOD_Sound_GetLength@12'
test.o:test.c:(.text+0x85f): undefined reference to `FMOD_System_GetChannelsPlay
ing@8'
test.o:test.c:(.text+0x9a8): undefined reference to `FMOD_Sound_Release@4'
test.o:test.c:(.text+0x9c4): undefined reference to `FMOD_Sound_Release@4'
test.o:test.c:(.text+0x9e0): undefined reference to `FMOD_Sound_Release@4'
test.o:test.c:(.text+0x9fc): undefined reference to `FMOD_System_Close@4'
test.o:test.c:(.text+0xa18): undefined reference to `FMOD_System_Release@4'
collect2: ld returned 1 exit status

c:\Users\-r.s-\Desktop\fmod>