-1

I want to make simple application using c++ and SDL libraries on mac. When I try to make executable with makefile, my SDl libraries are in the "/Library/Frameworks" directory.

CC = g++
CFLAGS = -c -std=c++23 -g 
LDFLAGS = -g -I/opt/homebrew/include/SDL2 -F/Library/Frameworks -framework SDL2 -framework SDL2_ttf -framework SDL2_image
SRC = ${wildcard src/* .cpp}
HDR = ${wildcard include/* .hpp}
OBJ = ${SRC:.c=.o}
EXEC = window_app

all: ${SRC} ${OBJ} ${EXEC} 

${EXEC}: ${OBJ}
    ${CC} ${LDFLAGS} $^ -o $@

%.o: %.c ${HDR}
    ${CC} ${CFLAGS} $< -o $@

When I run the executable on my computer it works perfect, but when I transfer the executable to another computer, same os, it throws a error on me saying "SDL2, SDL2_ttf and etc..." don't exist on the computer.

I have tried to include the SDL folders into my project and compiling them but they don't work when they are directly inside my project. My question is there a way to compile the libraries with my project? Please and thank you. I am sorry if I am not clear enough, I am new to all of the coding stuff.

genpfault
  • 51,148
  • 11
  • 85
  • 139

1 Answers1

0

There are two types of libraries:

  • static: they are incorporated in the executable. Usually, .a files.

  • dynamic link: only the definition of the interface (API) is added to the executable. The library itself remains in a separate file that must be installed. Usually a .so file.


These options are not specifically related to the C++ language. They are system conventions used by any compilation chains.