2

So I have a C++ game program which is supposed to load dynamic class/library loading and all reference to graphic libraries must only be in the respective libraries I'm creating. Now I created the one lib in allegro 5 and the Makefile looks like this

NAME = libSnakeAllegro.so

SRC = SnakeAllegro.cpp
SRC2 = SnakeAllegro.cpp main.cpp
CC =  g++ -g -Wall -Wextra -Werror -std=c++11

FLAGS =  -L allegro/lib -lallegro  -lallegro_acodec -lallegro_audio \
         -lallegro_color -lallegro_dialog -lallegro_font -lallegro_image \
         -lallegro_main -lallegro_memfile -lallegro_physfs \
         -lallegro_primitives -lallegro -lallegro_ttf -lallegro_video

all: $(NAME)

$(NAME): fclean
    @ # $(CC) -o snake $(SRC2) -I ../ -I allegro/include $(FLAGS)
    @  $(CC) -shared -fPIC -o $(NAME) $(SRC) -I ../ -I allegro/include $(FLAGS)

clean:
    @rm -fr $(NAME)
    @rm -fr $(NAME).dSYM

fclean : clean

re: fclean all 

and I load the library with dl_open in another general class but then I get an error like

dl_error : dlopen(lib/libSnakeAllegro.so, 5): Symbol not found: __al_mangled_main
  Referenced from: /home/rmdaba/Desktop/Nibbler/SnakeAllegro/allegro/lib/liballegro_main.5.2.dylib
  Expected in: flat namespace
 in /home/rmdaba/Desktop/Nibbler/SnakeAllegro/allegro/lib/liballegro_main.5.2.dylib

now did some research and found that I have to implement al_run_main(...) but the problem is I don't know where since I don't have a main on my SnakeAllegro class.

leiyc
  • 903
  • 11
  • 23
sassy_rog
  • 1,077
  • 12
  • 30

0 Answers0