Skip to content
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

Add CMake support #4

Open
mcuee opened this issue Feb 24, 2024 · 8 comments
Open

Add CMake support #4

mcuee opened this issue Feb 24, 2024 · 8 comments
Labels
enhancement New feature or request

Comments

@mcuee
Copy link
Collaborator

mcuee commented Feb 24, 2024

Reference

To do:

  1. improve https://github.com/avrdudes/libserialport (not part of this issue)
    2. to make it compatible with MSVC
    3. adding CMake build script
  2. integrate into avrdude MSVC build (not part of this issue)

This issue will address No 2 and No 3, which may require quite some efforts.

@mcuee mcuee changed the title Add CMake and MSVC support Add MSVC support using CMake Feb 24, 2024
@mcuee
Copy link
Collaborator Author

mcuee commented Feb 25, 2024

vcpkg does not have the port yet. There was a new port request but nobody has done the port yet.

@ndim
Copy link

ndim commented Feb 26, 2024

FYI, I have a very basic CMakeLists.txt in PR #3.

@mcuee
Copy link
Collaborator Author

mcuee commented Feb 26, 2024

@ndim

Nice. You are almost there already.

Need to add something similar to avrdude, for MinGW.

if(WIN32 OR MINGW)
    list(APPEND EXTRA_WINDOWS_RESOURCES "${PROJECT_BINARY_DIR}/src/windows.rc")
    list(APPEND EXTRA_WINDOWS_LIBRARIES setupapi hid ws2_32)
endif()

Build log

MINGW64 /c/work/avr/avrdude_test/avrdude_libserialport_pr3
$ cmake -B build_cmake_mingw64
-- Building for: Ninja
-- The C compiler identification is GNU 13.2.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/msys64/mingw64/bin/cc.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Configuring done (5.7s)
-- Generating done (0.0s)
-- Build files have been written to: C:/work/avr/avrdude_test/avrdude_libserialport_pr3/build_cmake_mingw64

