Skip to content

Traceback (most recent call last) File "/usr/lib/emscripten/emcc.py", line 1639 in <module>.... #22904

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
acerpixels opened this issue Nov 10, 2024 · 3 comments

Comments

@acerpixels
Copy link

acerpixels commented Nov 10, 2024

Good day and I'm new to emscripten. I use archlinux to create my programs and build stuffs with SDL2 and I installed emscripten to port my game to the web. The compilation works well when I only modified settings to build with SDL2 only. However, when I tried to set my SDL2_Image, SDL2_Mixer and SDL2_TTF, I get an encounter with this error.

Emscripten Version:
3.1.71-git

cache:INFO: generating port: sysroot/lib/wasm32-emscripten/libSDL2_image_png.a... (this will be cached in "/home/fruitpunch/.cache/emscripten/sysroot/lib/wasm32-emscripten/libSDL2_image_png.a" for subsequent builds)
Traceback (most recent call last):
  File "/usr/lib/emscripten/emcc.py", line 1639, in <module>
Traceback (most recent call last):
Traceback (most recent call last):
  File "/usr/lib/emscripten/emcc.py", line 1639, in <module>
  File "/usr/lib/emscripten/emcc.py", line 1639, in <module>
    sys.exit(main(sys.argv))
    sys.exit(main(sys.argv))
             ^^^^^^^^^^^^^^
             ^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/contextlib.py", line 81, in inner
  File "/usr/lib/python3.12/contextlib.py", line 81, in inner
    return func(*args, **kwds)
           ^^^^^^^^^^^^^^^^^^^
    return func(*args, **kwds)
  File "/usr/lib/emscripten/emcc.py", line 1632, in main
    sys.exit(main(sys.argv))
           ^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/emscripten/emcc.py", line 1632, in main
             ^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/contextlib.py", line 81, in inner
    return func(*args, **kwds)
           ^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/emscripten/emcc.py", line 1632, in main
Traceback (most recent call last):
  File "/usr/lib/emscripten/emcc.py", line 1639, in <module>
Traceback (most recent call last):
  File "/usr/lib/emscripten/emcc.py", line 1639, in <module>
    ret = run(args)
          ^^^^^^^^^
  File "/usr/lib/emscripten/emcc.py", line 675, in run
    ret = run(args)
          ^^^^^^^^^
  File "/usr/lib/emscripten/emcc.py", line 675, in run
    ret = run(args)
          ^^^^^^^^^

This is my makefile I've wrote at the moment when building my web game.

###################################################
# Written by acerstructor
###################################################

TARGET = CONSOLETEMPLATE_C

# C COMPILER CONFIG
# ---------------------
CC     =gcc
CFLAGS =-Wall -std=c99

# Output file
OUT = ${TARGET}${SUFFIX}

# BUILD TYPE: RELEASE | DEBUG (Default)
BUILD_TYPE ?=DEBUG

# PLATFORMS
# ---------------------
# WINDOWS
# WEB
# LINUX (Default)
PLATFORM ?=LINUX

# PROGRAM ARCHITECTURE : X86 | X64 (Default)
ARCHITECTURE ?=X64

# Output Directory
BIN_DIR :=bin

# Directories
SRC_DIR :=src
OBJ_DIR :=obj
RES_DIR :=res

# Find all .c files inside SRC_DIR and its subdirectories
SRC_SUBDIRS =$(wildcard $(SRC_DIR)/*/ $(SRC_DIR)/*/*/)
SRC         =$(wildcard $(SRC_DIR)/*.c $(SRC_DIR)/*/*.c $(SRC_DIR)/*/*/*.c)

# Define corresponding .o files in OBJ_DIR
OBJ_SUBDIRS =$(patsubst $(SRC_DIR)/%, $(OBJ_DIR)/%, $(SRC_SUBDIRS))
OBJ         =$(patsubst $(SRC_DIR)/%.c, $(OBJ_DIR)/%.o, $(SRC))

SDL2_CONFIG =sdl2-config
PKG_CONFIG  =pkg-config

# Check what platform is selected for build process
# COMPILER CONFIGURATION
ifeq ($(PLATFORM), WINDOWS)
	# COMPILER CONFIG FOR WINDOWS 64 BIT
	CC          =x86_64-w64-mingw32-gcc
	SDL2_CONFIG =x86_64-w64-mingw32-sdl2-config
	PKG_CONFIG  =x86_64-w64-mingw32-pkg-config
	# if ARCHITECTURE is set to 32bit
	ifeq ($(ARCHITECTURE), X86)
		# COMPILER CONFIG FOR WINDOWS 32 BIT
		CC          =i686-w64-mingw32-gcc
		SDL2_CONFIG =i686-w64-mingw32-sdl2-config
		PKG_CONFIG  =i686-w64-mingw32-pkg-config
	endif
	SUFFIX=.exe
