Reputation: 479
UPDATE 2 The compiletor found SDL.H with the following command:
g++ \
-I/usr/local/include/SDL2/ -D_GNU_SOURCE=1 -D_THREAD_SAFE \
-L/usr/local/lib -Wl,-framework,Cocoa \
sdltest.cpp
Could someone please explain what the code above says?!
This is my new errors, I realize that I dont compile any other .cpp than my own, should've I do that?
sdltest.cpp:10:2: error: use of undeclared identifier 'SDL_WM_SetCaption'
SDL_WM_SetCaption("SDL Test", "SDL Test");
^
sdltest.cpp:13:24: error: use of undeclared identifier 'SDL_SetVideoMode'
SDL_Surface* screen = SDL_SetVideoMode(640, 480, 0, 0);
^
sdltest.cpp:19:20: error: use of undeclared identifier 'SDL_DisplayFormat'
SDL_Surface* bg = SDL_DisplayFormat(temp);
^
sdltest.cpp:55:3: error: use of undeclared identifier 'SDL_UpdateRect'
SDL_UpdateRect(screen, 0, 0, 0, 0);
END OF UPDATE 2
UPDATE 1
I now compile with
g++ \
-Wall -Wextra -pedantic \
-std=c++11 \
-I/Library/Frameworks/SDL.framework/Versions/A/Headers/-lSDL2 -framework Cocoa \
lesson01.cpp
The output is
2 warnings generated.
Undefined symbols for architecture x86_64:
"_main", referenced from:
implicit entry/start for main executable
(maybe you meant: _SDL_main)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
END OF UPDATE 1
I just installed SDL(as a framework) for the first time and I have some problem to link it correctly!
I compile with
g++ \
-Wall -Wextra -pedantic \
-std=c++11 \
-I/Library/Frameworks/SDL.framework/Headers -lSDL2 -framework Cocoa \
lesson01.cpp
Which return
ld: library not found for -lSDL2
clang: error: linker command failed with exit code 1 (use -v to see invocation)
The path seems to be correct since
ls /Library/Frameworks/SDL.framework/Headers | grep SDL.h
return
SDL.h
My Code:
#include "SDL.h"
int main( int argc, char* args[] )
{
return 0
}
If I use
#include "SDL/SDL.h"
instead, the compiler return
lesson01.cpp:5:10: fatal error: 'SDL/SDL.h' file not found
What can I do to fix this?
Should it be SDL.H or SDL/SDL.h?
I prefer to work via terminal so Xcode is not an option!
Upvotes: 1
Views: 1817
Reputation: 2344
There's a bit too much of a mess here to go over everything, but here's something...
You need to decide if you are using SDL 1.2 or SDL 2.0. They are distinct libraries and come in separate frameworks. Your compile errors with SDL_WM_SetCaption
etc. are from code which uses SDL 1.2.
Also decide if you will use a framework for SDL or if you will link to the lib itself (e.g. -lSDL).
Including SDL.h is more portable than SDL/SDL.h. You just need to make sure that you specify the header search path (with -I).
Upvotes: 0