$ cmake --build build_cmake_mingw64
[2/2] Linking C shared library libserialport.dll
FAILED: libserialport.dll liblibserialport.dll.a
C:\WINDOWS\system32\cmd.exe /C "cd . && C:\msys64\mingw64\bin\cc.exe    -shared -o libserialport.dll -Wl,--out-implib,liblibserialport.dll.a -Wl,--major-image-version,0,--minor-image-version,1 CMakeFiles/libserialport.dir/windows.c.obj  -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 && cd ."
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/libserialport.dir/windows.c.obj:windows.c:(.text+0x9f2): undefined reference to `__imp_CM_Get_Parent'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/libserialport.dir/windows.c.obj:windows.c:(.text+0xa17): undefined reference to `__imp_CM_Get_Device_IDA'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/libserialport.dir/windows.c.obj:windows.c:(.text+0xc52): undefined reference to `__imp_SetupDiGetClassDevsA'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/libserialport.dir/windows.c.obj:windows.c:(.text+0xca1): undefined reference to `__imp_SetupDiEnumDeviceInterfaces'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/libserialport.dir/windows.c.obj:windows.c:(.text+0xcdb): undefined reference to `__imp_SetupDiGetDeviceInterfaceDetailA'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/libserialport.dir/windows.c.obj:windows.c:(.text+0xd45): undefined reference to `__imp_SetupDiGetDeviceInterfaceDetailA'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/libserialport.dir/windows.c.obj:windows.c:(.text+0xd74): undefined reference to `__imp_CM_Get_Parent'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/libserialport.dir/windows.c.obj:windows.c:(.text+0xe4e): undefined reference to `__imp_SetupDiEnumDeviceInfo'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/libserialport.dir/windows.c.obj:windows.c:(.text+0xe66): undefined reference to `__imp_SetupDiDestroyDeviceInfoList'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/libserialport.dir/windows.c.obj:windows.c:(.text+0xec2): undefined reference to `__imp_SetupDiGetClassDevsA'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/libserialport.dir/windows.c.obj:windows.c:(.text+0xeda): undefined reference to `sp_last_error_message'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/libserialport.dir/windows.c.obj:windows.c:(.text+0xf23): undefined reference to `sp_free_error_message'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/libserialport.dir/windows.c.obj:windows.c:(.text+0xf70): undefined reference to `__imp_SetupDiOpenDevRegKey'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/libserialport.dir/windows.c.obj:windows.c:(.text+0x1073): undefined reference to `__imp_CM_Get_Parent'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/libserialport.dir/windows.c.obj:windows.c:(.text+0x10b1): undefined reference to `__imp_CM_Get_DevNode_Registry_PropertyA'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/libserialport.dir/windows.c.obj:windows.c:(.text+0x1142): undefined reference to `__imp_CM_Get_DevNode_Registry_PropertyA'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/libserialport.dir/windows.c.obj:windows.c:(.text+0x1170): undefined reference to `__imp_CM_Get_Parent'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/libserialport.dir/windows.c.obj:windows.c:(.text+0x11f9): undefined reference to `__imp_CM_Get_Device_IDA'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/libserialport.dir/windows.c.obj:windows.c:(.text+0x1273): undefined reference to `__imp_CM_Get_DevNode_Registry_PropertyA'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/libserialport.dir/windows.c.obj:windows.c:(.text+0x133a): undefined reference to `__imp_CM_Get_DevNode_Registry_PropertyA'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/libserialport.dir/windows.c.obj:windows.c:(.text+0x13ba): undefined reference to `__imp_CM_Get_Parent'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/libserialport.dir/windows.c.obj:windows.c:(.text+0x150f): undefined reference to `__imp_SetupDiEnumDeviceInfo'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/libserialport.dir/windows.c.obj:windows.c:(.text+0x152d): undefined reference to `__imp_SetupDiDestroyDeviceInfoList'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/libserialport.dir/windows.c.obj:windows.c:(.text+0x15ff): undefined reference to `sp_last_error_message'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/libserialport.dir/windows.c.obj:windows.c:(.text+0x163f): undefined reference to `sp_free_error_message'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/libserialport.dir/windows.c.obj:windows.c:(.text+0x16f7): undefined reference to `sp_last_error_message'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/libserialport.dir/windows.c.obj:windows.c:(.text+0x1737): undefined reference to `sp_free_error_message'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/libserialport.dir/windows.c.obj:windows.c:(.text+0x18de): undefined reference to `list_append'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/libserialport.dir/windows.c.obj:windows.c:(.rdata$.refptr.sp_debug_handler[.refptr.sp_debug_handler]+0x0): undefined reference to `sp_debug_handler'
collect2.exe: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.

@mcuee
Copy link
Collaborator Author

mcuee commented Feb 26, 2024

Similar for VS2019.

PS C:\work\avr\avrdude_test\avrdude_libserialport_pr3> cmake -B .\build_cmake_vs2019
-- Building for: Visual Studio 16 2019
-- Selecting Windows SDK version 10.0.22000.0 to target Windows 10.0.19045.
-- The C compiler identification is MSVC 19.29.30153.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: C:/work/avr/avrdude_test/avrdude_libserialport_pr3/build_cmake_vs2019
PS C:\work\avr\avrdude_test\avrdude_libserialport_pr3> cmake --build .\build_cmake_vs2019
Microsoft (R) Build Engine version 16.11.2+f32259642 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

  Checking Build System
  Building Custom Rule C:/work/avr/avrdude_test/avrdude_libserialport_pr3/CMakeLists.txt
  windows.c