else ifeq ($(PLATFORM), WEB)
	# COMPILER CONFIG FOR WEB
	CC       =emcc
	EMFLAGS  =-sUSE_SDL=2 -sUSE_SDL_TTF=2 -sUSE_SDL_IMAGE=2 -sUSE_SDL_MIXER=2 -sSDL2_IMAGE_FORMATS='["png"]' -sSDL2_MIXER_FORMATS='["mp3"]'
	CFLAGS  +=${EMFLAGS}
	LDFLAGS +=${EMFLAGS}
	OUT      =index.html
	#SUFFIX  =.js
endif

# Check what build type is selected
ifeq ($(BUILD_TYPE), RELEASE)
	CFLAGS  +=-O3 -s
else # Sets to DEBUG by default
	CFLAGS  +=-g -DDEBUG
endif

##### 3RD-PARTY LIBRARIES #####
SDL2_CFLAGS =$(shell ${SDL2_CONFIG} --cflags)
SDL2_LIBS   =$(shell ${SDL2_CONFIG} --libs)

SDL2_IMAGE_CFLAGS =$(shell ${PKG_CONFIG} SDL2_image --cflags)
SDL2_IMAGE_LIBS   =$(shell ${PKG_CONFIG} SDL2_image --libs)

SDL2_TTF_CFLAGS =$(shell ${PKG_CONFIG} SDL2_ttf --cflags)
SDL2_TTF_LIBS   =$(shell ${PKG_CONFIG} SDL2_ttf --libs)

SDL2_MIXER_CFLAGS =$(shell ${PKG_CONFIG} SDL2_mixer --cflags)
SDL2_MIXER_LIBS   =$(shell ${PKG_CONFIG} SDL2_mixer --libs)

# PUT ALL LIBRARY FLAGS TO CFLAGS
CFLAGS += ${SDL2_CFLAGS} ${SDL2_IMAGE_CFLAGS} ${SDL2_TTF_CFLAGS} ${SDL2_MIXER_CFLAGS}

ifneq ($(PLATFORM), WEB)
	# PUT ALL LIBRARY LINKING FLAGS TO LDFLAGS
	LDFLAGS += ${SDL2_LIBS} ${SDL2_IMAGE_LIBS} ${SDL2_TTF_LIBS} ${SDL2_MIXER_LIBS}
endif

# BUILD THE PROGRAM
$(TARGET): $(OBJ) 
	@echo "[LOG] Creating bin directory... "; mkdir -p $(BIN_DIR)
	@echo -n "[LINKING] "
	$(CC) $(OBJ) -o $(BIN_DIR)/${OUT} ${LDFLAGS}
	@echo "----- BUILD COMPLETE! ------"

$(OBJ): $(OBJ_DIR)/%.o : $(SRC_DIR)/%.c | $(OBJ_DIR) $(OBJ_SUBDIRS)
	@echo -n "[COMPILING] " 
	$(CC) -c $< -o $@ $(CFLAGS)

# Create obj directory if it doesn't exist
$(OBJ_DIR):
	@mkdir -p $@

$(OBJ_SUBDIRS):
	@mkdir -p $@

clean:
	@echo "[LOG] obj files are cleaned..."
	@rm -rf $(OBJ_DIR)/*.o $(OBJ_DIR)/*/*.o $(OBJ_DIR)/*/*/*.o $(BIN_DIR)/${OUT}

# Removes both bin and obj
cleanall:
	@echo "[LOG] obj and bin files are cleaned..."
	@rm -rf $(BIN_DIR) $(OBJ_DIR)

.

Here is my initialization function I've wrote

bool InitGame()
{
    if (SDL_Init(SDL_INIT_VIDEO) != 0) return false;

    windowPtr = SDL_CreateWindow(
            "SDL2TEMPLATE_C",
            SDL_WINDOWPOS_CENTERED,
            SDL_WINDOWPOS_CENTERED,
            500, 500,
            SDL_WINDOW_MAXIMIZED
    );

    if (windowPtr == NULL) return false;
    
    rendererPtr = SDL_CreateRenderer(
            windowPtr,
            -1, 
            SDL_RENDERER_ACCELERATED
    );

    if (rendererPtr == NULL) return false;
    if (IMG_Init(IMG_INIT_PNG) == 0) return false;
    if (TTF_Init() != 0) return FALSE;
    if (Mix_Init(MIX_INIT_MP3) == 0) return false;

    return true;
}
@kripken
Copy link
Member

kripken commented Nov 12, 2024

Is there nothing more to that error? It looks clipped to me. Or maybe stderr or stdout is missing.

Maybe try something like make &> o and then viewing that file o.

@sbc100
Copy link
Collaborator

sbc100 commented Nov 12, 2024

This looks like it might be a dup of #22860 since it looks like an arch linux issue maybe?

@acerpixels
Copy link
Author

Nevermind, I downloaded and installed an AUR for emsdk and runned sudo emsdk install latest since it wouldn't work without running it as an administrator. Right now, my build works well and there are no errors. Feels like magic to me but no news is good news to me. Apologies for being a nuissance but thanks for helping out guys. :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants