yunusaydin yunusaydin - 1 month ago 24
C++ Question

linker command failed, sdl

I'm trying to compile my very first SDL program, but it doesn't compile.By the way, this shouldn't be about setting up the library I guess because I think that I installed the library properly.

This is my command :

g++ main.cpp -o main -I/Library/Frameworks/SDL2.framework/Headers -framework SDL2

This is my code :

#include <iostream>
#include <SDL.h>

int main(int argc, char **argv){
std::cout << "SDL_Init Error: " << SDL_GetError() << std::endl;
return 1;

return 0;

And this is the error message :

clang: error: linker command failed with exit code 1 (use -v to see invocation)

Invocation :

Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn)
Target: x86_64-apple-darwin13.1.0
Thread model: posix
"/Applications/" -cc1 -triple x86_64-apple-macosx10.9.0 -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -main-file-name main.cpp -mrelocation-model pic -pic-level 2 -mdisable-fp-elim -masm-verbose -munwind-tables -target-cpu core2 -target-linker-version 224.1 -v -resource-dir /Applications/ -isysroot /Applications/ -I /Library/Frameworks/SDL2.framework/Headers -stdlib=libc++ -fdeprecated-macro -fdebug-compilation-dir /Users/yunusaydin -ferror-limit 19 -fmessage-length 80 -stack-protector 1 -mstackrealign -fblocks -fobjc-runtime=macosx-10.9.0 -fobjc-dispatch-method=mixed -fobjc-default-synthesize-properties -fencode-extended-block-signature -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -o /var/folders/ss/mltsqt6n3jn2kv85gmyn060r0000gn/T/main-Ref4XX.o -x c++ main.cpp
clang -cc1 version 5.0 based upon LLVM 3.3svn default target x86_64-apple-darwin13.1.0
ignoring nonexistent directory "/Applications/"
ignoring nonexistent directory "/Applications/"
ignoring nonexistent directory "/Applications/"
#include "..." search starts here:
#include <...> search starts here:
/Applications/ (framework directory)
End of search list.
"/Applications/" -demangle -dynamic -arch x86_64 -macosx_version_min 10.9.0 -syslibroot /Applications/ -o main /var/folders/ss/mltsqt6n3jn2kv85gmyn060r0000gn/T/main-Ref4XX.o -framework SDL2 -lc++ -lSystem /Applications/
ld: framework not found SDL2

What am I doing wrong? Thanks for help :)


Finally, this command works :

g++ main.cpp -o main -I/Library/Frameworks/SDL2.framework/Headers -F/Library/Frameworks -framework SDL2