C:\work\avr\avrdude_test\avrdude_libserialport_pr3\libserialport.h(292,1): warning C4005: 'SP_API': macro redefinition
[C:\work\avr\avrdude_test\avrdude_libserialport_pr3\build_cmake_vs2019\libserialport.vcxproj]
C:\work\avr\avrdude_test\avrdude_libserialport_pr3\build_cmake_vs2019\config.h(17): message : see previous definition o
f 'SP_API' [C:\work\avr\avrdude_test\avrdude_libserialport_pr3\build_cmake_vs2019\libserialport.vcxproj]
windows.obj : error LNK2019: unresolved external symbol __imp_sp_last_error_message referenced in function get_port_det
ails [C:\work\avr\avrdude_test\avrdude_libserialport_pr3\build_cmake_vs2019\libserialport.vcxproj]
windows.obj : error LNK2019: unresolved external symbol __imp_sp_free_error_message referenced in function get_port_det
ails [C:\work\avr\avrdude_test\avrdude_libserialport_pr3\build_cmake_vs2019\libserialport.vcxproj]
windows.obj : error LNK2019: unresolved external symbol __imp_SetupDiEnumDeviceInfo referenced in function get_port_det
ails [C:\work\avr\avrdude_test\avrdude_libserialport_pr3\build_cmake_vs2019\libserialport.vcxproj]
windows.obj : error LNK2019: unresolved external symbol __imp_SetupDiDestroyDeviceInfoList referenced in function get_p
ort_details [C:\work\avr\avrdude_test\avrdude_libserialport_pr3\build_cmake_vs2019\libserialport.vcxproj]
windows.obj : error LNK2019: unresolved external symbol __imp_SetupDiEnumDeviceInterfaces referenced in function get_us
b_details [C:\work\avr\avrdude_test\avrdude_libserialport_pr3\build_cmake_vs2019\libserialport.vcxproj]
windows.obj : error LNK2019: unresolved external symbol __imp_SetupDiGetDeviceInterfaceDetailA referenced in function g
et_usb_details [C:\work\avr\avrdude_test\avrdude_libserialport_pr3\build_cmake_vs2019\libserialport.vcxproj]
windows.obj : error LNK2019: unresolved external symbol __imp_SetupDiGetClassDevsA referenced in function get_port_deta
ils [C:\work\avr\avrdude_test\avrdude_libserialport_pr3\build_cmake_vs2019\libserialport.vcxproj]
windows.obj : error LNK2019: unresolved external symbol __imp_SetupDiOpenDevRegKey referenced in function get_port_deta
ils [C:\work\avr\avrdude_test\avrdude_libserialport_pr3\build_cmake_vs2019\libserialport.vcxproj]
windows.obj : error LNK2019: unresolved external symbol __imp_CM_Get_Device_IDA referenced in function get_port_details
 [C:\work\avr\avrdude_test\avrdude_libserialport_pr3\build_cmake_vs2019\libserialport.vcxproj]
windows.obj : error LNK2019: unresolved external symbol __imp_CM_Get_DevNode_Registry_PropertyA referenced in function
get_port_details [C:\work\avr\avrdude_test\avrdude_libserialport_pr3\build_cmake_vs2019\libserialport.vcxproj]
windows.obj : error LNK2019: unresolved external symbol __imp_CM_Get_Parent referenced in function get_port_details [C:
\work\avr\avrdude_test\avrdude_libserialport_pr3\build_cmake_vs2019\libserialport.vcxproj]
windows.obj : error LNK2019: unresolved external symbol list_append referenced in function list_ports [C:\work\avr\avrd
ude_test\avrdude_libserialport_pr3\build_cmake_vs2019\libserialport.vcxproj]
windows.obj : error LNK2001: unresolved external symbol sp_debug_handler [C:\work\avr\avrdude_test\avrdude_libserialpor
t_pr3\build_cmake_vs2019\libserialport.vcxproj]
C:\work\avr\avrdude_test\avrdude_libserialport_pr3\build_cmake_vs2019\Debug\libserialport.dll : fatal error LNK1120: 13
 unresolved externals [C:\work\avr\avrdude_test\avrdude_libserialport_pr3\build_cmake_vs2019\libserialport.vcxproj]

@ndim
Copy link

ndim commented Feb 27, 2024

As of ndim@0574156, the CI builds are succeeding:
https://github.com/ndim/libserialport/actions/runs/8069048688

This includes cmake ("cm") and autotools ("at") builds:

  • linux-x86_64 (at, cm)
  • linux (i386, armhf, arm64) x (cm, at)
  • macos-x86_64 (cm, at)
  • msvc (cm only)
  • msys2+mingw (mingw64, ucrt64, clang64) (cm, at)

The commit series and the resulting tree need massive cleanups, but at least we now have a known good state, at least in the sense of "it succeeds building something".

@mcuee
Copy link
Collaborator Author

mcuee commented Mar 2, 2024

CMake build under macOS ARM64 (macOS 14.3.1, Mac Mini M1).

mcuee@mcuees-Mac-mini libserialport_ndim % cmake -B build_cmake
-- The C compiler identification is AppleClang 15.0.0.15000100
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Configuring done (0.4s)
-- Generating done (0.0s)
-- Build files have been written to: /Users/mcuee/build/avr/libserialport_ndim/build_cmake
mcuee@mcuees-Mac-mini libserialport_ndim % cmake --build build_cmake 
[ 25%] Building C object CMakeFiles/libserialport.dir/serialport.c.o
[ 50%] Building C object CMakeFiles/libserialport.dir/timing.c.o
[ 75%] Building C object CMakeFiles/libserialport.dir/macosx.c.o
[100%] Linking C shared library libserialport.dylib
[100%] Built target libserialport

@mcuee mcuee changed the title Add MSVC support using CMake Add CMake support Mar 2, 2024
@mcuee
Copy link
Collaborator Author

mcuee commented Mar 2, 2024

CMake under Linux.

mcuee@UbuntuSwift3 ~/build/avr/libserialport_ndim (add-version-suffix)$ cmake -B build_cmake
-- The C compiler identification is GNU 9.4.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Configuring done (0.4s)
-- Generating done (0.0s)
-- Build files have been written to: /home/mcuee/build/avr/libserialport_ndim/build_cmake
mcuee@UbuntuSwift3 ~/build/avr/libserialport_ndim (add-version-suffix)$ cmake --build build_cmake/
[ 20%] Building C object CMakeFiles/libserialport.dir/serialport.c.o
[ 40%] Building C object CMakeFiles/libserialport.dir/timing.c.o
[ 60%] Building C object CMakeFiles/libserialport.dir/linux.c.o
[ 80%] Building C object CMakeFiles/libserialport.dir/linux_termios.c.o
[100%] Linking C shared library libserialport.so
[100%] Built target libserialport

mcuee@UbuntuSwift3 ~/build/avr/libserialport_ndim (add-version-suffix)$ sudo cmake --build build_cmake --target install
[100%] Built target libserialport
Install the project...
-- Install configuration: ""
-- Installing: /usr/local/lib/pkgconfig/libserialport.pc
-- Installing: /usr/local/lib/libserialport.so.0.1.0
-- Installing: /usr/local/lib/libserialport.so.0
-- Installing: /usr/local/lib/libserialport.so
-- Installing: /usr/local/include/libserialport.h

@mcuee
Copy link
Collaborator Author

mcuee commented Mar 24, 2024

Not so sure how to carry out cross-compiler under macOS though.
arduino/avrdude-packing#31 (comment)

