openGL + SDL kļūda

Parunāsim par OpenGL
Post Reply
Message
Author
User avatar
kristapuciitis
Posts: 163
Joined: 03 Jun 2011, 14:22

openGL + SDL kļūda

#1 Post by kristapuciitis » 13 Jul 2011, 22:41

Sveiki!
Man radās problēma. Es sekoju http://lazyfoo.net/SDL_tutorials/index.php šim tutoriālim. Man ir Visual C++ 2010, es uzstādīju SDL pēc viņa instrukcijas http://lazyfoo.net/SDL_tutorials/lesson ... /index.php šeit. Tur man viss gāja pareizi bez kļūdām. Tad aizgāju uz http://lazyfoo.net/SDL_tutorials/lesson36/index.php šo lapu un lapas apakšā, kur ir tas download links, novilku cpp failu, nokopēju visu no turienes un ieliku iekšā tajā failā, kuru vajadzēja sataisīt pirmajā tutoriālī, palaboju include tā, kā bija norādīts tutoriālī ("SDL.h" un "SDL_opengl.h", nevis "SDL/SDL.h" un "SDL/SDL_opengl.h"). Man izmeta tādus errorus:
1>------ Rebuild All started: Project: kkil, Configuration: Debug Win32 ------
1> bbb.cpp
1>c:\users\kristaps\documents\visual studio 2010\projects\kkil\bbb.cpp(200): warning C4244: 'argument' : conversion from 'int' to 'GLfloat', possible loss of data
1>c:\users\kristaps\documents\visual studio 2010\projects\kkil\bbb.cpp(200): warning C4244: 'argument' : conversion from 'int' to 'GLfloat', possible loss of data
1>c:\users\kristaps\documents\visual studio 2010\projects\kkil\bbb.cpp(210): warning C4244: 'argument' : conversion from 'const int' to 'GLfloat', possible loss of data
1>c:\users\kristaps\documents\visual studio 2010\projects\kkil\bbb.cpp(211): warning C4244: 'argument' : conversion from 'const int' to 'GLfloat', possible loss of data
1>c:\users\kristaps\documents\visual studio 2010\projects\kkil\bbb.cpp(211): warning C4244: 'argument' : conversion from 'const int' to 'GLfloat', possible loss of data
1>c:\users\kristaps\documents\visual studio 2010\projects\kkil\bbb.cpp(212): warning C4244: 'argument' : conversion from 'const int' to 'GLfloat', possible loss of data
1>LINK : fatal error LNK1561: entry point must be defined
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
Palīdziet, lūdzu. Paskatieties arī tos tutoriāļus, varbūt viņi ir kļūdaini.
Gooby pls

snake5
Posts: 353
Joined: 07 Dec 2010, 04:54
Contact:

Re: openGL + SDL kļūda

#2 Post by snake5 » 13 Jul 2011, 23:06

Neesi "main" funkciju definējis. Tajā 36tajā pamācībā tādas arī nav, jo visticamāk tā balstās uz kādas citas pamācības koda. Vajag kopēt uzmanīgāk.. ;)

User avatar
kristapuciitis
Posts: 163
Joined: 03 Jun 2011, 14:22

Re: openGL + SDL kļūda

#3 Post by kristapuciitis » 14 Jul 2011, 00:30

Tas kā ir "neesu definējis"? Man tur ir tā:

Code: Select all

int main( int argc, char *argv[] )
Apgriezu kodu līdz šādam:

Code: Select all

#include "SDL.h"
#include "SDL_opengl.h"

