devkitPro / libctru

Homebrew development library for Nintendo 3DS/Horizon OS user mode (Arm11)
https://libctru.devkitpro.org/
770 stars 170 forks source link

sys/lock.h: No such file or directory #512

Closed gamestabled closed 1 year ago

gamestabled commented 1 year ago

Is sys/lock.h missing?

Attempting to build the following fails:

#include <3ds.h>

int main() {
  return 0;
}

with this build output from cmake:

[ 25%] Building CXX object CMakeFiles/z3dr.dir/source/main.cpp.o
In file included from /opt/devkitpro/libctru/include/3ds.h:25:0,
                 from /home/gamestabled/3DS/mvp/Z3DRApp/source/main.cpp:1:
/opt/devkitpro/libctru/include/3ds/synchronization.h:6:10: fatal error: sys/lock.h: No such file or directory
 #include <sys/lock.h>
          ^~~~~~~~~~~~
compilation terminated.
fincs commented 1 year ago

It looks like you are using CMake. Can you post your entire project?

gamestabled commented 1 year ago

I put a minimal version of my project in this repo: https://github.com/gamestabled/cmake_build_fail_example

fincs commented 1 year ago

You seem to be using an ancient, unsupported, third party CMake wrapper around the toolchain. Please note that devkitPro now provides official CMake support. If you install the 3ds-dev package group from pacman you will automatically have it installed. In order to use it, use the following wrapper script, which will automatically provide the correct toolchain file for 3DS:

$ /opt/devkitpro/portlibs/3ds/bin/arm-none-eabi-cmake

A basic CMake project for 3DS looks like this:

cmake_minimum_required(VERSION 3.13)

# Declare project containing a single eponymous executable
project(3ds_application LANGUAGES C CXX ASM)
add_executable(${PROJECT_NAME})

# Declare an asset target for the executable's RomFS (optional)
#dkp_add_asset_target(${PROJECT_NAME}_romfs romfs)

# Generate symbol list and map information (useful for debugging)
dkp_target_generate_symbol_list(${PROJECT_NAME})

# Generate a SMDH file for the executable
ctr_generate_smdh(${PROJECT_NAME}.smdh
    NAME "${PROJECT_NAME}"

    # Other options available:
    #DESCRIPTION "Built with devkitARM & libctru"
    #AUTHOR      "Unspecified Author"
    #ICON        myIcon.png
)

# Specify that the executable is a 3DSX file
ctr_create_3dsx(${PROJECT_NAME}
    SMDH ${PROJECT_NAME}.smdh
    #ROMFS ${PROJECT_NAME}_romfs  # Uncomment this if using RomFS
)

# Options for code generation
target_compile_options(${PROJECT_NAME} PRIVATE
    # Common C/C++ options
    -Wall

    # C++ specific options
    $<$<COMPILE_LANGUAGE:CXX>:-fno-exceptions -fno-rtti>
)

# Options for linking to libraries (example)
#target_link_libraries(${PROJECT_NAME} PRIVATE
#   citro3d
#)

# Source code files
target_sources(${PROJECT_NAME} PRIVATE
    source/main.c
)

# PICA200 shader source code files (example)
#ctr_add_shader_library(${PROJECT_NAME}_shaders
#   source/vertex_shader.pica
#)

# Converted texture (example)
#ctr_add_graphics_target(my_tex IMAGE
#   INPUTS gfx/my_tex.png
#)

# Texture atlas (example)
#ctr_add_graphics_target(my_atlas ATLAS
#   INPUTS gfx/sprite1.png gfx/sprite2.png
#)

# Install assets to RomFS (uncomment as needed)
#dkp_install_assets (${PROJECT_NAME}_romfs TARGETS
#   ${PROJECT_NAME}_shaders
#   my_tex
#   my_atlas
#)