root@c44bc932da28:~/build/libserialport_cmake# cmake -B build_darwin -DCMAKE_C_COMPILER=o64-clang -DCMAKE_EXE_LINKER_FLAGS="-L/opt/lib/x86_64-apple-darwin13/lib" -DCMAKE_C_FLAGS="-I/opt/lib/x86_64-apple-darwin13/include -pthread -framework Foundation -framework IOKit -framework Cocoa -framework Security" -DCMAKE_PREFIX_PATH=/opt/lib/x86_64-apple-darwin13    -- The C compiler identification is Clang 10.0.0
-- Check for working C compiler: /opt/osxcross/target/bin/o64-clang
-- Check for working C compiler: /opt/osxcross/target/bin/o64-clang -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /root/build/libserialport_cmake/build_darwin
root@c44bc932da28:~/build/libserialport_cmake# cmake -build build_darwin
-- Configuring done
-- Generating done
-- Build files have been written to: /root/build/libserialport_cmake/build_darwin
root@c44bc932da28:~/build/libserialport_cmake# cmake -B build_darwin -DCMAKE_C_COMPILER=o64-clang -DCMAKE_EXE_LINKER_FLAGS="-L/opt/lib/x86_64-apple-darwin13/lib" -DCMAKE_C_FLAGS="-I/opt/lib/x86_64-apple-darwin13/include -pthread -framework Foundation -framework IOKit -framework Cocoa -framework Security" -DCMAKE_PREFIX_PATH=/opt/lib/x86_64-apple-darwin13
-- Configuring done
-- Generating done
-- Build files have been written to: /root/build/libserialport_cmake/build_darwin
root@c44bc932da28:~/build/libserialport_cmake# cmake --build build_darwin
Scanning dependencies of target libserialport
[ 20%] Building C object CMakeFiles/libserialport.dir/serialport.c.o
clang: warning: -framework Foundation: 'linker' input unused [-Wunused-command-line-argument]
clang: warning: -framework IOKit: 'linker' input unused [-Wunused-command-line-argument]
clang: warning: -framework Cocoa: 'linker' input unused [-Wunused-command-line-argument]
clang: warning: -framework Security: 'linker' input unused [-Wunused-command-line-argument]
[ 40%] Building C object CMakeFiles/libserialport.dir/timing.c.o
clang: warning: -framework Foundation: 'linker' input unused [-Wunused-command-line-argument]
clang: warning: -framework IOKit: 'linker' input unused [-Wunused-command-line-argument]
clang: warning: -framework Cocoa: 'linker' input unused [-Wunused-command-line-argument]
clang: warning: -framework Security: 'linker' input unused [-Wunused-command-line-argument]
[ 60%] Building C object CMakeFiles/libserialport.dir/linux.c.o
clang: warning: -framework Foundation: 'linker' input unused [-Wunused-command-line-argument]
clang: warning: -framework IOKit: 'linker' input unused [-Wunused-command-line-argument]
clang: warning: -framework Cocoa: 'linker' input unused [-Wunused-command-line-argument]
clang: warning: -framework Security: 'linker' input unused [-Wunused-command-line-argument]
/root/build/libserialport_cmake/linux.c:198:23: error: incomplete definition of type 'struct dirent'
        char buf[sizeof(entry->d_name) + 23];
                        ~~~~~^
/root/build/libserialport_cmake/linux.c:193:9: note: forward declaration of 'struct dirent'
        struct dirent *entry;
               ^
/root/build/libserialport_cmake/linux.c:200:2: error: use of undeclared identifier 'DIR'
        DIR *dir;
        ^
/root/build/libserialport_cmake/linux.c:200:7: error: use of undeclared identifier 'dir'; did you mean 'div'?
        DIR *dir;
             ^~~
             div
/opt/osxcross/target/bin/../SDK/MacOSX10.15.sdk/usr/include/stdlib.h:144:8: note: 'div' declared here
div_t    div(int, int) __pure2;
         ^
/root/build/libserialport_cmake/linux.c:205:14: warning: implicit declaration of function 'opendir' is invalid in C99 [-Wimplicit-function-declaration]
        if (!(dir = opendir("/sys/class/tty")))
                    ^
/root/build/libserialport_cmake/linux.c:205:8: error: use of undeclared identifier 'dir'
        if (!(dir = opendir("/sys/class/tty")))
              ^
