Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SDL: Undefined symbols for architecture x86_64

Tags:

c++

g++

x86-64

sdl

I'm working on a simple wrapper for SDL to function as a sort of game engine. At the moment I have a simple temporary main function that looks like this:

#include <iostream>

int main(int argc, char * argv[])
{
  std::cout << "Still in development!\n";
  return 0;
}

Along with some simple functions for the wrapper:

#include "SDL.h"

namespace snowshoe
{
  void initialize()
  {
    SDL_Init(SDL_INIT_EVERYTHING);
  }

  void release()
  {
    SDL_Quit();
  }

  void update(SDL_Surface * screen)
  {
    SDL_Flip(screen);
  }
}

But when I try to compile the two I get the following error:

Undefined symbols for architecture x86_64:
  "_SDL_Flip", referenced from:
      snowshoe::update(SDL_Surface*)      in snowshoe-iru.o
  "_SDL_Init", referenced from:
      snowshoe::initialize()              in snowshoe-iru.o
  "_SDL_Quit", referenced from:
      snowshoe::release()                 in snowshoe-iru.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status

Before anyone asks, I've included all the flags I need:

`sdl-config --cflags` -lSDL

Any ideas? I'm running OSX Mountain Lion and compiling from the command line (not Xcode).

like image 472
beakr Avatar asked Nov 30 '25 08:11

beakr


1 Answers

try `sdl-config --cflags --libs`

on my system it gives

-I/usr/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT -L/usr/lib/x86_64-linux-gnu -lSDL

for example, I do

g++ fractal.cpp -O3 -fopenmp -mavx `sdl-config --cflags --libs` -o fractal_gcc_avx


Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!