int main( int argc, char *argv[] )
{
	return 0;
}
Vienalga ir errors. :(
1>------ Build started: Project: kkil, Configuration: Debug Win32 ------
1> bbb.cpp
1>LINK : fatal error LNK1561: entry point must be defined
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Ok, šo erroru vairs nemet.

Bet vienalga- kad kompilēju visu pilno cpp failu no tutoriāļa, izmet daudz erroru:
1>------ Rebuild All started: Project: hh, Configuration: Debug Win32 ------
1> hjjj.cpp
1>c:\users\kristaps\documents\visual studio 2010\projects\hh\hjjj.cpp(200): warning C4244: 'argument' : conversion from 'int' to 'GLfloat', possible loss of data
1>c:\users\kristaps\documents\visual studio 2010\projects\hh\hjjj.cpp(200): warning C4244: 'argument' : conversion from 'int' to 'GLfloat', possible loss of data
1>c:\users\kristaps\documents\visual studio 2010\projects\hh\hjjj.cpp(210): warning C4244: 'argument' : conversion from 'const int' to 'GLfloat', possible loss of data
1>c:\users\kristaps\documents\visual studio 2010\projects\hh\hjjj.cpp(211): warning C4244: 'argument' : conversion from 'const int' to 'GLfloat', possible loss of data
1>c:\users\kristaps\documents\visual studio 2010\projects\hh\hjjj.cpp(211): warning C4244: 'argument' : conversion from 'const int' to 'GLfloat', possible loss of data
1>c:\users\kristaps\documents\visual studio 2010\projects\hh\hjjj.cpp(212): warning C4244: 'argument' : conversion from 'const int' to 'GLfloat', possible loss of data
1>hjjj.obj : error LNK2019: unresolved external symbol __imp__glGetError@0 referenced in function "bool __cdecl init_GL(void)" (?init_GL@@YA_NXZ)
1>hjjj.obj : error LNK2019: unresolved external symbol __imp__glOrtho@48 referenced in function "bool __cdecl init_GL(void)" (?init_GL@@YA_NXZ)
1>hjjj.obj : error LNK2019: unresolved external symbol __imp__glLoadIdentity@0 referenced in function "bool __cdecl init_GL(void)" (?init_GL@@YA_NXZ)
1>hjjj.obj : error LNK2019: unresolved external symbol __imp__glMatrixMode@4 referenced in function "bool __cdecl init_GL(void)" (?init_GL@@YA_NXZ)
1>hjjj.obj : error LNK2019: unresolved external symbol __imp__glClearColor@16 referenced in function "bool __cdecl init_GL(void)" (?init_GL@@YA_NXZ)
1>hjjj.obj : error LNK2019: unresolved external symbol __imp__glEnd@0 referenced in function "public: void __thiscall Square::show(void)" (?show@Square@@QAEXXZ)
1>hjjj.obj : error LNK2019: unresolved external symbol __imp__glVertex3f@12 referenced in function "public: void __thiscall Square::show(void)" (?show@Square@@QAEXXZ)
1>hjjj.obj : error LNK2019: unresolved external symbol __imp__glColor4f@16 referenced in function "public: void __thiscall Square::show(void)" (?show@Square@@QAEXXZ)
1>hjjj.obj : error LNK2019: unresolved external symbol __imp__glBegin@4 referenced in function "public: void __thiscall Square::show(void)" (?show@Square@@QAEXXZ)
1>hjjj.obj : error LNK2019: unresolved external symbol __imp__glTranslatef@12 referenced in function "public: void __thiscall Square::show(void)" (?show@Square@@QAEXXZ)
1>hjjj.obj : error LNK2019: unresolved external symbol __imp__glClear@4 referenced in function _SDL_main
1>c:\users\kristaps\documents\visual studio 2010\Projects\hh\Debug\hh.exe : fatal error LNK1120: 11 unresolved externals
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
Palīdziet, lūdzu!
Pamēģināu kompilēt citus primitīvus kodus, bet visos izlec šis te errors. Ko tas nozīmē?? Kā no tā izbēgt??
Gooby pls

bubu
Guru
Guru
Posts: 398
Joined: 07 Dec 2010, 12:54

Re: openGL + SDL kļūda

#4 Post by bubu » 14 Jul 2011, 10:03

kristapuciitis wrote: Vienalga ir errors. :(
...
Ok, šo erroru vairs nemet.
Izsakies skaidrāk? :)
Ja tev nav main, tad tev tādu erroru metīs. Ja tev ir mains, tad nemetīs. Viss vienkārši.

Šīs kļūdas norāda, ka linkeris nevar atrast OpenGL funckijas (glXYZ...). Tas nozīmē, ka neesi linkerim pateicis, ka tavam exe failam vajadzēs OpenGL bibliotēku. To dara atverot projekta propertijus, un tur zem "Linker" sadaļas, "Input" kategorijas jāpievieno "OpenGL32.lib" fails "Additional Dependencies" parametram (pārējos divus, kas bildē, tev nevajag):
Image
Tikai neizmet ārā visu to, kas jau tur ir.

User avatar
kristapuciitis
Posts: 163
Joined: 03 Jun 2011, 14:22

Re: openGL + SDL kļūda

#5 Post by kristapuciitis » 14 Jul 2011, 11:12

omg, bubu, tu esi dievs!! :D Paldies! Viss iet. :)
Gooby pls

Post Reply

Return to “OpenGL”