/root/build/libserialport_cmake/linux.c:209:18: warning: implicit declaration of function 'readdir' is invalid in C99 [-Wimplicit-function-declaration]
        while ((entry = readdir(dir))) {
                        ^
/root/build/libserialport_cmake/linux.c:209:26: error: use of undeclared identifier 'dir'; did you mean 'div'?
        while ((entry = readdir(dir))) {
                                ^~~
                                div
/opt/osxcross/target/bin/../SDK/MacOSX10.15.sdk/usr/include/stdlib.h:144:8: note: 'div' declared here
div_t    div(int, int) __pure2;
         ^
/root/build/libserialport_cmake/linux.c:209:16: warning: incompatible integer to pointer conversion assigning to 'struct dirent *' from 'int' [-Wint-conversion]
        while ((entry = readdir(dir))) {
                      ^ ~~~~~~~~~~~~
/root/build/libserialport_cmake/linux.c:210:56: error: incomplete definition of type 'struct dirent'
                snprintf(buf, sizeof(buf), "/sys/class/tty/%s", entry->d_name);
                                                                ~~~~~^
/opt/osxcross/target/bin/../SDK/MacOSX10.15.sdk/usr/include/secure/_stdio.h:57:62: note: expanded from macro 'snprintf'
  __builtin___snprintf_chk (str, len, 0, __darwin_obsz(str), __VA_ARGS__)
                                                             ^~~~~~~~~~~
/root/build/libserialport_cmake/linux.c:193:9: note: forward declaration of 'struct dirent'
        struct dirent *entry;
               ^
/root/build/libserialport_cmake/linux.c:214:64: error: incomplete definition of type 'struct dirent'
                        snprintf(buf, sizeof(buf), "/sys/class/tty/%s/device", entry->d_name);
                                                                               ~~~~~^
/opt/osxcross/target/bin/../SDK/MacOSX10.15.sdk/usr/include/secure/_stdio.h:57:62: note: expanded from macro 'snprintf'
  __builtin___snprintf_chk (str, len, 0, __darwin_obsz(str), __VA_ARGS__)
                                                             ^~~~~~~~~~~
/root/build/libserialport_cmake/linux.c:193:9: note: forward declaration of 'struct dirent'
        struct dirent *entry;
               ^
/root/build/libserialport_cmake/linux.c:221:48: error: incomplete definition of type 'struct dirent'
                snprintf(name, sizeof(name), "/dev/%s", entry->d_name);
                                                        ~~~~~^
/opt/osxcross/target/bin/../SDK/MacOSX10.15.sdk/usr/include/secure/_stdio.h:57:62: note: expanded from macro 'snprintf'
  __builtin___snprintf_chk (str, len, 0, __darwin_obsz(str), __VA_ARGS__)
                                                             ^~~~~~~~~~~
/root/build/libserialport_cmake/linux.c:193:9: note: forward declaration of 'struct dirent'
        struct dirent *entry;
               ^
/root/build/libserialport_cmake/linux.c:256:2: warning: implicit declaration of function 'closedir' is invalid in C99 [-Wimplicit-function-declaration]
        closedir(dir);
        ^
/root/build/libserialport_cmake/linux.c:256:11: error: use of undeclared identifier 'dir'; did you mean 'div'?
        closedir(dir);
                 ^~~
                 div
/opt/osxcross/target/bin/../SDK/MacOSX10.15.sdk/usr/include/stdlib.h:144:8: note: 'div' declared here
div_t    div(int, int) __pure2;
         ^
4 warnings and 9 errors generated.
make[2]: *** [CMakeFiles/libserialport.dir/build.make:89: CMakeFiles/libserialport.dir/linux.c.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:76: CMakeFiles/libserialport.dir/all] Error 2
make: *** [Makefile:130: all] Error 2

@mcuee mcuee added the enhancement New feature or request label Apr 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants