Newbie question

47ac448f6d4fedf29eea76b6e82d47df
0
iceboylsg 101 Oct 25, 2009 at 09:50

I just started to learn the OpenAL. I have a problem when i try to compile a new code. it gives me a error:

#include <stdio.h>
#include <stdlib.h>
#include <GL/glut.h>
#include <AL/al.h>
#include <AL/alut.h>

#define NUM_BUFFERS 1
#define NUM_SOURCES 1
#define NUM_ENVIRONMENTS 1

ALfloat listenerPos[]={0.0,0.0,4.0};
ALfloat listenerVel[]={0.0,0.0,0.0};
Alfloat listenerOri[]={0.0,0.0,1.0, 0.0,1.0,0.0};

ALfloat source0Pos[]={ -2.0, 0.0, 0.0};
ALfloat source0Vel[]={ 0.0, 0.0, 0.0};

Aluint buffer[NUM_BUFFERS];
Aluint source[NUM_SOURCES];
ALuint environment[NUM_ENVIRONMENTS];

ALsizei size,freq;
ALenum format;
ALvoid *data;

void init(void)
{
alListenerfv(AL_POSITION,listenerPos);
alListenerfv(AL_VELOCITY,listenerVel);
alListenerfv(AL_ORIENTATION,listenerOri);

alGetError(); // clear any error messages

// Generate buffers, or else no sound will happen!
alGenBuffers(NUM_BUFFERS, buffer);

if(alGetError() != AL_NO_ERROR)
{
printf(“- Error creating buffers !!\n”);
exit(1);
}
else
{
printf(“init() - No errors yet.”);
}

alutLoadWAVFile(“a.wav”,&format,&data,&size,&freq);
alBufferData(buffer[0],format,data,size,freq);
alutUnloadWAV(format,data,size,freq);

alGetError(); /* clear error */
alGenSources(NUM_SOURCES, source);

if(alGetError() != AL_NO_ERROR)
{
printf(“- Error creating sources !!\n”);
exit(2);
}
else
{
printf(“init - no errors after alGenSources\n”);
}

alSourcef(source[0], AL_PITCH, 1.0f);
alSourcef(source[0], AL_GAIN, 1.0f);
alSourcefv(source[0], AL_POSITION, source0Pos);
alSourcefv(source[0], AL_VELOCITY, source0Vel);
alSourcei(source[0], AL_BUFFER,buffer[0]);
alSourcei(source[0], AL_LOOPING, AL_TRUE);

}

1>


Build started: Project: AL_testing, Configuration: Debug Win32


1>Compiling…
1>AL_testing.cpp
1>c:\program files\microsoft visual studio 9.0\vc\include\al\alut.h(5) : fatal error C1083: Cannot open include file: ‘alc.h’: No such file or directory
1>Build log was saved at “file://c:\Documents and Settings\User\My Documents\Visual Studio 2008\Projects\AL_testing\AL_testing\Debug\BuildLog.htm”
1>AL_testing - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Omg, i’m using Microsoft C++ express to compile it. How come it can’t detect the alc.h since it was already inside the AL folder. Any1 know how?

15 Replies

Please log in or register to post a reply.

2b97deded6213469bcd87b65cce5d014
0
Mihail121 102 Oct 25, 2009 at 10:16
  1. Use code tags around code, PLEASE.
  2. Before “learning” OpenAL, learn your development environment of choice. The error points out that a file cannot be found and Visual Studio is pretty good at locating files, as long as you provide ALL necessary include paths to check.
  3. Open alut.h, locate line 5, see how alc.h is included and what path should be added for this include to be located.
47ac448f6d4fedf29eea76b6e82d47df
0
iceboylsg 101 Oct 25, 2009 at 10:46

after i locate the alc.h, another 14 errors come out=.=. Is it my code problem? i stuck here for a few hours=.=.

1>


Build started: Project: AL_testing, Configuration: Debug Win32


1>Compiling…
1>AL_testing.cpp
1>c:\documents and settings\user\my documents\visual studio 2008\projects\al_testing\al_testing\al_testing.cpp(14) : error C2146: syntax error : missing ‘;’ before identifier ‘listenerOri’
1>c:\documents and settings\user\my documents\visual studio 2008\projects\al_testing\al_testing\al_testing.cpp(14) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\documents and settings\user\my documents\visual studio 2008\projects\al_testing\al_testing\al_testing.cpp(14) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\documents and settings\user\my documents\visual studio 2008\projects\al_testing\al_testing\al_testing.cpp(19) : error C2146: syntax error : missing ‘;’ before identifier ‘buffer’
1>c:\documents and settings\user\my documents\visual studio 2008\projects\al_testing\al_testing\al_testing.cpp(19) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\documents and settings\user\my documents\visual studio 2008\projects\al_testing\al_testing\al_testing.cpp(19) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\documents and settings\user\my documents\visual studio 2008\projects\al_testing\al_testing\al_testing.cpp(20) : error C2146: syntax error : missing ‘;’ before identifier ‘source’
1>c:\documents and settings\user\my documents\visual studio 2008\projects\al_testing\al_testing\al_testing.cpp(20) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\documents and settings\user\my documents\visual studio 2008\projects\al_testing\al_testing\al_testing.cpp(20) : error C2086: ‘int Aluint’ : redefinition
1> c:\documents and settings\user\my documents\visual studio 2008\projects\al_testing\al_testing\al_testing.cpp(19) : see declaration of ‘Aluint’
1>c:\documents and settings\user\my documents\visual studio 2008\projects\al_testing\al_testing\al_testing.cpp(20) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\documents and settings\user\my documents\visual studio 2008\projects\al_testing\al_testing\al_testing.cpp(31) : error C2664: ‘alListenerfv’ : cannot convert parameter 2 from ‘int [6]’ to ‘const ALfloat *’ 1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>c:\documents and settings\user\my documents\visual studio 2008\projects\al_testing\al_testing\al_testing.cpp(36) : error C2664: ‘alGenBuffers’ : cannot convert parameter 2 from ‘int [1]’ to ‘ALuint *’ 1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>c:\documents and settings\user\my documents\visual studio 2008\projects\al_testing\al_testing\al_testing.cpp(48) : error C2660: ‘alutLoadWAVFile’ : function does not take 5 arguments
1>c:\documents and settings\user\my documents\visual studio 2008\projects\al_testing\al_testing\al_testing.cpp(53) : error C2664: ‘alGenSources’ : cannot convert parameter 2 from ‘int [1]’ to ‘ALuint *’ 1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>Build log was saved at “file://c:\Documents and Settings\User\My Documents\Visual Studio 2008\Projects\AL_testing\AL_testing\Debug\BuildLog.htm”
1>AL_testing - 14 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

2b97deded6213469bcd87b65cce5d014
0
Mihail121 102 Oct 25, 2009 at 10:49

Yeah, that’s your code now, nothing to do with OpenAL.

36b416ed76cbaff49c8f6b7511458883
0
poita 101 Oct 25, 2009 at 11:01

Your first few errors are caused by you typing Alfloat instead of ALfloat. I’m assuming it’s just a typo, but in case you aren’t aware, C and most modern languages are case sensitive, so Alfloat =/= ALfloat.

Fd80f81596aa1cf809ceb1c2077e190b
0
rouncer 103 Oct 25, 2009 at 11:08

You gotta learn c before you can learn an api.

47ac448f6d4fedf29eea76b6e82d47df
0
iceboylsg 101 Oct 25, 2009 at 12:08

lol…i ty

47ac448f6d4fedf29eea76b6e82d47df
0
iceboylsg 101 Oct 25, 2009 at 13:04

sorry for my newbie question. After i correct all the errors, when i debug it, it comes out this:

1>


Build started: Project: AL_testing, Configuration: Debug Win32


1>Linking…
1>AL_testing.obj : error LNK2019: unresolved external symbol __imp__alSourcei referenced in function “void __cdecl init(void)” (?init@@YAXXZ)
1>AL_testing.obj : error LNK2019: unresolved external symbol __imp__alSourcefv referenced in function “void __cdecl init(void)” (?init@@YAXXZ)
1>AL_testing.obj : error LNK2019: unresolved external symbol __imp__alSourcef referenced in function “void __cdecl init(void)” (?init@@YAXXZ)
1>AL_testing.obj : error LNK2019: unresolved external symbol __imp__alGenSources referenced in function “void __cdecl init(void)” (?init@@YAXXZ)
1>AL_testing.obj : error LNK2019: unresolved external symbol __imp__alutUnloadWAV referenced in function “void __cdecl init(void)” (?init@@YAXXZ)
1>AL_testing.obj : error LNK2019: unresolved external symbol __imp__alBufferData referenced in function “void __cdecl init(void)” (?init@@YAXXZ)
1>AL_testing.obj : error LNK2019: unresolved external symbol __imp__alutLoadWAVFile referenced in function “void __cdecl init(void)” (?init@@YAXXZ)
1>AL_testing.obj : error LNK2019: unresolved external symbol __imp__alGenBuffers referenced in function “void __cdecl init(void)” (?init@@YAXXZ)
1>AL_testing.obj : error LNK2019: unresolved external symbol __imp__alGetError referenced in function “void __cdecl init(void)” (?init@@YAXXZ)
1>AL_testing.obj : error LNK2019: unresolved external symbol __imp__alListenerfv referenced in function “void __cdecl init(void)” (?init@@YAXXZ)
1>MSVCRTD.lib(crtexe.obj) : error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup
1>C:\Documents and Settings\User\My Documents\Visual Studio 2008\Projects\AL_testing\Debug\AL_testing.exe : fatal error LNK1120: 11 unresolved externals
1>Build log was saved at “file://c:\Documents and Settings\User\My Documents\Visual Studio 2008\Projects\AL_testing\AL_testing\Debug\BuildLog.htm”
1>AL_testing - 12 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
what does this mean?

36b416ed76cbaff49c8f6b7511458883
0
poita 101 Oct 25, 2009 at 13:53

It means you aren’t linking to the OpenAL library.

47ac448f6d4fedf29eea76b6e82d47df
0
iceboylsg 101 Oct 25, 2009 at 13:58

lol..i solved this prob..and another problem comes out=.=

fatal error LNK1104: cannot open file ‘C:\Program.obj’

lol…what is this mean again=.=…..

2b97deded6213469bcd87b65cce5d014
0
Mihail121 102 Oct 25, 2009 at 14:12

It means the object file does not exist any more. Recompile, relink and you’re done.

47ac448f6d4fedf29eea76b6e82d47df
0
iceboylsg 101 Oct 25, 2009 at 14:30

omg..i’m getting crazy…..after relink and recompile, it come out again the error link 2019!!

1>


Build started: Project: AL_testing, Configuration: Debug Win32


1>Linking…
1>AL_testing.obj : error LNK2019: unresolved external symbol __imp__alutUnloadWAV referenced in function “void __cdecl init(void)” (?init@@YAXXZ)
1>AL_testing.obj : error LNK2019: unresolved external symbol __imp__alutLoadWAVFile referenced in function “void __cdecl init(void)” (?init@@YAXXZ)
1>MSVCRTD.lib(crtexe.obj) : error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup
1>C:\Documents and Settings\User\My Documents\Visual Studio 2008\Projects\AL_testing\Debug\AL_testing.exe : fatal error LNK1120: 3 unresolved externals
1>Build log was saved at “file://c:\Documents and Settings\User\My Documents\Visual Studio 2008\Projects\AL_testing\AL_testing\Debug\BuildLog.htm”
1>AL_testing - 4 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

it seems the error cannot be solved!!!..help=.=

2b97deded6213469bcd87b65cce5d014
0
Mihail121 102 Oct 25, 2009 at 14:34

Oh my God, I’m seriously getting somewhat aggressive:

Link the ALUT library as well.

47ac448f6d4fedf29eea76b6e82d47df
0
iceboylsg 101 Oct 25, 2009 at 14:44

ty again…. BUT during debugging,

‘AL_testing.exe’: Loaded ‘C:\Documents and Settings\User\My Documents\Visual Studio 2008\Projects\AL_testing\Debug\AL_testing.exe’, Symbols loaded.
‘AL_testing.exe’: Loaded ‘C:\WINDOWS\system32\ntdll.dll’
‘AL_testing.exe’: Loaded ‘C:\WINDOWS\system32\kernel32.dll’
‘AL_testing.exe’: Loaded ‘C:\WINDOWS\system32\OpenAL32.dll’
‘AL_testing.exe’: Loaded ‘C:\WINDOWS\system32\winmm.dll’
‘AL_testing.exe’: Loaded ‘C:\WINDOWS\system32\advapi32.dll’
‘AL_testing.exe’: Loaded ‘C:\WINDOWS\system32\rpcrt4.dll’
‘AL_testing.exe’: Loaded ‘C:\WINDOWS\system32\secur32.dll’
‘AL_testing.exe’: Loaded ‘C:\WINDOWS\system32\gdi32.dll’
‘AL_testing.exe’: Loaded ‘C:\WINDOWS\system32\user32.dll’
‘AL_testing.exe’: Loaded ‘C:\WINDOWS\system32\alut.dll’, Binary was not built with debug information.
‘AL_testing.exe’: Loaded ‘C:\WINDOWS\system32\msvcrt.dll’
‘AL_testing.exe’: Loaded ‘C:\WINDOWS\WinSxS\x86_Microsoft.VC90.DebugCRT_1fc8b3b9a1e18e3b_9.0.30729.1_x-ww_f863c71f\msvcr90d.dll’
‘AL_testing.exe’: Loaded ‘C:\WINDOWS\system32\imm32.dll’
‘AL_testing.exe’: Loaded ‘C:\WINDOWS\system32\lpk.dll’
‘AL_testing.exe’: Loaded ‘C:\WINDOWS\system32\usp10.dll’
The program ‘[5368] AL_testing.exe: Native’ has exited with code 0 (0x0).

is it related to the regsvr32 prob?

47ac448f6d4fedf29eea76b6e82d47df
0
iceboylsg 101 Oct 25, 2009 at 14:46

lol.nth oledi..i know now thank you!!!!!!!!

47ac448f6d4fedf29eea76b6e82d47df
0
iceboylsg 101 Oct 25, 2009 at 15:28

ahh…i have a very noob question. when we using the alutLoadWAVFile function. Where should i save the wav file? Is it i have to assign it first using fopen?